mfd: fix for i2c issue DA9052/53 PMIC
Subsystems (2)
PATCH 1/1 mfd: fix for i2c issue DA9052/53 PMIC
There is an issue where the DA9052/53-AA/BA/BB PMIC either locks up or fails to respond following a system Reset. This could result in a second write in which the bus writes the current content of the write buffer to address of the last I2C access.
The failure case is where this unwanted write transfers incorrect data to a critical register.
This patch fixes this issue by following any read or write with a dummy read to a safe register address. A safe register address is one where the contents will not affect the operation of the system.
--- drivers/mfd/da9052-i2c.c | 56 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/da9052/da9052.h | 47 ++++++++++++++++++++++++++++-- include/linux/mfd/da9052/reg.h | 3 ++ 3 files changed, 102 insertions(+), 4 deletions(-)
drivers/mfd/da9052-i2c.c +56 -0
@@ -27,6 +27,62 @@#include <linux/of_device.h> #endif +/* safe register to park I2C operation */ +static inline bool is_i2c_safe_reg (unsigned char reg) +{ +switch (reg) { +case DA9052_STATUS_A_REG : +case DA9052_STATUS_B_REG : +case DA9052_STATUS_C_REG : +case DA9052_STATUS_D_REG : +case DA9052_ADC_RES_L_REG : +case DA9052_ADC_RES_H_REG : +case DA9052_VDD_RES_REG : +case DA9052_ICHG_AV_REG : +case DA9052_TBAT_RES_REG : +case DA9052_ADCIN4_RES_REG : +case DA9052_ADCIN5_RES_REG : +case DA9052_ADCIN6_RES_REG : +case DA9052_TJUNC_RES_REG : +case DA9052_TSI_X_MSB_REG : +case DA9052_TSI_Y_MSB_REG : +case DA9052_TSI_LSB_REG : +case DA9052_TSI_Z_MSB_REG : +return true; +default : +return false; + } +} + +/* +* There is an issue with DA9052 and DA9053_AA/BA/BB PMIC where the PMIC +* gets lockup up or fails to respond following a system reset. +* This fix is to follow any read or write with a dummy read to a safe +* register. +*/ +int da9052_i2c_fix (struct da9052 *da9052,unsigned char reg) +{ +int val; + +switch (da9052->chip_id) { +case DA9052 : +case DA9053_AA : +case DA9053_BA : +case DA9053_BB : +/* A dummy read to a safe register address. */ +if (!is_i2c_safe_reg (reg)) +return regmap_read (da9052->regmap,DA9052_PARK_REGISTER , + &val); +break ; +default : +/* Do nothing */ +break ; + } + +return 0 ; +} +EXPORT_SYMBOL (da9052_i2c_fix); +static int da9052_i2c_enable_multiwrite (struct da9052 *da9052) {int reg_val, ret;
include/linux/mfd/da9052/da9052.h +43 -4
81 lines not on this page · raw message
include/linux/mfd/da9052/reg.h +3 -0
@@ -34,6 +34,9 @@#define DA9052_STATUS_C_REG 3#define DA9052_STATUS_D_REG 4 +/* PARK REGISTER */ +#define DA9052_PARK_REGISTER DA9052_STATUS_D_REG +/* EVENT REGISTERS */ #define DA9052_EVENT_A_REG 5#define DA9052_EVENT_B_REG 6
Signature · 1 line
1.7.0.4
Samuel Ortiz
AppliedHi Ashish,
Quoted 12 lines · Ashish Jangam
There is an issue where the DA9052/53-AA/BA/BB PMIC either locks up or fails to respond following a system Reset. This could result in a second write in which the bus writes the current content of the write buffer to address of the last I2C access.
The failure case is where this unwanted write transfers incorrect data to a critical register.
This patch fixes this issue by following any read or write with a dummy read to a safe register address. A safe register address is one where the contents will not affect the operation of the system.
Quoted 7 lines
Signed-off-by David Dajun Chen <[email protected]>Signed-off-by Ashish Jangam <[email protected]>--- drivers/mfd/da9052-i2c.c | 56 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/da9052/da9052.h | 47 ++++++++++++++++++++++++++++-- include/linux/mfd/da9052/reg.h | 3 ++ 3 files changed, 102 insertions(+), 4 deletions(-)
Applied to my for-linus branch.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/