aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAshish Jangam <ashish.jangam@kpitcummins.com>2013-01-25 03:33:49 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-01-26 19:35:32 -0500
commit0a8c290ac58a86d5e1f2193abcd4d74ec075e20c (patch)
tree02c785e04f7d7aecf6166f92e240302c725a3e86 /include
parentab4e8f8b7bdfeff0c961fdbbdacb262d68f094c0 (diff)
mfd: da9052/53 lockup fix
An issue has been reported where the 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 to 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. Signed-off-by: Ashish Jangam <ashish.jangam@kpitcummins.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mfd/da9052/da9052.h66
-rw-r--r--include/linux/mfd/da9052/reg.h3
2 files changed, 65 insertions, 4 deletions
diff --git a/include/linux/mfd/da9052/da9052.h b/include/linux/mfd/da9052/da9052.h
index 86dd93de6ff2..786d02eb79d2 100644
--- a/include/linux/mfd/da9052/da9052.h
+++ b/include/linux/mfd/da9052/da9052.h
@@ -99,6 +99,9 @@ struct da9052 {
99 u8 chip_id; 99 u8 chip_id;
100 100
101 int chip_irq; 101 int chip_irq;
102
103 /* SOC I/O transfer related fixes for DA9052/53 */
104 int (*fix_io) (struct da9052 *da9052, unsigned char reg);
102}; 105};
103 106
104/* ADC API */ 107/* ADC API */
@@ -113,32 +116,87 @@ static inline int da9052_reg_read(struct da9052 *da9052, unsigned char reg)
113 ret = regmap_read(da9052->regmap, reg, &val); 116 ret = regmap_read(da9052->regmap, reg, &val);
114 if (ret < 0) 117 if (ret < 0)
115 return ret; 118 return ret;
119
120 if (da9052->fix_io) {
121 ret = da9052->fix_io(da9052, reg);
122 if (ret < 0)
123 return ret;
124 }
125
116 return val; 126 return val;
117} 127}
118 128
119static inline int da9052_reg_write(struct da9052 *da9052, unsigned char reg, 129static inline int da9052_reg_write(struct da9052 *da9052, unsigned char reg,
120 unsigned char val) 130 unsigned char val)
121{ 131{
122 return regmap_write(da9052->regmap, reg, val); 132 int ret;
133
134 ret = regmap_write(da9052->regmap, reg, val);
135 if (ret < 0)
136 return ret;
137
138 if (da9052->fix_io) {
139 ret = da9052->fix_io(da9052, reg);
140 if (ret < 0)
141 return ret;
142 }
143
144 return ret;
123} 145}
124 146
125static inline int da9052_group_read(struct da9052 *da9052, unsigned char reg, 147static inline int da9052_group_read(struct da9052 *da9052, unsigned char reg,
126 unsigned reg_cnt, unsigned char *val) 148 unsigned reg_cnt, unsigned char *val)
127{ 149{
128 return regmap_bulk_read(da9052->regmap, reg, val, reg_cnt); 150 int ret;
151
152 ret = regmap_bulk_read(da9052->regmap, reg, val, reg_cnt);
153 if (ret < 0)
154 return ret;
155
156 if (da9052->fix_io) {
157 ret = da9052->fix_io(da9052, reg);
158 if (ret < 0)
159 return ret;
160 }
161
162 return ret;
129} 163}
130 164
131static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg, 165static inline int da9052_group_write(struct da9052 *da9052, unsigned char reg,
132 unsigned reg_cnt, unsigned char *val) 166 unsigned reg_cnt, unsigned char *val)
133{ 167{
134 return regmap_raw_write(da9052->regmap, reg, val, reg_cnt); 168 int ret;
169
170 ret = regmap_raw_write(da9052->regmap, reg, val, reg_cnt);
171 if (ret < 0)
172 return ret;
173
174 if (da9052->fix_io) {
175 ret = da9052->fix_io(da9052, reg);
176 if (ret < 0)
177 return ret;
178 }
179
180 return ret;
135} 181}
136 182
137static inline int da9052_reg_update(struct da9052 *da9052, unsigned char reg, 183static inline int da9052_reg_update(struct da9052 *da9052, unsigned char reg,
138 unsigned char bit_mask, 184 unsigned char bit_mask,
139 unsigned char reg_val) 185 unsigned char reg_val)
140{ 186{
141 return regmap_update_bits(da9052->regmap, reg, bit_mask, reg_val); 187 int ret;
188
189 ret = regmap_update_bits(da9052->regmap, reg, bit_mask, reg_val);
190 if (ret < 0)
191 return ret;
192
193 if (da9052->fix_io) {
194 ret = da9052->fix_io(da9052, reg);
195 if (ret < 0)
196 return ret;
197 }
198
199 return ret;
142} 200}
143 201
144int da9052_device_init(struct da9052 *da9052, u8 chip_id); 202int da9052_device_init(struct da9052 *da9052, u8 chip_id);
diff --git a/include/linux/mfd/da9052/reg.h b/include/linux/mfd/da9052/reg.h
index b97f7309d7f6..c4dd3a8add21 100644
--- a/include/linux/mfd/da9052/reg.h
+++ b/include/linux/mfd/da9052/reg.h
@@ -34,6 +34,9 @@
34#define DA9052_STATUS_C_REG 3 34#define DA9052_STATUS_C_REG 3
35#define DA9052_STATUS_D_REG 4 35#define DA9052_STATUS_D_REG 4
36 36
37/* PARK REGISTER */
38#define DA9052_PARK_REGISTER DA9052_STATUS_D_REG
39
37/* EVENT REGISTERS */ 40/* EVENT REGISTERS */
38#define DA9052_EVENT_A_REG 5 41#define DA9052_EVENT_A_REG 5
39#define DA9052_EVENT_B_REG 6 42#define DA9052_EVENT_B_REG 6