Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Steve Twiss and committed by
Lee Jones
547120ed 29090265

+51
+51
drivers/mfd/da9052-core.c
··· 167 167 case DA9052_EVENT_B_REG: 168 168 case DA9052_EVENT_C_REG: 169 169 case DA9052_EVENT_D_REG: 170 + case DA9052_FAULTLOG_REG: 170 171 case DA9052_IRQ_MASK_A_REG: 171 172 case DA9052_IRQ_MASK_B_REG: 172 173 case DA9052_IRQ_MASK_C_REG: ··· 542 541 }; 543 542 EXPORT_SYMBOL_GPL(da9052_regmap_config); 544 543 544 + static int da9052_clear_fault_log(struct da9052 *da9052) 545 + { 546 + int ret = 0; 547 + int fault_log = 0; 548 + 549 + fault_log = da9052_reg_read(da9052, DA9052_FAULTLOG_REG); 550 + if (fault_log < 0) { 551 + dev_err(da9052->dev, 552 + "Cannot read FAULT_LOG %d\n", fault_log); 553 + return fault_log; 554 + } 555 + 556 + if (fault_log) { 557 + if (fault_log & DA9052_FAULTLOG_TWDERROR) 558 + dev_dbg(da9052->dev, 559 + "Fault log entry detected: TWD_ERROR\n"); 560 + if (fault_log & DA9052_FAULTLOG_VDDFAULT) 561 + dev_dbg(da9052->dev, 562 + "Fault log entry detected: VDD_FAULT\n"); 563 + if (fault_log & DA9052_FAULTLOG_VDDSTART) 564 + dev_dbg(da9052->dev, 565 + "Fault log entry detected: VDD_START\n"); 566 + if (fault_log & DA9052_FAULTLOG_TEMPOVER) 567 + dev_dbg(da9052->dev, 568 + "Fault log entry detected: TEMP_OVER\n"); 569 + if (fault_log & DA9052_FAULTLOG_KEYSHUT) 570 + dev_dbg(da9052->dev, 571 + "Fault log entry detected: KEY_SHUT\n"); 572 + if (fault_log & DA9052_FAULTLOG_NSDSET) 573 + dev_dbg(da9052->dev, 574 + "Fault log entry detected: nSD_SHUT\n"); 575 + if (fault_log & DA9052_FAULTLOG_WAITSET) 576 + dev_dbg(da9052->dev, 577 + "Fault log entry detected: WAIT_SHUT\n"); 578 + 579 + ret = da9052_reg_write(da9052, 580 + DA9052_FAULTLOG_REG, 581 + 0xFF); 582 + if (ret < 0) 583 + dev_err(da9052->dev, 584 + "Cannot reset FAULT_LOG values %d\n", ret); 585 + } 586 + 587 + return ret; 588 + } 589 + 545 590 int da9052_device_init(struct da9052 *da9052, u8 chip_id) 546 591 { 547 592 struct da9052_pdata *pdata = dev_get_platdata(da9052->dev); ··· 595 548 596 549 mutex_init(&da9052->auxadc_lock); 597 550 init_completion(&da9052->done); 551 + 552 + ret = da9052_clear_fault_log(da9052); 553 + if (ret < 0) 554 + dev_warn(da9052->dev, "Cannot clear FAULT_LOG\n"); 598 555 599 556 if (pdata && pdata->init != NULL) 600 557 pdata->init(da9052);