summaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorSteve Twiss <stwiss.opensource@diasemi.com>2016-07-06 17:12:03 +0200
committerLee Jones <lee.jones@linaro.org>2016-10-04 16:48:02 +0200
commit547120edbacba09ae8becab65aa86e3fd4e75e9a (patch)
tree51490ef01f6132caa334a3871f3e1d05d6124bae /drivers/mfd
parentmfd: dm355evm_msp: Refactoring for add_child() (diff)
downloadlinux-547120edbacba09ae8becab65aa86e3fd4e75e9a.tar.xz
linux-547120edbacba09ae8becab65aa86e3fd4e75e9a.zip
mfd: da9053: Ensure the FAULT_LOG is cleared during MFD driver probe
The function da9052_clear_fault_log() is added to mitigate the case of persistent data being transferred between reboots. Clearance of any the persistent information within the DA9053 FAULT_LOG register must be completed during start-up so the fault-log does not continue with previous values. A clearance function has been added here in the kernel driver because wiping the fault-log cannot be counted on outside the Linux kernel. Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Reviewed-by: Adam Thomson <adam.thomson.opensource@diasemi.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/da9052-core.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index c0bf68a3e614..a88c2065d8ab 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -167,6 +167,7 @@ static bool da9052_reg_writeable(struct device *dev, unsigned int reg)
case DA9052_EVENT_B_REG:
case DA9052_EVENT_C_REG:
case DA9052_EVENT_D_REG:
+ case DA9052_FAULTLOG_REG:
case DA9052_IRQ_MASK_A_REG:
case DA9052_IRQ_MASK_B_REG:
case DA9052_IRQ_MASK_C_REG:
@@ -541,6 +542,52 @@ const struct regmap_config da9052_regmap_config = {
};
EXPORT_SYMBOL_GPL(da9052_regmap_config);
+static int da9052_clear_fault_log(struct da9052 *da9052)
+{
+ int ret = 0;
+ int fault_log = 0;
+
+ fault_log = da9052_reg_read(da9052, DA9052_FAULTLOG_REG);
+ if (fault_log < 0) {
+ dev_err(da9052->dev,
+ "Cannot read FAULT_LOG %d\n", fault_log);
+ return fault_log;
+ }
+
+ if (fault_log) {
+ if (fault_log & DA9052_FAULTLOG_TWDERROR)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: TWD_ERROR\n");
+ if (fault_log & DA9052_FAULTLOG_VDDFAULT)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: VDD_FAULT\n");
+ if (fault_log & DA9052_FAULTLOG_VDDSTART)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: VDD_START\n");
+ if (fault_log & DA9052_FAULTLOG_TEMPOVER)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: TEMP_OVER\n");
+ if (fault_log & DA9052_FAULTLOG_KEYSHUT)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: KEY_SHUT\n");
+ if (fault_log & DA9052_FAULTLOG_NSDSET)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: nSD_SHUT\n");
+ if (fault_log & DA9052_FAULTLOG_WAITSET)
+ dev_dbg(da9052->dev,
+ "Fault log entry detected: WAIT_SHUT\n");
+
+ ret = da9052_reg_write(da9052,
+ DA9052_FAULTLOG_REG,
+ 0xFF);
+ if (ret < 0)
+ dev_err(da9052->dev,
+ "Cannot reset FAULT_LOG values %d\n", ret);
+ }
+
+ return ret;
+}
+
int da9052_device_init(struct da9052 *da9052, u8 chip_id)
{
struct da9052_pdata *pdata = dev_get_platdata(da9052->dev);
@@ -549,6 +596,10 @@ int da9052_device_init(struct da9052 *da9052, u8 chip_id)
mutex_init(&da9052->auxadc_lock);
init_completion(&da9052->done);
+ ret = da9052_clear_fault_log(da9052);
+ if (ret < 0)
+ dev_warn(da9052->dev, "Cannot clear FAULT_LOG\n");
+
if (pdata && pdata->init != NULL)
pdata->init(da9052);