diff options
author | Anton Vorontsov <anton@enomsg.org> | 2013-01-05 20:14:22 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-01-05 20:14:22 -0500 |
commit | 240fbe2347f1bb58c45fe07fd7c1e5ed96e2e983 (patch) | |
tree | 8481027b056197db888e51eae47a8f95931b84cb /drivers | |
parent | 2fbb520d2079186727786b728ebc5bf20fc85520 (diff) | |
parent | 215cf5c93d2deda4df38d0c9b2429ab2e86808a5 (diff) |
Merge branch 'for-anton' of git://git.linaro.org/people/ljones/linux-3.0-ux500
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/ab8500-core.c | 8 | ||||
-rw-r--r-- | drivers/power/Makefile | 2 | ||||
-rw-r--r-- | drivers/power/ab8500_bmdata.c | 523 | ||||
-rw-r--r-- | drivers/power/ab8500_btemp.c | 96 | ||||
-rw-r--r-- | drivers/power/ab8500_charger.c | 222 | ||||
-rw-r--r-- | drivers/power/ab8500_fg.c | 123 | ||||
-rw-r--r-- | drivers/power/abx500_chargalg.c | 133 |
7 files changed, 591 insertions, 516 deletions
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index e1650badd106..30b92652fce9 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
@@ -1011,40 +1011,32 @@ static struct mfd_cell ab8500_bm_devs[] = { | |||
1011 | .of_compatible = "stericsson,ab8500-charger", | 1011 | .of_compatible = "stericsson,ab8500-charger", |
1012 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), | 1012 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), |
1013 | .resources = ab8500_charger_resources, | 1013 | .resources = ab8500_charger_resources, |
1014 | #ifndef CONFIG_OF | ||
1015 | .platform_data = &ab8500_bm_data, | 1014 | .platform_data = &ab8500_bm_data, |
1016 | .pdata_size = sizeof(ab8500_bm_data), | 1015 | .pdata_size = sizeof(ab8500_bm_data), |
1017 | #endif | ||
1018 | }, | 1016 | }, |
1019 | { | 1017 | { |
1020 | .name = "ab8500-btemp", | 1018 | .name = "ab8500-btemp", |
1021 | .of_compatible = "stericsson,ab8500-btemp", | 1019 | .of_compatible = "stericsson,ab8500-btemp", |
1022 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), | 1020 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), |
1023 | .resources = ab8500_btemp_resources, | 1021 | .resources = ab8500_btemp_resources, |
1024 | #ifndef CONFIG_OF | ||
1025 | .platform_data = &ab8500_bm_data, | 1022 | .platform_data = &ab8500_bm_data, |
1026 | .pdata_size = sizeof(ab8500_bm_data), | 1023 | .pdata_size = sizeof(ab8500_bm_data), |
1027 | #endif | ||
1028 | }, | 1024 | }, |
1029 | { | 1025 | { |
1030 | .name = "ab8500-fg", | 1026 | .name = "ab8500-fg", |
1031 | .of_compatible = "stericsson,ab8500-fg", | 1027 | .of_compatible = "stericsson,ab8500-fg", |
1032 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), | 1028 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), |
1033 | .resources = ab8500_fg_resources, | 1029 | .resources = ab8500_fg_resources, |
1034 | #ifndef CONFIG_OF | ||
1035 | .platform_data = &ab8500_bm_data, | 1030 | .platform_data = &ab8500_bm_data, |
1036 | .pdata_size = sizeof(ab8500_bm_data), | 1031 | .pdata_size = sizeof(ab8500_bm_data), |
1037 | #endif | ||
1038 | }, | 1032 | }, |
1039 | { | 1033 | { |
1040 | .name = "ab8500-chargalg", | 1034 | .name = "ab8500-chargalg", |
1041 | .of_compatible = "stericsson,ab8500-chargalg", | 1035 | .of_compatible = "stericsson,ab8500-chargalg", |
1042 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), | 1036 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), |
1043 | .resources = ab8500_chargalg_resources, | 1037 | .resources = ab8500_chargalg_resources, |
1044 | #ifndef CONFIG_OF | ||
1045 | .platform_data = &ab8500_bm_data, | 1038 | .platform_data = &ab8500_bm_data, |
1046 | .pdata_size = sizeof(ab8500_bm_data), | 1039 | .pdata_size = sizeof(ab8500_bm_data), |
1047 | #endif | ||
1048 | }, | 1040 | }, |
1049 | }; | 1041 | }; |
1050 | 1042 | ||
diff --git a/drivers/power/Makefile b/drivers/power/Makefile index 22c8913382c0..b11e0c7ea0f1 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile | |||
@@ -38,7 +38,7 @@ obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o | |||
38 | obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o | 38 | obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o |
39 | obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o | 39 | obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o |
40 | obj-$(CONFIG_BATTERY_RX51) += rx51_battery.o | 40 | obj-$(CONFIG_BATTERY_RX51) += rx51_battery.o |
41 | obj-$(CONFIG_AB8500_BM) += ab8500_bmdata.o ab8500_charger.o ab8500_btemp.o ab8500_fg.o abx500_chargalg.o | 41 | obj-$(CONFIG_AB8500_BM) += ab8500_bmdata.o ab8500_charger.o ab8500_fg.o ab8500_btemp.o abx500_chargalg.o |
42 | obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o | 42 | obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o |
43 | obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o | 43 | obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o |
44 | obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o | 44 | obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o |
diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index 03cc528425cb..0bf52369d6a5 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c | |||
@@ -182,206 +182,206 @@ static struct batres_vs_temp temp_to_batres_tbl_9100[] = { | |||
182 | }; | 182 | }; |
183 | 183 | ||
184 | static struct abx500_battery_type bat_type_thermistor[] = { | 184 | static struct abx500_battery_type bat_type_thermistor[] = { |
185 | [BATTERY_UNKNOWN] = { | 185 | [BATTERY_UNKNOWN] = { |
186 | /* First element always represent the UNKNOWN battery */ | 186 | /* First element always represent the UNKNOWN battery */ |
187 | .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, | 187 | .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, |
188 | .resis_high = 0, | 188 | .resis_high = 0, |
189 | .resis_low = 0, | 189 | .resis_low = 0, |
190 | .battery_resistance = 300, | 190 | .battery_resistance = 300, |
191 | .charge_full_design = 612, | 191 | .charge_full_design = 612, |
192 | .nominal_voltage = 3700, | 192 | .nominal_voltage = 3700, |
193 | .termination_vol = 4050, | 193 | .termination_vol = 4050, |
194 | .termination_curr = 200, | 194 | .termination_curr = 200, |
195 | .recharge_vol = 3990, | 195 | .recharge_vol = 3990, |
196 | .normal_cur_lvl = 400, | 196 | .normal_cur_lvl = 400, |
197 | .normal_vol_lvl = 4100, | 197 | .normal_vol_lvl = 4100, |
198 | .maint_a_cur_lvl = 400, | 198 | .maint_a_cur_lvl = 400, |
199 | .maint_a_vol_lvl = 4050, | 199 | .maint_a_vol_lvl = 4050, |
200 | .maint_a_chg_timer_h = 60, | 200 | .maint_a_chg_timer_h = 60, |
201 | .maint_b_cur_lvl = 400, | 201 | .maint_b_cur_lvl = 400, |
202 | .maint_b_vol_lvl = 4000, | 202 | .maint_b_vol_lvl = 4000, |
203 | .maint_b_chg_timer_h = 200, | 203 | .maint_b_chg_timer_h = 200, |
204 | .low_high_cur_lvl = 300, | 204 | .low_high_cur_lvl = 300, |
205 | .low_high_vol_lvl = 4000, | 205 | .low_high_vol_lvl = 4000, |
206 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), | 206 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), |
207 | .r_to_t_tbl = temp_tbl, | 207 | .r_to_t_tbl = temp_tbl, |
208 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), | 208 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), |
209 | .v_to_cap_tbl = cap_tbl, | 209 | .v_to_cap_tbl = cap_tbl, |
210 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 210 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
211 | .batres_tbl = temp_to_batres_tbl_thermistor, | 211 | .batres_tbl = temp_to_batres_tbl_thermistor, |
212 | }, | 212 | }, |
213 | { | 213 | { |
214 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, | 214 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, |
215 | .resis_high = 53407, | 215 | .resis_high = 53407, |
216 | .resis_low = 12500, | 216 | .resis_low = 12500, |
217 | .battery_resistance = 300, | 217 | .battery_resistance = 300, |
218 | .charge_full_design = 900, | 218 | .charge_full_design = 900, |
219 | .nominal_voltage = 3600, | 219 | .nominal_voltage = 3600, |
220 | .termination_vol = 4150, | 220 | .termination_vol = 4150, |
221 | .termination_curr = 80, | 221 | .termination_curr = 80, |
222 | .recharge_vol = 4130, | 222 | .recharge_vol = 4130, |
223 | .normal_cur_lvl = 700, | 223 | .normal_cur_lvl = 700, |
224 | .normal_vol_lvl = 4200, | 224 | .normal_vol_lvl = 4200, |
225 | .maint_a_cur_lvl = 600, | 225 | .maint_a_cur_lvl = 600, |
226 | .maint_a_vol_lvl = 4150, | 226 | .maint_a_vol_lvl = 4150, |
227 | .maint_a_chg_timer_h = 60, | 227 | .maint_a_chg_timer_h = 60, |
228 | .maint_b_cur_lvl = 600, | 228 | .maint_b_cur_lvl = 600, |
229 | .maint_b_vol_lvl = 4100, | 229 | .maint_b_vol_lvl = 4100, |
230 | .maint_b_chg_timer_h = 200, | 230 | .maint_b_chg_timer_h = 200, |
231 | .low_high_cur_lvl = 300, | 231 | .low_high_cur_lvl = 300, |
232 | .low_high_vol_lvl = 4000, | 232 | .low_high_vol_lvl = 4000, |
233 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_A_thermistor), | 233 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_A_thermistor), |
234 | .r_to_t_tbl = temp_tbl_A_thermistor, | 234 | .r_to_t_tbl = temp_tbl_A_thermistor, |
235 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_A_thermistor), | 235 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_A_thermistor), |
236 | .v_to_cap_tbl = cap_tbl_A_thermistor, | 236 | .v_to_cap_tbl = cap_tbl_A_thermistor, |
237 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 237 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
238 | .batres_tbl = temp_to_batres_tbl_thermistor, | 238 | .batres_tbl = temp_to_batres_tbl_thermistor, |
239 | 239 | ||
240 | }, | 240 | }, |
241 | { | 241 | { |
242 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, | 242 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, |
243 | .resis_high = 200000, | 243 | .resis_high = 200000, |
244 | .resis_low = 82869, | 244 | .resis_low = 82869, |
245 | .battery_resistance = 300, | 245 | .battery_resistance = 300, |
246 | .charge_full_design = 900, | 246 | .charge_full_design = 900, |
247 | .nominal_voltage = 3600, | 247 | .nominal_voltage = 3600, |
248 | .termination_vol = 4150, | 248 | .termination_vol = 4150, |
249 | .termination_curr = 80, | 249 | .termination_curr = 80, |
250 | .recharge_vol = 4130, | 250 | .recharge_vol = 4130, |
251 | .normal_cur_lvl = 700, | 251 | .normal_cur_lvl = 700, |
252 | .normal_vol_lvl = 4200, | 252 | .normal_vol_lvl = 4200, |
253 | .maint_a_cur_lvl = 600, | 253 | .maint_a_cur_lvl = 600, |
254 | .maint_a_vol_lvl = 4150, | 254 | .maint_a_vol_lvl = 4150, |
255 | .maint_a_chg_timer_h = 60, | 255 | .maint_a_chg_timer_h = 60, |
256 | .maint_b_cur_lvl = 600, | 256 | .maint_b_cur_lvl = 600, |
257 | .maint_b_vol_lvl = 4100, | 257 | .maint_b_vol_lvl = 4100, |
258 | .maint_b_chg_timer_h = 200, | 258 | .maint_b_chg_timer_h = 200, |
259 | .low_high_cur_lvl = 300, | 259 | .low_high_cur_lvl = 300, |
260 | .low_high_vol_lvl = 4000, | 260 | .low_high_vol_lvl = 4000, |
261 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_B_thermistor), | 261 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_B_thermistor), |
262 | .r_to_t_tbl = temp_tbl_B_thermistor, | 262 | .r_to_t_tbl = temp_tbl_B_thermistor, |
263 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_B_thermistor), | 263 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_B_thermistor), |
264 | .v_to_cap_tbl = cap_tbl_B_thermistor, | 264 | .v_to_cap_tbl = cap_tbl_B_thermistor, |
265 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 265 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
266 | .batres_tbl = temp_to_batres_tbl_thermistor, | 266 | .batres_tbl = temp_to_batres_tbl_thermistor, |
267 | }, | 267 | }, |
268 | }; | 268 | }; |
269 | 269 | ||
270 | static struct abx500_battery_type bat_type_ext_thermistor[] = { | 270 | static struct abx500_battery_type bat_type_ext_thermistor[] = { |
271 | [BATTERY_UNKNOWN] = { | 271 | [BATTERY_UNKNOWN] = { |
272 | /* First element always represent the UNKNOWN battery */ | 272 | /* First element always represent the UNKNOWN battery */ |
273 | .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, | 273 | .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, |
274 | .resis_high = 0, | 274 | .resis_high = 0, |
275 | .resis_low = 0, | 275 | .resis_low = 0, |
276 | .battery_resistance = 300, | 276 | .battery_resistance = 300, |
277 | .charge_full_design = 612, | 277 | .charge_full_design = 612, |
278 | .nominal_voltage = 3700, | 278 | .nominal_voltage = 3700, |
279 | .termination_vol = 4050, | 279 | .termination_vol = 4050, |
280 | .termination_curr = 200, | 280 | .termination_curr = 200, |
281 | .recharge_vol = 3990, | 281 | .recharge_vol = 3990, |
282 | .normal_cur_lvl = 400, | 282 | .normal_cur_lvl = 400, |
283 | .normal_vol_lvl = 4100, | 283 | .normal_vol_lvl = 4100, |
284 | .maint_a_cur_lvl = 400, | 284 | .maint_a_cur_lvl = 400, |
285 | .maint_a_vol_lvl = 4050, | 285 | .maint_a_vol_lvl = 4050, |
286 | .maint_a_chg_timer_h = 60, | 286 | .maint_a_chg_timer_h = 60, |
287 | .maint_b_cur_lvl = 400, | 287 | .maint_b_cur_lvl = 400, |
288 | .maint_b_vol_lvl = 4000, | 288 | .maint_b_vol_lvl = 4000, |
289 | .maint_b_chg_timer_h = 200, | 289 | .maint_b_chg_timer_h = 200, |
290 | .low_high_cur_lvl = 300, | 290 | .low_high_cur_lvl = 300, |
291 | .low_high_vol_lvl = 4000, | 291 | .low_high_vol_lvl = 4000, |
292 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), | 292 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), |
293 | .r_to_t_tbl = temp_tbl, | 293 | .r_to_t_tbl = temp_tbl, |
294 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), | 294 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), |
295 | .v_to_cap_tbl = cap_tbl, | 295 | .v_to_cap_tbl = cap_tbl, |
296 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 296 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
297 | .batres_tbl = temp_to_batres_tbl_thermistor, | 297 | .batres_tbl = temp_to_batres_tbl_thermistor, |
298 | }, | 298 | }, |
299 | /* | 299 | /* |
300 | * These are the batteries that doesn't have an internal NTC resistor to measure | 300 | * These are the batteries that doesn't have an internal NTC resistor to measure |
301 | * its temperature. The temperature in this case is measure with a NTC placed | 301 | * its temperature. The temperature in this case is measure with a NTC placed |
302 | * near the battery but on the PCB. | 302 | * near the battery but on the PCB. |
303 | */ | 303 | */ |
304 | { | 304 | { |
305 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, | 305 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, |
306 | .resis_high = 76000, | 306 | .resis_high = 76000, |
307 | .resis_low = 53000, | 307 | .resis_low = 53000, |
308 | .battery_resistance = 300, | 308 | .battery_resistance = 300, |
309 | .charge_full_design = 900, | 309 | .charge_full_design = 900, |
310 | .nominal_voltage = 3700, | 310 | .nominal_voltage = 3700, |
311 | .termination_vol = 4150, | 311 | .termination_vol = 4150, |
312 | .termination_curr = 100, | 312 | .termination_curr = 100, |
313 | .recharge_vol = 4130, | 313 | .recharge_vol = 4130, |
314 | .normal_cur_lvl = 700, | 314 | .normal_cur_lvl = 700, |
315 | .normal_vol_lvl = 4200, | 315 | .normal_vol_lvl = 4200, |
316 | .maint_a_cur_lvl = 600, | 316 | .maint_a_cur_lvl = 600, |
317 | .maint_a_vol_lvl = 4150, | 317 | .maint_a_vol_lvl = 4150, |
318 | .maint_a_chg_timer_h = 60, | 318 | .maint_a_chg_timer_h = 60, |
319 | .maint_b_cur_lvl = 600, | 319 | .maint_b_cur_lvl = 600, |
320 | .maint_b_vol_lvl = 4100, | 320 | .maint_b_vol_lvl = 4100, |
321 | .maint_b_chg_timer_h = 200, | 321 | .maint_b_chg_timer_h = 200, |
322 | .low_high_cur_lvl = 300, | 322 | .low_high_cur_lvl = 300, |
323 | .low_high_vol_lvl = 4000, | 323 | .low_high_vol_lvl = 4000, |
324 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), | 324 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), |
325 | .r_to_t_tbl = temp_tbl, | 325 | .r_to_t_tbl = temp_tbl, |
326 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), | 326 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), |
327 | .v_to_cap_tbl = cap_tbl, | 327 | .v_to_cap_tbl = cap_tbl, |
328 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 328 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
329 | .batres_tbl = temp_to_batres_tbl_thermistor, | 329 | .batres_tbl = temp_to_batres_tbl_thermistor, |
330 | }, | 330 | }, |
331 | { | 331 | { |
332 | .name = POWER_SUPPLY_TECHNOLOGY_LION, | 332 | .name = POWER_SUPPLY_TECHNOLOGY_LION, |
333 | .resis_high = 30000, | 333 | .resis_high = 30000, |
334 | .resis_low = 10000, | 334 | .resis_low = 10000, |
335 | .battery_resistance = 300, | 335 | .battery_resistance = 300, |
336 | .charge_full_design = 950, | 336 | .charge_full_design = 950, |
337 | .nominal_voltage = 3700, | 337 | .nominal_voltage = 3700, |
338 | .termination_vol = 4150, | 338 | .termination_vol = 4150, |
339 | .termination_curr = 100, | 339 | .termination_curr = 100, |
340 | .recharge_vol = 4130, | 340 | .recharge_vol = 4130, |
341 | .normal_cur_lvl = 700, | 341 | .normal_cur_lvl = 700, |
342 | .normal_vol_lvl = 4200, | 342 | .normal_vol_lvl = 4200, |
343 | .maint_a_cur_lvl = 600, | 343 | .maint_a_cur_lvl = 600, |
344 | .maint_a_vol_lvl = 4150, | 344 | .maint_a_vol_lvl = 4150, |
345 | .maint_a_chg_timer_h = 60, | 345 | .maint_a_chg_timer_h = 60, |
346 | .maint_b_cur_lvl = 600, | 346 | .maint_b_cur_lvl = 600, |
347 | .maint_b_vol_lvl = 4100, | 347 | .maint_b_vol_lvl = 4100, |
348 | .maint_b_chg_timer_h = 200, | 348 | .maint_b_chg_timer_h = 200, |
349 | .low_high_cur_lvl = 300, | 349 | .low_high_cur_lvl = 300, |
350 | .low_high_vol_lvl = 4000, | 350 | .low_high_vol_lvl = 4000, |
351 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), | 351 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), |
352 | .r_to_t_tbl = temp_tbl, | 352 | .r_to_t_tbl = temp_tbl, |
353 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), | 353 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), |
354 | .v_to_cap_tbl = cap_tbl, | 354 | .v_to_cap_tbl = cap_tbl, |
355 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 355 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
356 | .batres_tbl = temp_to_batres_tbl_thermistor, | 356 | .batres_tbl = temp_to_batres_tbl_thermistor, |
357 | }, | 357 | }, |
358 | { | 358 | { |
359 | .name = POWER_SUPPLY_TECHNOLOGY_LION, | 359 | .name = POWER_SUPPLY_TECHNOLOGY_LION, |
360 | .resis_high = 95000, | 360 | .resis_high = 95000, |
361 | .resis_low = 76001, | 361 | .resis_low = 76001, |
362 | .battery_resistance = 300, | 362 | .battery_resistance = 300, |
363 | .charge_full_design = 950, | 363 | .charge_full_design = 950, |
364 | .nominal_voltage = 3700, | 364 | .nominal_voltage = 3700, |
365 | .termination_vol = 4150, | 365 | .termination_vol = 4150, |
366 | .termination_curr = 100, | 366 | .termination_curr = 100, |
367 | .recharge_vol = 4130, | 367 | .recharge_vol = 4130, |
368 | .normal_cur_lvl = 700, | 368 | .normal_cur_lvl = 700, |
369 | .normal_vol_lvl = 4200, | 369 | .normal_vol_lvl = 4200, |
370 | .maint_a_cur_lvl = 600, | 370 | .maint_a_cur_lvl = 600, |
371 | .maint_a_vol_lvl = 4150, | 371 | .maint_a_vol_lvl = 4150, |
372 | .maint_a_chg_timer_h = 60, | 372 | .maint_a_chg_timer_h = 60, |
373 | .maint_b_cur_lvl = 600, | 373 | .maint_b_cur_lvl = 600, |
374 | .maint_b_vol_lvl = 4100, | 374 | .maint_b_vol_lvl = 4100, |
375 | .maint_b_chg_timer_h = 200, | 375 | .maint_b_chg_timer_h = 200, |
376 | .low_high_cur_lvl = 300, | 376 | .low_high_cur_lvl = 300, |
377 | .low_high_vol_lvl = 4000, | 377 | .low_high_vol_lvl = 4000, |
378 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), | 378 | .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), |
379 | .r_to_t_tbl = temp_tbl, | 379 | .r_to_t_tbl = temp_tbl, |
380 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), | 380 | .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), |
381 | .v_to_cap_tbl = cap_tbl, | 381 | .v_to_cap_tbl = cap_tbl, |
382 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), | 382 | .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), |
383 | .batres_tbl = temp_to_batres_tbl_thermistor, | 383 | .batres_tbl = temp_to_batres_tbl_thermistor, |
384 | }, | 384 | }, |
385 | }; | 385 | }; |
386 | 386 | ||
387 | static const struct abx500_bm_capacity_levels cap_levels = { | 387 | static const struct abx500_bm_capacity_levels cap_levels = { |
@@ -424,98 +424,83 @@ static const struct abx500_bm_charger_parameters chg = { | |||
424 | }; | 424 | }; |
425 | 425 | ||
426 | struct abx500_bm_data ab8500_bm_data = { | 426 | struct abx500_bm_data ab8500_bm_data = { |
427 | .temp_under = 3, | 427 | .temp_under = 3, |
428 | .temp_low = 8, | 428 | .temp_low = 8, |
429 | .temp_high = 43, | 429 | .temp_high = 43, |
430 | .temp_over = 48, | 430 | .temp_over = 48, |
431 | .main_safety_tmr_h = 4, | 431 | .main_safety_tmr_h = 4, |
432 | .temp_interval_chg = 20, | 432 | .temp_interval_chg = 20, |
433 | .temp_interval_nochg = 120, | 433 | .temp_interval_nochg = 120, |
434 | .usb_safety_tmr_h = 4, | 434 | .usb_safety_tmr_h = 4, |
435 | .bkup_bat_v = BUP_VCH_SEL_2P6V, | 435 | .bkup_bat_v = BUP_VCH_SEL_2P6V, |
436 | .bkup_bat_i = BUP_ICH_SEL_150UA, | 436 | .bkup_bat_i = BUP_ICH_SEL_150UA, |
437 | .no_maintenance = false, | 437 | .no_maintenance = false, |
438 | .adc_therm = ABx500_ADC_THERM_BATCTRL, | 438 | .adc_therm = ABx500_ADC_THERM_BATCTRL, |
439 | .chg_unknown_bat = false, | 439 | .chg_unknown_bat = false, |
440 | .enable_overshoot = false, | 440 | .enable_overshoot = false, |
441 | .fg_res = 100, | 441 | .fg_res = 100, |
442 | .cap_levels = &cap_levels, | 442 | .cap_levels = &cap_levels, |
443 | .bat_type = bat_type_thermistor, | 443 | .bat_type = bat_type_thermistor, |
444 | .n_btypes = 3, | 444 | .n_btypes = 3, |
445 | .batt_id = 0, | 445 | .batt_id = 0, |
446 | .interval_charging = 5, | 446 | .interval_charging = 5, |
447 | .interval_not_charging = 120, | 447 | .interval_not_charging = 120, |
448 | .temp_hysteresis = 3, | 448 | .temp_hysteresis = 3, |
449 | .gnd_lift_resistance = 34, | 449 | .gnd_lift_resistance = 34, |
450 | .maxi = &maxi_params, | 450 | .maxi = &maxi_params, |
451 | .chg_params = &chg, | 451 | .chg_params = &chg, |
452 | .fg_params = &fg, | 452 | .fg_params = &fg, |
453 | }; | 453 | }; |
454 | 454 | ||
455 | int __devinit | 455 | int __devinit ab8500_bm_of_probe(struct device *dev, |
456 | bmdevs_of_probe(struct device *dev, | 456 | struct device_node *np, |
457 | struct device_node *np, | 457 | struct abx500_bm_data *bm) |
458 | struct abx500_bm_data **battery) | ||
459 | { | 458 | { |
460 | struct abx500_battery_type *btype; | 459 | struct batres_vs_temp *tmp_batres_tbl; |
461 | struct device_node *np_bat_supply; | 460 | struct device_node *battery_node; |
462 | struct abx500_bm_data *bat; | ||
463 | const char *btech; | 461 | const char *btech; |
464 | char bat_tech[8]; | 462 | int i; |
465 | int i, thermistor; | ||
466 | |||
467 | *battery = &ab8500_bm_data; | ||
468 | 463 | ||
469 | /* get phandle to 'battery-info' node */ | 464 | /* get phandle to 'battery-info' node */ |
470 | np_bat_supply = of_parse_phandle(np, "battery", 0); | 465 | battery_node = of_parse_phandle(np, "battery", 0); |
471 | if (!np_bat_supply) { | 466 | if (!battery_node) { |
472 | dev_err(dev, "missing property battery\n"); | 467 | dev_err(dev, "battery node or reference missing\n"); |
473 | return -EINVAL; | 468 | return -EINVAL; |
474 | } | 469 | } |
475 | if (of_property_read_bool(np_bat_supply, | ||
476 | "thermistor-on-batctrl")) | ||
477 | thermistor = NTC_INTERNAL; | ||
478 | else | ||
479 | thermistor = NTC_EXTERNAL; | ||
480 | 470 | ||
481 | bat = *battery; | 471 | btech = of_get_property(battery_node, "stericsson,battery-type", NULL); |
482 | if (thermistor == NTC_EXTERNAL) { | ||
483 | bat->n_btypes = 4; | ||
484 | bat->bat_type = bat_type_ext_thermistor; | ||
485 | bat->adc_therm = ABx500_ADC_THERM_BATTEMP; | ||
486 | } | ||
487 | btech = of_get_property(np_bat_supply, | ||
488 | "stericsson,battery-type", NULL); | ||
489 | if (!btech) { | 472 | if (!btech) { |
490 | dev_warn(dev, "missing property battery-name/type\n"); | 473 | dev_warn(dev, "missing property battery-name/type\n"); |
491 | strcpy(bat_tech, "UNKNOWN"); | 474 | return -EINVAL; |
492 | } else { | ||
493 | strcpy(bat_tech, btech); | ||
494 | } | 475 | } |
495 | 476 | ||
496 | if (strncmp(bat_tech, "LION", 4) == 0) { | 477 | if (strncmp(btech, "LION", 4) == 0) { |
497 | bat->no_maintenance = true; | 478 | bm->no_maintenance = true; |
498 | bat->chg_unknown_bat = true; | 479 | bm->chg_unknown_bat = true; |
499 | bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; | 480 | bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; |
500 | bat->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; | 481 | bm->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; |
501 | bat->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; | 482 | bm->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; |
502 | bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; | 483 | bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; |
503 | bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; | 484 | bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; |
504 | } | 485 | } |
505 | /* select the battery resolution table */ | 486 | |
506 | for (i = 0; i < bat->n_btypes; ++i) { | 487 | if (of_property_read_bool(battery_node, "thermistor-on-batctrl")) { |
507 | btype = (bat->bat_type + i); | 488 | if (strncmp(btech, "LION", 4) == 0) |
508 | if (thermistor == NTC_EXTERNAL) { | 489 | tmp_batres_tbl = temp_to_batres_tbl_9100; |
509 | btype->batres_tbl = | 490 | else |
510 | temp_to_batres_tbl_ext_thermistor; | 491 | tmp_batres_tbl = temp_to_batres_tbl_thermistor; |
511 | } else if (strncmp(bat_tech, "LION", 4) == 0) { | 492 | } else { |
512 | btype->batres_tbl = | 493 | bm->n_btypes = 4; |
513 | temp_to_batres_tbl_9100; | 494 | bm->bat_type = bat_type_ext_thermistor; |
514 | } else { | 495 | bm->adc_therm = ABx500_ADC_THERM_BATTEMP; |
515 | btype->batres_tbl = | 496 | tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor; |
516 | temp_to_batres_tbl_thermistor; | ||
517 | } | ||
518 | } | 497 | } |
519 | of_node_put(np_bat_supply); | 498 | |
499 | /* select the battery resolution table */ | ||
500 | for (i = 0; i < bm->n_btypes; ++i) | ||
501 | bm->bat_type[i].batres_tbl = tmp_batres_tbl; | ||
502 | |||
503 | of_node_put(battery_node); | ||
504 | |||
520 | return 0; | 505 | return 0; |
521 | } | 506 | } |
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 20e2a7d3ef43..e1d28039ce7b 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c | |||
@@ -78,12 +78,13 @@ struct ab8500_btemp_ranges { | |||
78 | * @parent: Pointer to the struct ab8500 | 78 | * @parent: Pointer to the struct ab8500 |
79 | * @gpadc: Pointer to the struct gpadc | 79 | * @gpadc: Pointer to the struct gpadc |
80 | * @fg: Pointer to the struct fg | 80 | * @fg: Pointer to the struct fg |
81 | * @bat: Pointer to the abx500_bm platform data | 81 | * @bm: Platform specific battery management information |
82 | * @btemp_psy: Structure for BTEMP specific battery properties | 82 | * @btemp_psy: Structure for BTEMP specific battery properties |
83 | * @events: Structure for information about events triggered | 83 | * @events: Structure for information about events triggered |
84 | * @btemp_ranges: Battery temperature range structure | 84 | * @btemp_ranges: Battery temperature range structure |
85 | * @btemp_wq: Work queue for measuring the temperature periodically | 85 | * @btemp_wq: Work queue for measuring the temperature periodically |
86 | * @btemp_periodic_work: Work for measuring the temperature periodically | 86 | * @btemp_periodic_work: Work for measuring the temperature periodically |
87 | * @initialized: True if battery id read. | ||
87 | */ | 88 | */ |
88 | struct ab8500_btemp { | 89 | struct ab8500_btemp { |
89 | struct device *dev; | 90 | struct device *dev; |
@@ -94,12 +95,13 @@ struct ab8500_btemp { | |||
94 | struct ab8500 *parent; | 95 | struct ab8500 *parent; |
95 | struct ab8500_gpadc *gpadc; | 96 | struct ab8500_gpadc *gpadc; |
96 | struct ab8500_fg *fg; | 97 | struct ab8500_fg *fg; |
97 | struct abx500_bm_data *bat; | 98 | struct abx500_bm_data *bm; |
98 | struct power_supply btemp_psy; | 99 | struct power_supply btemp_psy; |
99 | struct ab8500_btemp_events events; | 100 | struct ab8500_btemp_events events; |
100 | struct ab8500_btemp_ranges btemp_ranges; | 101 | struct ab8500_btemp_ranges btemp_ranges; |
101 | struct workqueue_struct *btemp_wq; | 102 | struct workqueue_struct *btemp_wq; |
102 | struct delayed_work btemp_periodic_work; | 103 | struct delayed_work btemp_periodic_work; |
104 | bool initialized; | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | /* BTEMP power supply properties */ | 107 | /* BTEMP power supply properties */ |
@@ -147,13 +149,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di, | |||
147 | return (450000 * (v_batctrl)) / (1800 - v_batctrl); | 149 | return (450000 * (v_batctrl)) / (1800 - v_batctrl); |
148 | } | 150 | } |
149 | 151 | ||
150 | if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL) { | 152 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL) { |
151 | /* | 153 | /* |
152 | * If the battery has internal NTC, we use the current | 154 | * If the battery has internal NTC, we use the current |
153 | * source to calculate the resistance, 7uA or 20uA | 155 | * source to calculate the resistance, 7uA or 20uA |
154 | */ | 156 | */ |
155 | rbs = (v_batctrl * 1000 | 157 | rbs = (v_batctrl * 1000 |
156 | - di->bat->gnd_lift_resistance * inst_curr) | 158 | - di->bm->gnd_lift_resistance * inst_curr) |
157 | / di->curr_source; | 159 | / di->curr_source; |
158 | } else { | 160 | } else { |
159 | /* | 161 | /* |
@@ -209,7 +211,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, | |||
209 | return 0; | 211 | return 0; |
210 | 212 | ||
211 | /* Only do this for batteries with internal NTC */ | 213 | /* Only do this for batteries with internal NTC */ |
212 | if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { | 214 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { |
213 | if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) | 215 | if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) |
214 | curr = BAT_CTRL_7U_ENA; | 216 | curr = BAT_CTRL_7U_ENA; |
215 | else | 217 | else |
@@ -241,7 +243,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, | |||
241 | __func__); | 243 | __func__); |
242 | goto disable_curr_source; | 244 | goto disable_curr_source; |
243 | } | 245 | } |
244 | } else if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { | 246 | } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { |
245 | dev_dbg(di->dev, "Disable BATCTRL curr source\n"); | 247 | dev_dbg(di->dev, "Disable BATCTRL curr source\n"); |
246 | 248 | ||
247 | /* Write 0 to the curr bits */ | 249 | /* Write 0 to the curr bits */ |
@@ -457,9 +459,9 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) | |||
457 | int rbat, rntc, vntc; | 459 | int rbat, rntc, vntc; |
458 | u8 id; | 460 | u8 id; |
459 | 461 | ||
460 | id = di->bat->batt_id; | 462 | id = di->bm->batt_id; |
461 | 463 | ||
462 | if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && | 464 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && |
463 | id != BATTERY_UNKNOWN) { | 465 | id != BATTERY_UNKNOWN) { |
464 | 466 | ||
465 | rbat = ab8500_btemp_get_batctrl_res(di); | 467 | rbat = ab8500_btemp_get_batctrl_res(di); |
@@ -474,8 +476,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) | |||
474 | } | 476 | } |
475 | 477 | ||
476 | temp = ab8500_btemp_res_to_temp(di, | 478 | temp = ab8500_btemp_res_to_temp(di, |
477 | di->bat->bat_type[id].r_to_t_tbl, | 479 | di->bm->bat_type[id].r_to_t_tbl, |
478 | di->bat->bat_type[id].n_temp_tbl_elements, rbat); | 480 | di->bm->bat_type[id].n_temp_tbl_elements, rbat); |
479 | } else { | 481 | } else { |
480 | vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); | 482 | vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); |
481 | if (vntc < 0) { | 483 | if (vntc < 0) { |
@@ -491,8 +493,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) | |||
491 | rntc = 230000 * vntc / (VTVOUT_V - vntc); | 493 | rntc = 230000 * vntc / (VTVOUT_V - vntc); |
492 | 494 | ||
493 | temp = ab8500_btemp_res_to_temp(di, | 495 | temp = ab8500_btemp_res_to_temp(di, |
494 | di->bat->bat_type[id].r_to_t_tbl, | 496 | di->bm->bat_type[id].r_to_t_tbl, |
495 | di->bat->bat_type[id].n_temp_tbl_elements, rntc); | 497 | di->bm->bat_type[id].n_temp_tbl_elements, rntc); |
496 | prev = temp; | 498 | prev = temp; |
497 | } | 499 | } |
498 | dev_dbg(di->dev, "Battery temperature is %d\n", temp); | 500 | dev_dbg(di->dev, "Battery temperature is %d\n", temp); |
@@ -513,7 +515,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) | |||
513 | u8 i; | 515 | u8 i; |
514 | 516 | ||
515 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; | 517 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; |
516 | di->bat->batt_id = BATTERY_UNKNOWN; | 518 | di->bm->batt_id = BATTERY_UNKNOWN; |
517 | 519 | ||
518 | res = ab8500_btemp_get_batctrl_res(di); | 520 | res = ab8500_btemp_get_batctrl_res(di); |
519 | if (res < 0) { | 521 | if (res < 0) { |
@@ -522,23 +524,23 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) | |||
522 | } | 524 | } |
523 | 525 | ||
524 | /* BATTERY_UNKNOWN is defined on position 0, skip it! */ | 526 | /* BATTERY_UNKNOWN is defined on position 0, skip it! */ |
525 | for (i = BATTERY_UNKNOWN + 1; i < di->bat->n_btypes; i++) { | 527 | for (i = BATTERY_UNKNOWN + 1; i < di->bm->n_btypes; i++) { |
526 | if ((res <= di->bat->bat_type[i].resis_high) && | 528 | if ((res <= di->bm->bat_type[i].resis_high) && |
527 | (res >= di->bat->bat_type[i].resis_low)) { | 529 | (res >= di->bm->bat_type[i].resis_low)) { |
528 | dev_dbg(di->dev, "Battery detected on %s" | 530 | dev_dbg(di->dev, "Battery detected on %s" |
529 | " low %d < res %d < high: %d" | 531 | " low %d < res %d < high: %d" |
530 | " index: %d\n", | 532 | " index: %d\n", |
531 | di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL ? | 533 | di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL ? |
532 | "BATCTRL" : "BATTEMP", | 534 | "BATCTRL" : "BATTEMP", |
533 | di->bat->bat_type[i].resis_low, res, | 535 | di->bm->bat_type[i].resis_low, res, |
534 | di->bat->bat_type[i].resis_high, i); | 536 | di->bm->bat_type[i].resis_high, i); |
535 | 537 | ||
536 | di->bat->batt_id = i; | 538 | di->bm->batt_id = i; |
537 | break; | 539 | break; |
538 | } | 540 | } |
539 | } | 541 | } |
540 | 542 | ||
541 | if (di->bat->batt_id == BATTERY_UNKNOWN) { | 543 | if (di->bm->batt_id == BATTERY_UNKNOWN) { |
542 | dev_warn(di->dev, "Battery identified as unknown" | 544 | dev_warn(di->dev, "Battery identified as unknown" |
543 | ", resistance %d Ohm\n", res); | 545 | ", resistance %d Ohm\n", res); |
544 | return -ENXIO; | 546 | return -ENXIO; |
@@ -548,13 +550,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) | |||
548 | * We only have to change current source if the | 550 | * We only have to change current source if the |
549 | * detected type is Type 1, else we use the 7uA source | 551 | * detected type is Type 1, else we use the 7uA source |
550 | */ | 552 | */ |
551 | if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && | 553 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && |
552 | di->bat->batt_id == 1) { | 554 | di->bm->batt_id == 1) { |
553 | dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); | 555 | dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); |
554 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; | 556 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; |
555 | } | 557 | } |
556 | 558 | ||
557 | return di->bat->batt_id; | 559 | return di->bm->batt_id; |
558 | } | 560 | } |
559 | 561 | ||
560 | /** | 562 | /** |
@@ -569,6 +571,13 @@ static void ab8500_btemp_periodic_work(struct work_struct *work) | |||
569 | struct ab8500_btemp *di = container_of(work, | 571 | struct ab8500_btemp *di = container_of(work, |
570 | struct ab8500_btemp, btemp_periodic_work.work); | 572 | struct ab8500_btemp, btemp_periodic_work.work); |
571 | 573 | ||
574 | if (!di->initialized) { | ||
575 | di->initialized = true; | ||
576 | /* Identify the battery */ | ||
577 | if (ab8500_btemp_id(di) < 0) | ||
578 | dev_warn(di->dev, "failed to identify the battery\n"); | ||
579 | } | ||
580 | |||
572 | di->bat_temp = ab8500_btemp_measure_temp(di); | 581 | di->bat_temp = ab8500_btemp_measure_temp(di); |
573 | 582 | ||
574 | if (di->bat_temp != di->prev_bat_temp) { | 583 | if (di->bat_temp != di->prev_bat_temp) { |
@@ -577,9 +586,9 @@ static void ab8500_btemp_periodic_work(struct work_struct *work) | |||
577 | } | 586 | } |
578 | 587 | ||
579 | if (di->events.ac_conn || di->events.usb_conn) | 588 | if (di->events.ac_conn || di->events.usb_conn) |
580 | interval = di->bat->temp_interval_chg; | 589 | interval = di->bm->temp_interval_chg; |
581 | else | 590 | else |
582 | interval = di->bat->temp_interval_nochg; | 591 | interval = di->bm->temp_interval_nochg; |
583 | 592 | ||
584 | /* Schedule a new measurement */ | 593 | /* Schedule a new measurement */ |
585 | queue_delayed_work(di->btemp_wq, | 594 | queue_delayed_work(di->btemp_wq, |
@@ -806,7 +815,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy, | |||
806 | val->intval = 1; | 815 | val->intval = 1; |
807 | break; | 816 | break; |
808 | case POWER_SUPPLY_PROP_TECHNOLOGY: | 817 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
809 | val->intval = di->bat->bat_type[di->bat->batt_id].name; | 818 | val->intval = di->bm->bat_type[di->bm->batt_id].name; |
810 | break; | 819 | break; |
811 | case POWER_SUPPLY_PROP_TEMP: | 820 | case POWER_SUPPLY_PROP_TEMP: |
812 | val->intval = ab8500_btemp_get_temp(di); | 821 | val->intval = ab8500_btemp_get_temp(di); |
@@ -967,6 +976,7 @@ static char *supply_interface[] = { | |||
967 | static int ab8500_btemp_probe(struct platform_device *pdev) | 976 | static int ab8500_btemp_probe(struct platform_device *pdev) |
968 | { | 977 | { |
969 | struct device_node *np = pdev->dev.of_node; | 978 | struct device_node *np = pdev->dev.of_node; |
979 | struct abx500_bm_data *plat = pdev->dev.platform_data; | ||
970 | struct ab8500_btemp *di; | 980 | struct ab8500_btemp *di; |
971 | int irq, i, ret = 0; | 981 | int irq, i, ret = 0; |
972 | u8 val; | 982 | u8 val; |
@@ -976,21 +986,19 @@ static int ab8500_btemp_probe(struct platform_device *pdev) | |||
976 | dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); | 986 | dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); |
977 | return -ENOMEM; | 987 | return -ENOMEM; |
978 | } | 988 | } |
979 | di->bat = pdev->mfd_cell->platform_data; | 989 | |
980 | if (!di->bat) { | 990 | if (!plat) { |
981 | if (np) { | 991 | dev_err(&pdev->dev, "no battery management data supplied\n"); |
982 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | 992 | return -EINVAL; |
983 | if (ret) { | 993 | } |
984 | dev_err(&pdev->dev, | 994 | di->bm = plat; |
985 | "failed to get battery information\n"); | 995 | |
986 | return ret; | 996 | if (np) { |
987 | } | 997 | ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); |
988 | } else { | 998 | if (ret) { |
989 | dev_err(&pdev->dev, "missing dt node for ab8500_btemp\n"); | 999 | dev_err(&pdev->dev, "failed to get battery information\n"); |
990 | return -EINVAL; | 1000 | return ret; |
991 | } | 1001 | } |
992 | } else { | ||
993 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | ||
994 | } | 1002 | } |
995 | 1003 | ||
996 | /* get parent data */ | 1004 | /* get parent data */ |
@@ -998,6 +1006,8 @@ static int ab8500_btemp_probe(struct platform_device *pdev) | |||
998 | di->parent = dev_get_drvdata(pdev->dev.parent); | 1006 | di->parent = dev_get_drvdata(pdev->dev.parent); |
999 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | 1007 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
1000 | 1008 | ||
1009 | di->initialized = false; | ||
1010 | |||
1001 | /* BTEMP supply */ | 1011 | /* BTEMP supply */ |
1002 | di->btemp_psy.name = "ab8500_btemp"; | 1012 | di->btemp_psy.name = "ab8500_btemp"; |
1003 | di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; | 1013 | di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; |
@@ -1022,10 +1032,6 @@ static int ab8500_btemp_probe(struct platform_device *pdev) | |||
1022 | INIT_DEFERRABLE_WORK(&di->btemp_periodic_work, | 1032 | INIT_DEFERRABLE_WORK(&di->btemp_periodic_work, |
1023 | ab8500_btemp_periodic_work); | 1033 | ab8500_btemp_periodic_work); |
1024 | 1034 | ||
1025 | /* Identify the battery */ | ||
1026 | if (ab8500_btemp_id(di) < 0) | ||
1027 | dev_warn(di->dev, "failed to identify the battery\n"); | ||
1028 | |||
1029 | /* Set BTEMP thermal limits. Low and Med are fixed */ | 1035 | /* Set BTEMP thermal limits. Low and Med are fixed */ |
1030 | di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT; | 1036 | di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT; |
1031 | di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT; | 1037 | di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT; |
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 3be9c0ee3fc5..e5755f0ba831 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c | |||
@@ -79,6 +79,9 @@ | |||
79 | /* Lowest charger voltage is 3.39V -> 0x4E */ | 79 | /* Lowest charger voltage is 3.39V -> 0x4E */ |
80 | #define LOW_VOLT_REG 0x4E | 80 | #define LOW_VOLT_REG 0x4E |
81 | 81 | ||
82 | /* Step up/down delay in us */ | ||
83 | #define STEP_UDELAY 1000 | ||
84 | |||
82 | /* UsbLineStatus register - usb types */ | 85 | /* UsbLineStatus register - usb types */ |
83 | enum ab8500_charger_link_status { | 86 | enum ab8500_charger_link_status { |
84 | USB_STAT_NOT_CONFIGURED, | 87 | USB_STAT_NOT_CONFIGURED, |
@@ -186,7 +189,7 @@ struct ab8500_charger_usb_state { | |||
186 | * @autopower_cfg platform specific power config support for "pwron after pwrloss" | 189 | * @autopower_cfg platform specific power config support for "pwron after pwrloss" |
187 | * @parent: Pointer to the struct ab8500 | 190 | * @parent: Pointer to the struct ab8500 |
188 | * @gpadc: Pointer to the struct gpadc | 191 | * @gpadc: Pointer to the struct gpadc |
189 | * @bat: Pointer to the abx500_bm platform data | 192 | * @bm: Platform specific battery management information |
190 | * @flags: Structure for information about events triggered | 193 | * @flags: Structure for information about events triggered |
191 | * @usb_state: Structure for usb stack information | 194 | * @usb_state: Structure for usb stack information |
192 | * @ac_chg: AC charger power supply | 195 | * @ac_chg: AC charger power supply |
@@ -223,7 +226,7 @@ struct ab8500_charger { | |||
223 | bool autopower_cfg; | 226 | bool autopower_cfg; |
224 | struct ab8500 *parent; | 227 | struct ab8500 *parent; |
225 | struct ab8500_gpadc *gpadc; | 228 | struct ab8500_gpadc *gpadc; |
226 | struct abx500_bm_data *bat; | 229 | struct abx500_bm_data *bm; |
227 | struct ab8500_charger_event_flags flags; | 230 | struct ab8500_charger_event_flags flags; |
228 | struct ab8500_charger_usb_state usb_state; | 231 | struct ab8500_charger_usb_state usb_state; |
229 | struct ux500_charger ac_chg; | 232 | struct ux500_charger ac_chg; |
@@ -936,6 +939,88 @@ static int ab8500_charger_get_usb_cur(struct ab8500_charger *di) | |||
936 | } | 939 | } |
937 | 940 | ||
938 | /** | 941 | /** |
942 | * ab8500_charger_set_current() - set charger current | ||
943 | * @di: pointer to the ab8500_charger structure | ||
944 | * @ich: charger current, in mA | ||
945 | * @reg: select what charger register to set | ||
946 | * | ||
947 | * Set charger current. | ||
948 | * There is no state machine in the AB to step up/down the charger | ||
949 | * current to avoid dips and spikes on MAIN, VBUS and VBAT when | ||
950 | * charging is started. Instead we need to implement | ||
951 | * this charger current step-up/down here. | ||
952 | * Returns error code in case of failure else 0(on success) | ||
953 | */ | ||
954 | static int ab8500_charger_set_current(struct ab8500_charger *di, | ||
955 | int ich, int reg) | ||
956 | { | ||
957 | int ret, i; | ||
958 | int curr_index, prev_curr_index, shift_value; | ||
959 | u8 reg_value; | ||
960 | |||
961 | switch (reg) { | ||
962 | case AB8500_MCH_IPT_CURLVL_REG: | ||
963 | shift_value = MAIN_CH_INPUT_CURR_SHIFT; | ||
964 | curr_index = ab8500_current_to_regval(ich); | ||
965 | break; | ||
966 | case AB8500_USBCH_IPT_CRNTLVL_REG: | ||
967 | shift_value = VBUS_IN_CURR_LIM_SHIFT; | ||
968 | curr_index = ab8500_vbus_in_curr_to_regval(ich); | ||
969 | break; | ||
970 | case AB8500_CH_OPT_CRNTLVL_REG: | ||
971 | shift_value = 0; | ||
972 | curr_index = ab8500_current_to_regval(ich); | ||
973 | break; | ||
974 | default: | ||
975 | dev_err(di->dev, "%s current register not valid\n", __func__); | ||
976 | return -ENXIO; | ||
977 | } | ||
978 | |||
979 | if (curr_index < 0) { | ||
980 | dev_err(di->dev, "requested current limit out-of-range\n"); | ||
981 | return -ENXIO; | ||
982 | } | ||
983 | |||
984 | ret = abx500_get_register_interruptible(di->dev, AB8500_CHARGER, | ||
985 | reg, ®_value); | ||
986 | if (ret < 0) { | ||
987 | dev_err(di->dev, "%s read failed\n", __func__); | ||
988 | return ret; | ||
989 | } | ||
990 | prev_curr_index = (reg_value >> shift_value); | ||
991 | |||
992 | /* only update current if it's been changed */ | ||
993 | if (prev_curr_index == curr_index) | ||
994 | return 0; | ||
995 | |||
996 | dev_dbg(di->dev, "%s set charger current: %d mA for reg: 0x%02x\n", | ||
997 | __func__, ich, reg); | ||
998 | |||
999 | if (prev_curr_index > curr_index) { | ||
1000 | for (i = prev_curr_index - 1; i >= curr_index; i--) { | ||
1001 | ret = abx500_set_register_interruptible(di->dev, | ||
1002 | AB8500_CHARGER, reg, (u8) i << shift_value); | ||
1003 | if (ret) { | ||
1004 | dev_err(di->dev, "%s write failed\n", __func__); | ||
1005 | return ret; | ||
1006 | } | ||
1007 | usleep_range(STEP_UDELAY, STEP_UDELAY * 2); | ||
1008 | } | ||
1009 | } else { | ||
1010 | for (i = prev_curr_index + 1; i <= curr_index; i++) { | ||
1011 | ret = abx500_set_register_interruptible(di->dev, | ||
1012 | AB8500_CHARGER, reg, (u8) i << shift_value); | ||
1013 | if (ret) { | ||
1014 | dev_err(di->dev, "%s write failed\n", __func__); | ||
1015 | return ret; | ||
1016 | } | ||
1017 | usleep_range(STEP_UDELAY, STEP_UDELAY * 2); | ||
1018 | } | ||
1019 | } | ||
1020 | return ret; | ||
1021 | } | ||
1022 | |||
1023 | /** | ||
939 | * ab8500_charger_set_vbus_in_curr() - set VBUS input current limit | 1024 | * ab8500_charger_set_vbus_in_curr() - set VBUS input current limit |
940 | * @di: pointer to the ab8500_charger structure | 1025 | * @di: pointer to the ab8500_charger structure |
941 | * @ich_in: charger input current limit | 1026 | * @ich_in: charger input current limit |
@@ -946,12 +1031,10 @@ static int ab8500_charger_get_usb_cur(struct ab8500_charger *di) | |||
946 | static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di, | 1031 | static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di, |
947 | int ich_in) | 1032 | int ich_in) |
948 | { | 1033 | { |
949 | int ret; | ||
950 | int input_curr_index; | ||
951 | int min_value; | 1034 | int min_value; |
952 | 1035 | ||
953 | /* We should always use to lowest current limit */ | 1036 | /* We should always use to lowest current limit */ |
954 | min_value = min(di->bat->chg_params->usb_curr_max, ich_in); | 1037 | min_value = min(di->bm->chg_params->usb_curr_max, ich_in); |
955 | 1038 | ||
956 | switch (min_value) { | 1039 | switch (min_value) { |
957 | case 100: | 1040 | case 100: |
@@ -966,19 +1049,38 @@ static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di, | |||
966 | break; | 1049 | break; |
967 | } | 1050 | } |
968 | 1051 | ||
969 | input_curr_index = ab8500_vbus_in_curr_to_regval(min_value); | 1052 | return ab8500_charger_set_current(di, min_value, |
970 | if (input_curr_index < 0) { | 1053 | AB8500_USBCH_IPT_CRNTLVL_REG); |
971 | dev_err(di->dev, "VBUS input current limit too high\n"); | 1054 | } |
972 | return -ENXIO; | ||
973 | } | ||
974 | 1055 | ||
975 | ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, | 1056 | /** |
976 | AB8500_USBCH_IPT_CRNTLVL_REG, | 1057 | * ab8500_charger_set_main_in_curr() - set main charger input current |
977 | input_curr_index << VBUS_IN_CURR_LIM_SHIFT); | 1058 | * @di: pointer to the ab8500_charger structure |
978 | if (ret) | 1059 | * @ich_in: input charger current, in mA |
979 | dev_err(di->dev, "%s write failed\n", __func__); | 1060 | * |
1061 | * Set main charger input current. | ||
1062 | * Returns error code in case of failure else 0(on success) | ||
1063 | */ | ||
1064 | static int ab8500_charger_set_main_in_curr(struct ab8500_charger *di, | ||
1065 | int ich_in) | ||
1066 | { | ||
1067 | return ab8500_charger_set_current(di, ich_in, | ||
1068 | AB8500_MCH_IPT_CURLVL_REG); | ||
1069 | } | ||
980 | 1070 | ||
981 | return ret; | 1071 | /** |
1072 | * ab8500_charger_set_output_curr() - set charger output current | ||
1073 | * @di: pointer to the ab8500_charger structure | ||
1074 | * @ich_out: output charger current, in mA | ||
1075 | * | ||
1076 | * Set charger output current. | ||
1077 | * Returns error code in case of failure else 0(on success) | ||
1078 | */ | ||
1079 | static int ab8500_charger_set_output_curr(struct ab8500_charger *di, | ||
1080 | int ich_out) | ||
1081 | { | ||
1082 | return ab8500_charger_set_current(di, ich_out, | ||
1083 | AB8500_CH_OPT_CRNTLVL_REG); | ||
982 | } | 1084 | } |
983 | 1085 | ||
984 | /** | 1086 | /** |
@@ -1074,7 +1176,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, | |||
1074 | volt_index = ab8500_voltage_to_regval(vset); | 1176 | volt_index = ab8500_voltage_to_regval(vset); |
1075 | curr_index = ab8500_current_to_regval(iset); | 1177 | curr_index = ab8500_current_to_regval(iset); |
1076 | input_curr_index = ab8500_current_to_regval( | 1178 | input_curr_index = ab8500_current_to_regval( |
1077 | di->bat->chg_params->ac_curr_max); | 1179 | di->bm->chg_params->ac_curr_max); |
1078 | if (volt_index < 0 || curr_index < 0 || input_curr_index < 0) { | 1180 | if (volt_index < 0 || curr_index < 0 || input_curr_index < 0) { |
1079 | dev_err(di->dev, | 1181 | dev_err(di->dev, |
1080 | "Charger voltage or current too high, " | 1182 | "Charger voltage or current too high, " |
@@ -1090,23 +1192,24 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, | |||
1090 | return ret; | 1192 | return ret; |
1091 | } | 1193 | } |
1092 | /* MainChInputCurr: current that can be drawn from the charger*/ | 1194 | /* MainChInputCurr: current that can be drawn from the charger*/ |
1093 | ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, | 1195 | ret = ab8500_charger_set_main_in_curr(di, |
1094 | AB8500_MCH_IPT_CURLVL_REG, | 1196 | di->bm->chg_params->ac_curr_max); |
1095 | input_curr_index << MAIN_CH_INPUT_CURR_SHIFT); | ||
1096 | if (ret) { | 1197 | if (ret) { |
1097 | dev_err(di->dev, "%s write failed\n", __func__); | 1198 | dev_err(di->dev, "%s Failed to set MainChInputCurr\n", |
1199 | __func__); | ||
1098 | return ret; | 1200 | return ret; |
1099 | } | 1201 | } |
1100 | /* ChOutputCurentLevel: protected output current */ | 1202 | /* ChOutputCurentLevel: protected output current */ |
1101 | ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, | 1203 | ret = ab8500_charger_set_output_curr(di, iset); |
1102 | AB8500_CH_OPT_CRNTLVL_REG, (u8) curr_index); | ||
1103 | if (ret) { | 1204 | if (ret) { |
1104 | dev_err(di->dev, "%s write failed\n", __func__); | 1205 | dev_err(di->dev, "%s " |
1206 | "Failed to set ChOutputCurentLevel\n", | ||
1207 | __func__); | ||
1105 | return ret; | 1208 | return ret; |
1106 | } | 1209 | } |
1107 | 1210 | ||
1108 | /* Check if VBAT overshoot control should be enabled */ | 1211 | /* Check if VBAT overshoot control should be enabled */ |
1109 | if (!di->bat->enable_overshoot) | 1212 | if (!di->bm->enable_overshoot) |
1110 | overshoot = MAIN_CH_NO_OVERSHOOT_ENA_N; | 1213 | overshoot = MAIN_CH_NO_OVERSHOOT_ENA_N; |
1111 | 1214 | ||
1112 | /* Enable Main Charger */ | 1215 | /* Enable Main Charger */ |
@@ -1158,12 +1261,11 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, | |||
1158 | return ret; | 1261 | return ret; |
1159 | } | 1262 | } |
1160 | 1263 | ||
1161 | ret = abx500_set_register_interruptible(di->dev, | 1264 | ret = ab8500_charger_set_output_curr(di, 0); |
1162 | AB8500_CHARGER, | ||
1163 | AB8500_CH_OPT_CRNTLVL_REG, CH_OP_CUR_LVL_0P1); | ||
1164 | if (ret) { | 1265 | if (ret) { |
1165 | dev_err(di->dev, | 1266 | dev_err(di->dev, "%s " |
1166 | "%s write failed\n", __func__); | 1267 | "Failed to set ChOutputCurentLevel\n", |
1268 | __func__); | ||
1167 | return ret; | 1269 | return ret; |
1168 | } | 1270 | } |
1169 | } else { | 1271 | } else { |
@@ -1266,14 +1368,15 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger, | |||
1266 | return ret; | 1368 | return ret; |
1267 | } | 1369 | } |
1268 | /* ChOutputCurentLevel: protected output current */ | 1370 | /* ChOutputCurentLevel: protected output current */ |
1269 | ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, | 1371 | ret = ab8500_charger_set_output_curr(di, ich_out); |
1270 | AB8500_CH_OPT_CRNTLVL_REG, (u8) curr_index); | ||
1271 | if (ret) { | 1372 | if (ret) { |
1272 | dev_err(di->dev, "%s write failed\n", __func__); | 1373 | dev_err(di->dev, "%s " |
1374 | "Failed to set ChOutputCurentLevel\n", | ||
1375 | __func__); | ||
1273 | return ret; | 1376 | return ret; |
1274 | } | 1377 | } |
1275 | /* Check if VBAT overshoot control should be enabled */ | 1378 | /* Check if VBAT overshoot control should be enabled */ |
1276 | if (!di->bat->enable_overshoot) | 1379 | if (!di->bm->enable_overshoot) |
1277 | overshoot = USB_CHG_NO_OVERSHOOT_ENA_N; | 1380 | overshoot = USB_CHG_NO_OVERSHOOT_ENA_N; |
1278 | 1381 | ||
1279 | /* Enable USB Charger */ | 1382 | /* Enable USB Charger */ |
@@ -1366,7 +1469,6 @@ static int ab8500_charger_update_charger_current(struct ux500_charger *charger, | |||
1366 | int ich_out) | 1469 | int ich_out) |
1367 | { | 1470 | { |
1368 | int ret; | 1471 | int ret; |
1369 | int curr_index; | ||
1370 | struct ab8500_charger *di; | 1472 | struct ab8500_charger *di; |
1371 | 1473 | ||
1372 | if (charger->psy.type == POWER_SUPPLY_TYPE_MAINS) | 1474 | if (charger->psy.type == POWER_SUPPLY_TYPE_MAINS) |
@@ -1376,18 +1478,11 @@ static int ab8500_charger_update_charger_current(struct ux500_charger *charger, | |||
1376 | else | 1478 | else |
1377 | return -ENXIO; | 1479 | return -ENXIO; |
1378 | 1480 | ||
1379 | curr_index = ab8500_current_to_regval(ich_out); | 1481 | ret = ab8500_charger_set_output_curr(di, ich_out); |
1380 | if (curr_index < 0) { | ||
1381 | dev_err(di->dev, | ||
1382 | "Charger current too high, " | ||
1383 | "charging not started\n"); | ||
1384 | return -ENXIO; | ||
1385 | } | ||
1386 | |||
1387 | ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, | ||
1388 | AB8500_CH_OPT_CRNTLVL_REG, (u8) curr_index); | ||
1389 | if (ret) { | 1482 | if (ret) { |
1390 | dev_err(di->dev, "%s write failed\n", __func__); | 1483 | dev_err(di->dev, "%s " |
1484 | "Failed to set ChOutputCurentLevel\n", | ||
1485 | __func__); | ||
1391 | return ret; | 1486 | return ret; |
1392 | } | 1487 | } |
1393 | 1488 | ||
@@ -2359,8 +2454,8 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) | |||
2359 | ret = abx500_set_register_interruptible(di->dev, | 2454 | ret = abx500_set_register_interruptible(di->dev, |
2360 | AB8500_RTC, | 2455 | AB8500_RTC, |
2361 | AB8500_RTC_BACKUP_CHG_REG, | 2456 | AB8500_RTC_BACKUP_CHG_REG, |
2362 | di->bat->bkup_bat_v | | 2457 | di->bm->bkup_bat_v | |
2363 | di->bat->bkup_bat_i); | 2458 | di->bm->bkup_bat_i); |
2364 | if (ret) { | 2459 | if (ret) { |
2365 | dev_err(di->dev, "failed to setup backup battery charging\n"); | 2460 | dev_err(di->dev, "failed to setup backup battery charging\n"); |
2366 | goto out; | 2461 | goto out; |
@@ -2541,6 +2636,7 @@ static char *supply_interface[] = { | |||
2541 | static int ab8500_charger_probe(struct platform_device *pdev) | 2636 | static int ab8500_charger_probe(struct platform_device *pdev) |
2542 | { | 2637 | { |
2543 | struct device_node *np = pdev->dev.of_node; | 2638 | struct device_node *np = pdev->dev.of_node; |
2639 | struct abx500_bm_data *plat = pdev->dev.platform_data; | ||
2544 | struct ab8500_charger *di; | 2640 | struct ab8500_charger *di; |
2545 | int irq, i, charger_status, ret = 0; | 2641 | int irq, i, charger_status, ret = 0; |
2546 | 2642 | ||
@@ -2549,24 +2645,22 @@ static int ab8500_charger_probe(struct platform_device *pdev) | |||
2549 | dev_err(&pdev->dev, "%s no mem for ab8500_charger\n", __func__); | 2645 | dev_err(&pdev->dev, "%s no mem for ab8500_charger\n", __func__); |
2550 | return -ENOMEM; | 2646 | return -ENOMEM; |
2551 | } | 2647 | } |
2552 | di->bat = pdev->mfd_cell->platform_data; | 2648 | |
2553 | if (!di->bat) { | 2649 | if (!plat) { |
2554 | if (np) { | 2650 | dev_err(&pdev->dev, "no battery management data supplied\n"); |
2555 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | 2651 | return -EINVAL; |
2556 | if (ret) { | 2652 | } |
2557 | dev_err(&pdev->dev, | 2653 | di->bm = plat; |
2558 | "failed to get battery information\n"); | 2654 | |
2559 | return ret; | 2655 | if (np) { |
2560 | } | 2656 | ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); |
2561 | di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); | 2657 | if (ret) { |
2562 | } else { | 2658 | dev_err(&pdev->dev, "failed to get battery information\n"); |
2563 | dev_err(&pdev->dev, "missing dt node for ab8500_charger\n"); | 2659 | return ret; |
2564 | return -EINVAL; | ||
2565 | } | 2660 | } |
2566 | } else { | 2661 | di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); |
2567 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | 2662 | } else |
2568 | di->autopower_cfg = false; | 2663 | di->autopower_cfg = false; |
2569 | } | ||
2570 | 2664 | ||
2571 | /* get parent data */ | 2665 | /* get parent data */ |
2572 | di->dev = &pdev->dev; | 2666 | di->dev = &pdev->dev; |
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index b3bf178c3462..3d05c73813c8 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c | |||
@@ -173,7 +173,7 @@ struct inst_curr_result_list { | |||
173 | * @avg_cap: Average capacity filter | 173 | * @avg_cap: Average capacity filter |
174 | * @parent: Pointer to the struct ab8500 | 174 | * @parent: Pointer to the struct ab8500 |
175 | * @gpadc: Pointer to the struct gpadc | 175 | * @gpadc: Pointer to the struct gpadc |
176 | * @bat: Pointer to the abx500_bm platform data | 176 | * @bm: Platform specific battery management information |
177 | * @fg_psy: Structure that holds the FG specific battery properties | 177 | * @fg_psy: Structure that holds the FG specific battery properties |
178 | * @fg_wq: Work queue for running the FG algorithm | 178 | * @fg_wq: Work queue for running the FG algorithm |
179 | * @fg_periodic_work: Work to run the FG algorithm periodically | 179 | * @fg_periodic_work: Work to run the FG algorithm periodically |
@@ -212,7 +212,7 @@ struct ab8500_fg { | |||
212 | struct ab8500_fg_avg_cap avg_cap; | 212 | struct ab8500_fg_avg_cap avg_cap; |
213 | struct ab8500 *parent; | 213 | struct ab8500 *parent; |
214 | struct ab8500_gpadc *gpadc; | 214 | struct ab8500_gpadc *gpadc; |
215 | struct abx500_bm_data *bat; | 215 | struct abx500_bm_data *bm; |
216 | struct power_supply fg_psy; | 216 | struct power_supply fg_psy; |
217 | struct workqueue_struct *fg_wq; | 217 | struct workqueue_struct *fg_wq; |
218 | struct delayed_work fg_periodic_work; | 218 | struct delayed_work fg_periodic_work; |
@@ -355,7 +355,7 @@ static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr) | |||
355 | /* | 355 | /* |
356 | * We want to know if we're in low current mode | 356 | * We want to know if we're in low current mode |
357 | */ | 357 | */ |
358 | if (curr > -di->bat->fg_params->high_curr_threshold) | 358 | if (curr > -di->bm->fg_params->high_curr_threshold) |
359 | return true; | 359 | return true; |
360 | else | 360 | else |
361 | return false; | 361 | return false; |
@@ -484,8 +484,9 @@ static int ab8500_fg_coulomb_counter(struct ab8500_fg *di, bool enable) | |||
484 | di->flags.fg_enabled = true; | 484 | di->flags.fg_enabled = true; |
485 | } else { | 485 | } else { |
486 | /* Clear any pending read requests */ | 486 | /* Clear any pending read requests */ |
487 | ret = abx500_set_register_interruptible(di->dev, | 487 | ret = abx500_mask_and_set_register_interruptible(di->dev, |
488 | AB8500_GAS_GAUGE, AB8500_GASG_CC_CTRL_REG, 0); | 488 | AB8500_GAS_GAUGE, AB8500_GASG_CC_CTRL_REG, |
489 | (RESET_ACCU | READ_REQ), 0); | ||
489 | if (ret) | 490 | if (ret) |
490 | goto cc_err; | 491 | goto cc_err; |
491 | 492 | ||
@@ -647,7 +648,7 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res) | |||
647 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm | 648 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm |
648 | */ | 649 | */ |
649 | val = (val * QLSB_NANO_AMP_HOURS_X10 * 36 * 4) / | 650 | val = (val * QLSB_NANO_AMP_HOURS_X10 * 36 * 4) / |
650 | (1000 * di->bat->fg_res); | 651 | (1000 * di->bm->fg_res); |
651 | 652 | ||
652 | if (di->turn_off_fg) { | 653 | if (di->turn_off_fg) { |
653 | dev_dbg(di->dev, "%s Disable FG\n", __func__); | 654 | dev_dbg(di->dev, "%s Disable FG\n", __func__); |
@@ -750,7 +751,7 @@ static void ab8500_fg_acc_cur_work(struct work_struct *work) | |||
750 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm | 751 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm |
751 | */ | 752 | */ |
752 | di->accu_charge = (val * QLSB_NANO_AMP_HOURS_X10) / | 753 | di->accu_charge = (val * QLSB_NANO_AMP_HOURS_X10) / |
753 | (100 * di->bat->fg_res); | 754 | (100 * di->bm->fg_res); |
754 | 755 | ||
755 | /* | 756 | /* |
756 | * Convert to unit value in mA | 757 | * Convert to unit value in mA |
@@ -762,7 +763,7 @@ static void ab8500_fg_acc_cur_work(struct work_struct *work) | |||
762 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm | 763 | * 112.9nAh assumes 10mOhm, but fg_res is in 0.1mOhm |
763 | */ | 764 | */ |
764 | di->avg_curr = (val * QLSB_NANO_AMP_HOURS_X10 * 36) / | 765 | di->avg_curr = (val * QLSB_NANO_AMP_HOURS_X10 * 36) / |
765 | (1000 * di->bat->fg_res * (di->fg_samples / 4)); | 766 | (1000 * di->bm->fg_res * (di->fg_samples / 4)); |
766 | 767 | ||
767 | di->flags.conv_done = true; | 768 | di->flags.conv_done = true; |
768 | 769 | ||
@@ -814,8 +815,8 @@ static int ab8500_fg_volt_to_capacity(struct ab8500_fg *di, int voltage) | |||
814 | struct abx500_v_to_cap *tbl; | 815 | struct abx500_v_to_cap *tbl; |
815 | int cap = 0; | 816 | int cap = 0; |
816 | 817 | ||
817 | tbl = di->bat->bat_type[di->bat->batt_id].v_to_cap_tbl, | 818 | tbl = di->bm->bat_type[di->bm->batt_id].v_to_cap_tbl, |
818 | tbl_size = di->bat->bat_type[di->bat->batt_id].n_v_cap_tbl_elements; | 819 | tbl_size = di->bm->bat_type[di->bm->batt_id].n_v_cap_tbl_elements; |
819 | 820 | ||
820 | for (i = 0; i < tbl_size; ++i) { | 821 | for (i = 0; i < tbl_size; ++i) { |
821 | if (voltage > tbl[i].voltage) | 822 | if (voltage > tbl[i].voltage) |
@@ -866,8 +867,8 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di) | |||
866 | struct batres_vs_temp *tbl; | 867 | struct batres_vs_temp *tbl; |
867 | int resist = 0; | 868 | int resist = 0; |
868 | 869 | ||
869 | tbl = di->bat->bat_type[di->bat->batt_id].batres_tbl; | 870 | tbl = di->bm->bat_type[di->bm->batt_id].batres_tbl; |
870 | tbl_size = di->bat->bat_type[di->bat->batt_id].n_batres_tbl_elements; | 871 | tbl_size = di->bm->bat_type[di->bm->batt_id].n_batres_tbl_elements; |
871 | 872 | ||
872 | for (i = 0; i < tbl_size; ++i) { | 873 | for (i = 0; i < tbl_size; ++i) { |
873 | if (di->bat_temp / 10 > tbl[i].temp) | 874 | if (di->bat_temp / 10 > tbl[i].temp) |
@@ -888,11 +889,11 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di) | |||
888 | 889 | ||
889 | dev_dbg(di->dev, "%s Temp: %d battery internal resistance: %d" | 890 | dev_dbg(di->dev, "%s Temp: %d battery internal resistance: %d" |
890 | " fg resistance %d, total: %d (mOhm)\n", | 891 | " fg resistance %d, total: %d (mOhm)\n", |
891 | __func__, di->bat_temp, resist, di->bat->fg_res / 10, | 892 | __func__, di->bat_temp, resist, di->bm->fg_res / 10, |
892 | (di->bat->fg_res / 10) + resist); | 893 | (di->bm->fg_res / 10) + resist); |
893 | 894 | ||
894 | /* fg_res variable is in 0.1mOhm */ | 895 | /* fg_res variable is in 0.1mOhm */ |
895 | resist += di->bat->fg_res / 10; | 896 | resist += di->bm->fg_res / 10; |
896 | 897 | ||
897 | return resist; | 898 | return resist; |
898 | } | 899 | } |
@@ -1110,14 +1111,14 @@ static int ab8500_fg_capacity_level(struct ab8500_fg *di) | |||
1110 | 1111 | ||
1111 | percent = di->bat_cap.permille / 10; | 1112 | percent = di->bat_cap.permille / 10; |
1112 | 1113 | ||
1113 | if (percent <= di->bat->cap_levels->critical || | 1114 | if (percent <= di->bm->cap_levels->critical || |
1114 | di->flags.low_bat) | 1115 | di->flags.low_bat) |
1115 | ret = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; | 1116 | ret = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; |
1116 | else if (percent <= di->bat->cap_levels->low) | 1117 | else if (percent <= di->bm->cap_levels->low) |
1117 | ret = POWER_SUPPLY_CAPACITY_LEVEL_LOW; | 1118 | ret = POWER_SUPPLY_CAPACITY_LEVEL_LOW; |
1118 | else if (percent <= di->bat->cap_levels->normal) | 1119 | else if (percent <= di->bm->cap_levels->normal) |
1119 | ret = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; | 1120 | ret = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; |
1120 | else if (percent <= di->bat->cap_levels->high) | 1121 | else if (percent <= di->bm->cap_levels->high) |
1121 | ret = POWER_SUPPLY_CAPACITY_LEVEL_HIGH; | 1122 | ret = POWER_SUPPLY_CAPACITY_LEVEL_HIGH; |
1122 | else | 1123 | else |
1123 | ret = POWER_SUPPLY_CAPACITY_LEVEL_FULL; | 1124 | ret = POWER_SUPPLY_CAPACITY_LEVEL_FULL; |
@@ -1182,7 +1183,7 @@ static void ab8500_fg_check_capacity_limits(struct ab8500_fg *di, bool init) | |||
1182 | di->bat_cap.prev_percent != | 1183 | di->bat_cap.prev_percent != |
1183 | (di->bat_cap.permille) / 10 && | 1184 | (di->bat_cap.permille) / 10 && |
1184 | (di->bat_cap.permille / 10) < | 1185 | (di->bat_cap.permille / 10) < |
1185 | di->bat->fg_params->maint_thres) { | 1186 | di->bm->fg_params->maint_thres) { |
1186 | dev_dbg(di->dev, | 1187 | dev_dbg(di->dev, |
1187 | "battery reported full " | 1188 | "battery reported full " |
1188 | "but capacity dropping: %d\n", | 1189 | "but capacity dropping: %d\n", |
@@ -1284,7 +1285,7 @@ static void ab8500_fg_algorithm_charging(struct ab8500_fg *di) | |||
1284 | switch (di->charge_state) { | 1285 | switch (di->charge_state) { |
1285 | case AB8500_FG_CHARGE_INIT: | 1286 | case AB8500_FG_CHARGE_INIT: |
1286 | di->fg_samples = SEC_TO_SAMPLE( | 1287 | di->fg_samples = SEC_TO_SAMPLE( |
1287 | di->bat->fg_params->accu_charging); | 1288 | di->bm->fg_params->accu_charging); |
1288 | 1289 | ||
1289 | ab8500_fg_coulomb_counter(di, true); | 1290 | ab8500_fg_coulomb_counter(di, true); |
1290 | ab8500_fg_charge_state_to(di, AB8500_FG_CHARGE_READOUT); | 1291 | ab8500_fg_charge_state_to(di, AB8500_FG_CHARGE_READOUT); |
@@ -1346,8 +1347,8 @@ static bool check_sysfs_capacity(struct ab8500_fg *di) | |||
1346 | cap_permille = ab8500_fg_convert_mah_to_permille(di, | 1347 | cap_permille = ab8500_fg_convert_mah_to_permille(di, |
1347 | di->bat_cap.user_mah); | 1348 | di->bat_cap.user_mah); |
1348 | 1349 | ||
1349 | lower = di->bat_cap.permille - di->bat->fg_params->user_cap_limit * 10; | 1350 | lower = di->bat_cap.permille - di->bm->fg_params->user_cap_limit * 10; |
1350 | upper = di->bat_cap.permille + di->bat->fg_params->user_cap_limit * 10; | 1351 | upper = di->bat_cap.permille + di->bm->fg_params->user_cap_limit * 10; |
1351 | 1352 | ||
1352 | if (lower < 0) | 1353 | if (lower < 0) |
1353 | lower = 0; | 1354 | lower = 0; |
@@ -1387,7 +1388,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1387 | case AB8500_FG_DISCHARGE_INIT: | 1388 | case AB8500_FG_DISCHARGE_INIT: |
1388 | /* We use the FG IRQ to work on */ | 1389 | /* We use the FG IRQ to work on */ |
1389 | di->init_cnt = 0; | 1390 | di->init_cnt = 0; |
1390 | di->fg_samples = SEC_TO_SAMPLE(di->bat->fg_params->init_timer); | 1391 | di->fg_samples = SEC_TO_SAMPLE(di->bm->fg_params->init_timer); |
1391 | ab8500_fg_coulomb_counter(di, true); | 1392 | ab8500_fg_coulomb_counter(di, true); |
1392 | ab8500_fg_discharge_state_to(di, | 1393 | ab8500_fg_discharge_state_to(di, |
1393 | AB8500_FG_DISCHARGE_INITMEASURING); | 1394 | AB8500_FG_DISCHARGE_INITMEASURING); |
@@ -1400,18 +1401,17 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1400 | * samples to get an initial capacity. | 1401 | * samples to get an initial capacity. |
1401 | * Then go to READOUT | 1402 | * Then go to READOUT |
1402 | */ | 1403 | */ |
1403 | sleep_time = di->bat->fg_params->init_timer; | 1404 | sleep_time = di->bm->fg_params->init_timer; |
1404 | 1405 | ||
1405 | /* Discard the first [x] seconds */ | 1406 | /* Discard the first [x] seconds */ |
1406 | if (di->init_cnt > | 1407 | if (di->init_cnt > di->bm->fg_params->init_discard_time) { |
1407 | di->bat->fg_params->init_discard_time) { | ||
1408 | ab8500_fg_calc_cap_discharge_voltage(di, true); | 1408 | ab8500_fg_calc_cap_discharge_voltage(di, true); |
1409 | 1409 | ||
1410 | ab8500_fg_check_capacity_limits(di, true); | 1410 | ab8500_fg_check_capacity_limits(di, true); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | di->init_cnt += sleep_time; | 1413 | di->init_cnt += sleep_time; |
1414 | if (di->init_cnt > di->bat->fg_params->init_total_time) | 1414 | if (di->init_cnt > di->bm->fg_params->init_total_time) |
1415 | ab8500_fg_discharge_state_to(di, | 1415 | ab8500_fg_discharge_state_to(di, |
1416 | AB8500_FG_DISCHARGE_READOUT_INIT); | 1416 | AB8500_FG_DISCHARGE_READOUT_INIT); |
1417 | 1417 | ||
@@ -1426,7 +1426,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1426 | /* Intentional fallthrough */ | 1426 | /* Intentional fallthrough */ |
1427 | 1427 | ||
1428 | case AB8500_FG_DISCHARGE_RECOVERY: | 1428 | case AB8500_FG_DISCHARGE_RECOVERY: |
1429 | sleep_time = di->bat->fg_params->recovery_sleep_timer; | 1429 | sleep_time = di->bm->fg_params->recovery_sleep_timer; |
1430 | 1430 | ||
1431 | /* | 1431 | /* |
1432 | * We should check the power consumption | 1432 | * We should check the power consumption |
@@ -1438,9 +1438,9 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1438 | 1438 | ||
1439 | if (ab8500_fg_is_low_curr(di, di->inst_curr)) { | 1439 | if (ab8500_fg_is_low_curr(di, di->inst_curr)) { |
1440 | if (di->recovery_cnt > | 1440 | if (di->recovery_cnt > |
1441 | di->bat->fg_params->recovery_total_time) { | 1441 | di->bm->fg_params->recovery_total_time) { |
1442 | di->fg_samples = SEC_TO_SAMPLE( | 1442 | di->fg_samples = SEC_TO_SAMPLE( |
1443 | di->bat->fg_params->accu_high_curr); | 1443 | di->bm->fg_params->accu_high_curr); |
1444 | ab8500_fg_coulomb_counter(di, true); | 1444 | ab8500_fg_coulomb_counter(di, true); |
1445 | ab8500_fg_discharge_state_to(di, | 1445 | ab8500_fg_discharge_state_to(di, |
1446 | AB8500_FG_DISCHARGE_READOUT); | 1446 | AB8500_FG_DISCHARGE_READOUT); |
@@ -1453,7 +1453,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1453 | di->recovery_cnt += sleep_time; | 1453 | di->recovery_cnt += sleep_time; |
1454 | } else { | 1454 | } else { |
1455 | di->fg_samples = SEC_TO_SAMPLE( | 1455 | di->fg_samples = SEC_TO_SAMPLE( |
1456 | di->bat->fg_params->accu_high_curr); | 1456 | di->bm->fg_params->accu_high_curr); |
1457 | ab8500_fg_coulomb_counter(di, true); | 1457 | ab8500_fg_coulomb_counter(di, true); |
1458 | ab8500_fg_discharge_state_to(di, | 1458 | ab8500_fg_discharge_state_to(di, |
1459 | AB8500_FG_DISCHARGE_READOUT); | 1459 | AB8500_FG_DISCHARGE_READOUT); |
@@ -1462,7 +1462,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1462 | 1462 | ||
1463 | case AB8500_FG_DISCHARGE_READOUT_INIT: | 1463 | case AB8500_FG_DISCHARGE_READOUT_INIT: |
1464 | di->fg_samples = SEC_TO_SAMPLE( | 1464 | di->fg_samples = SEC_TO_SAMPLE( |
1465 | di->bat->fg_params->accu_high_curr); | 1465 | di->bm->fg_params->accu_high_curr); |
1466 | ab8500_fg_coulomb_counter(di, true); | 1466 | ab8500_fg_coulomb_counter(di, true); |
1467 | ab8500_fg_discharge_state_to(di, | 1467 | ab8500_fg_discharge_state_to(di, |
1468 | AB8500_FG_DISCHARGE_READOUT); | 1468 | AB8500_FG_DISCHARGE_READOUT); |
@@ -1509,9 +1509,9 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | di->high_curr_cnt += | 1511 | di->high_curr_cnt += |
1512 | di->bat->fg_params->accu_high_curr; | 1512 | di->bm->fg_params->accu_high_curr; |
1513 | if (di->high_curr_cnt > | 1513 | if (di->high_curr_cnt > |
1514 | di->bat->fg_params->high_curr_time) | 1514 | di->bm->fg_params->high_curr_time) |
1515 | di->recovery_needed = true; | 1515 | di->recovery_needed = true; |
1516 | 1516 | ||
1517 | ab8500_fg_calc_cap_discharge_fg(di); | 1517 | ab8500_fg_calc_cap_discharge_fg(di); |
@@ -1528,7 +1528,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di) | |||
1528 | ab8500_fg_calc_cap_discharge_voltage(di, true); | 1528 | ab8500_fg_calc_cap_discharge_voltage(di, true); |
1529 | 1529 | ||
1530 | di->fg_samples = SEC_TO_SAMPLE( | 1530 | di->fg_samples = SEC_TO_SAMPLE( |
1531 | di->bat->fg_params->accu_high_curr); | 1531 | di->bm->fg_params->accu_high_curr); |
1532 | ab8500_fg_coulomb_counter(di, true); | 1532 | ab8500_fg_coulomb_counter(di, true); |
1533 | ab8500_fg_discharge_state_to(di, | 1533 | ab8500_fg_discharge_state_to(di, |
1534 | AB8500_FG_DISCHARGE_READOUT); | 1534 | AB8500_FG_DISCHARGE_READOUT); |
@@ -1721,7 +1721,7 @@ static void ab8500_fg_low_bat_work(struct work_struct *work) | |||
1721 | vbat = ab8500_fg_bat_voltage(di); | 1721 | vbat = ab8500_fg_bat_voltage(di); |
1722 | 1722 | ||
1723 | /* Check if LOW_BAT still fulfilled */ | 1723 | /* Check if LOW_BAT still fulfilled */ |
1724 | if (vbat < di->bat->fg_params->lowbat_threshold) { | 1724 | if (vbat < di->bm->fg_params->lowbat_threshold) { |
1725 | di->flags.low_bat = true; | 1725 | di->flags.low_bat = true; |
1726 | dev_warn(di->dev, "Battery voltage still LOW\n"); | 1726 | dev_warn(di->dev, "Battery voltage still LOW\n"); |
1727 | 1727 | ||
@@ -1779,8 +1779,8 @@ static int ab8500_fg_battok_init_hw_register(struct ab8500_fg *di) | |||
1779 | int ret; | 1779 | int ret; |
1780 | int new_val; | 1780 | int new_val; |
1781 | 1781 | ||
1782 | sel0 = di->bat->fg_params->battok_falling_th_sel0; | 1782 | sel0 = di->bm->fg_params->battok_falling_th_sel0; |
1783 | sel1 = di->bat->fg_params->battok_raising_th_sel1; | 1783 | sel1 = di->bm->fg_params->battok_raising_th_sel1; |
1784 | 1784 | ||
1785 | cbp_sel0 = ab8500_fg_battok_calc(di, sel0); | 1785 | cbp_sel0 = ab8500_fg_battok_calc(di, sel0); |
1786 | cbp_sel1 = ab8500_fg_battok_calc(di, sel1); | 1786 | cbp_sel1 = ab8500_fg_battok_calc(di, sel1); |
@@ -1963,7 +1963,7 @@ static int ab8500_fg_get_property(struct power_supply *psy, | |||
1963 | di->bat_cap.max_mah); | 1963 | di->bat_cap.max_mah); |
1964 | break; | 1964 | break; |
1965 | case POWER_SUPPLY_PROP_ENERGY_NOW: | 1965 | case POWER_SUPPLY_PROP_ENERGY_NOW: |
1966 | if (di->flags.batt_unknown && !di->bat->chg_unknown_bat && | 1966 | if (di->flags.batt_unknown && !di->bm->chg_unknown_bat && |
1967 | di->flags.batt_id_received) | 1967 | di->flags.batt_id_received) |
1968 | val->intval = ab8500_fg_convert_mah_to_uwh(di, | 1968 | val->intval = ab8500_fg_convert_mah_to_uwh(di, |
1969 | di->bat_cap.max_mah); | 1969 | di->bat_cap.max_mah); |
@@ -1978,21 +1978,21 @@ static int ab8500_fg_get_property(struct power_supply *psy, | |||
1978 | val->intval = di->bat_cap.max_mah; | 1978 | val->intval = di->bat_cap.max_mah; |
1979 | break; | 1979 | break; |
1980 | case POWER_SUPPLY_PROP_CHARGE_NOW: | 1980 | case POWER_SUPPLY_PROP_CHARGE_NOW: |
1981 | if (di->flags.batt_unknown && !di->bat->chg_unknown_bat && | 1981 | if (di->flags.batt_unknown && !di->bm->chg_unknown_bat && |
1982 | di->flags.batt_id_received) | 1982 | di->flags.batt_id_received) |
1983 | val->intval = di->bat_cap.max_mah; | 1983 | val->intval = di->bat_cap.max_mah; |
1984 | else | 1984 | else |
1985 | val->intval = di->bat_cap.prev_mah; | 1985 | val->intval = di->bat_cap.prev_mah; |
1986 | break; | 1986 | break; |
1987 | case POWER_SUPPLY_PROP_CAPACITY: | 1987 | case POWER_SUPPLY_PROP_CAPACITY: |
1988 | if (di->flags.batt_unknown && !di->bat->chg_unknown_bat && | 1988 | if (di->flags.batt_unknown && !di->bm->chg_unknown_bat && |
1989 | di->flags.batt_id_received) | 1989 | di->flags.batt_id_received) |
1990 | val->intval = 100; | 1990 | val->intval = 100; |
1991 | else | 1991 | else |
1992 | val->intval = di->bat_cap.prev_percent; | 1992 | val->intval = di->bat_cap.prev_percent; |
1993 | break; | 1993 | break; |
1994 | case POWER_SUPPLY_PROP_CAPACITY_LEVEL: | 1994 | case POWER_SUPPLY_PROP_CAPACITY_LEVEL: |
1995 | if (di->flags.batt_unknown && !di->bat->chg_unknown_bat && | 1995 | if (di->flags.batt_unknown && !di->bm->chg_unknown_bat && |
1996 | di->flags.batt_id_received) | 1996 | di->flags.batt_id_received) |
1997 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; | 1997 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; |
1998 | else | 1998 | else |
@@ -2078,7 +2078,7 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) | |||
2078 | if (!di->flags.batt_id_received) { | 2078 | if (!di->flags.batt_id_received) { |
2079 | const struct abx500_battery_type *b; | 2079 | const struct abx500_battery_type *b; |
2080 | 2080 | ||
2081 | b = &(di->bat->bat_type[di->bat->batt_id]); | 2081 | b = &(di->bm->bat_type[di->bm->batt_id]); |
2082 | 2082 | ||
2083 | di->flags.batt_id_received = true; | 2083 | di->flags.batt_id_received = true; |
2084 | 2084 | ||
@@ -2155,7 +2155,7 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di) | |||
2155 | AB8500_SYS_CTRL2_BLOCK, | 2155 | AB8500_SYS_CTRL2_BLOCK, |
2156 | AB8500_LOW_BAT_REG, | 2156 | AB8500_LOW_BAT_REG, |
2157 | ab8500_volt_to_regval( | 2157 | ab8500_volt_to_regval( |
2158 | di->bat->fg_params->lowbat_threshold) << 1 | | 2158 | di->bm->fg_params->lowbat_threshold) << 1 | |
2159 | LOW_BAT_ENABLE); | 2159 | LOW_BAT_ENABLE); |
2160 | if (ret) { | 2160 | if (ret) { |
2161 | dev_err(di->dev, "%s write failed\n", __func__); | 2161 | dev_err(di->dev, "%s write failed\n", __func__); |
@@ -2448,6 +2448,7 @@ static char *supply_interface[] = { | |||
2448 | static int ab8500_fg_probe(struct platform_device *pdev) | 2448 | static int ab8500_fg_probe(struct platform_device *pdev) |
2449 | { | 2449 | { |
2450 | struct device_node *np = pdev->dev.of_node; | 2450 | struct device_node *np = pdev->dev.of_node; |
2451 | struct abx500_bm_data *plat = pdev->dev.platform_data; | ||
2451 | struct ab8500_fg *di; | 2452 | struct ab8500_fg *di; |
2452 | int i, irq; | 2453 | int i, irq; |
2453 | int ret = 0; | 2454 | int ret = 0; |
@@ -2457,21 +2458,19 @@ static int ab8500_fg_probe(struct platform_device *pdev) | |||
2457 | dev_err(&pdev->dev, "%s no mem for ab8500_fg\n", __func__); | 2458 | dev_err(&pdev->dev, "%s no mem for ab8500_fg\n", __func__); |
2458 | return -ENOMEM; | 2459 | return -ENOMEM; |
2459 | } | 2460 | } |
2460 | di->bat = pdev->mfd_cell->platform_data; | 2461 | |
2461 | if (!di->bat) { | 2462 | if (!plat) { |
2462 | if (np) { | 2463 | dev_err(&pdev->dev, "no battery management data supplied\n"); |
2463 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | 2464 | return -EINVAL; |
2464 | if (ret) { | 2465 | } |
2465 | dev_err(&pdev->dev, | 2466 | di->bm = plat; |
2466 | "failed to get battery information\n"); | 2467 | |
2467 | return ret; | 2468 | if (np) { |
2468 | } | 2469 | ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); |
2469 | } else { | 2470 | if (ret) { |
2470 | dev_err(&pdev->dev, "missing dt node for ab8500_fg\n"); | 2471 | dev_err(&pdev->dev, "failed to get battery information\n"); |
2471 | return -EINVAL; | 2472 | return ret; |
2472 | } | 2473 | } |
2473 | } else { | ||
2474 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | ||
2475 | } | 2474 | } |
2476 | 2475 | ||
2477 | mutex_init(&di->cc_lock); | 2476 | mutex_init(&di->cc_lock); |
@@ -2491,11 +2490,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) | |||
2491 | di->fg_psy.external_power_changed = ab8500_fg_external_power_changed; | 2490 | di->fg_psy.external_power_changed = ab8500_fg_external_power_changed; |
2492 | 2491 | ||
2493 | di->bat_cap.max_mah_design = MILLI_TO_MICRO * | 2492 | di->bat_cap.max_mah_design = MILLI_TO_MICRO * |
2494 | di->bat->bat_type[di->bat->batt_id].charge_full_design; | 2493 | di->bm->bat_type[di->bm->batt_id].charge_full_design; |
2495 | 2494 | ||
2496 | di->bat_cap.max_mah = di->bat_cap.max_mah_design; | 2495 | di->bat_cap.max_mah = di->bat_cap.max_mah_design; |
2497 | 2496 | ||
2498 | di->vbat_nom = di->bat->bat_type[di->bat->batt_id].nominal_voltage; | 2497 | di->vbat_nom = di->bm->bat_type[di->bm->batt_id].nominal_voltage; |
2499 | 2498 | ||
2500 | di->init_capacity = true; | 2499 | di->init_capacity = true; |
2501 | 2500 | ||
@@ -2549,7 +2548,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) | |||
2549 | goto free_inst_curr_wq; | 2548 | goto free_inst_curr_wq; |
2550 | } | 2549 | } |
2551 | 2550 | ||
2552 | di->fg_samples = SEC_TO_SAMPLE(di->bat->fg_params->init_timer); | 2551 | di->fg_samples = SEC_TO_SAMPLE(di->bm->fg_params->init_timer); |
2553 | ab8500_fg_coulomb_counter(di, true); | 2552 | ab8500_fg_coulomb_counter(di, true); |
2554 | 2553 | ||
2555 | /* Initialize completion used to notify completion of inst current */ | 2554 | /* Initialize completion used to notify completion of inst current */ |
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 297089146064..8b69da0ae5af 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c | |||
@@ -207,7 +207,7 @@ enum maxim_ret { | |||
207 | * @chg_info: information about connected charger types | 207 | * @chg_info: information about connected charger types |
208 | * @batt_data: data of the battery | 208 | * @batt_data: data of the battery |
209 | * @susp_status: current charger suspension status | 209 | * @susp_status: current charger suspension status |
210 | * @bat: pointer to the abx500_bm platform data | 210 | * @bm: Platform specific battery management information |
211 | * @chargalg_psy: structure that holds the battery properties exposed by | 211 | * @chargalg_psy: structure that holds the battery properties exposed by |
212 | * the charging algorithm | 212 | * the charging algorithm |
213 | * @events: structure for information about events triggered | 213 | * @events: structure for information about events triggered |
@@ -232,7 +232,7 @@ struct abx500_chargalg { | |||
232 | struct abx500_chargalg_charger_info chg_info; | 232 | struct abx500_chargalg_charger_info chg_info; |
233 | struct abx500_chargalg_battery_data batt_data; | 233 | struct abx500_chargalg_battery_data batt_data; |
234 | struct abx500_chargalg_suspension_status susp_status; | 234 | struct abx500_chargalg_suspension_status susp_status; |
235 | struct abx500_bm_data *bat; | 235 | struct abx500_bm_data *bm; |
236 | struct power_supply chargalg_psy; | 236 | struct power_supply chargalg_psy; |
237 | struct ux500_charger *ac_chg; | 237 | struct ux500_charger *ac_chg; |
238 | struct ux500_charger *usb_chg; | 238 | struct ux500_charger *usb_chg; |
@@ -367,13 +367,13 @@ static void abx500_chargalg_start_safety_timer(struct abx500_chargalg *di) | |||
367 | case AC_CHG: | 367 | case AC_CHG: |
368 | timer_expiration = | 368 | timer_expiration = |
369 | round_jiffies(jiffies + | 369 | round_jiffies(jiffies + |
370 | (di->bat->main_safety_tmr_h * 3600 * HZ)); | 370 | (di->bm->main_safety_tmr_h * 3600 * HZ)); |
371 | break; | 371 | break; |
372 | 372 | ||
373 | case USB_CHG: | 373 | case USB_CHG: |
374 | timer_expiration = | 374 | timer_expiration = |
375 | round_jiffies(jiffies + | 375 | round_jiffies(jiffies + |
376 | (di->bat->usb_safety_tmr_h * 3600 * HZ)); | 376 | (di->bm->usb_safety_tmr_h * 3600 * HZ)); |
377 | break; | 377 | break; |
378 | 378 | ||
379 | default: | 379 | default: |
@@ -638,32 +638,32 @@ static void abx500_chargalg_start_charging(struct abx500_chargalg *di, | |||
638 | */ | 638 | */ |
639 | static void abx500_chargalg_check_temp(struct abx500_chargalg *di) | 639 | static void abx500_chargalg_check_temp(struct abx500_chargalg *di) |
640 | { | 640 | { |
641 | if (di->batt_data.temp > (di->bat->temp_low + di->t_hyst_norm) && | 641 | if (di->batt_data.temp > (di->bm->temp_low + di->t_hyst_norm) && |
642 | di->batt_data.temp < (di->bat->temp_high - di->t_hyst_norm)) { | 642 | di->batt_data.temp < (di->bm->temp_high - di->t_hyst_norm)) { |
643 | /* Temp OK! */ | 643 | /* Temp OK! */ |
644 | di->events.btemp_underover = false; | 644 | di->events.btemp_underover = false; |
645 | di->events.btemp_lowhigh = false; | 645 | di->events.btemp_lowhigh = false; |
646 | di->t_hyst_norm = 0; | 646 | di->t_hyst_norm = 0; |
647 | di->t_hyst_lowhigh = 0; | 647 | di->t_hyst_lowhigh = 0; |
648 | } else { | 648 | } else { |
649 | if (((di->batt_data.temp >= di->bat->temp_high) && | 649 | if (((di->batt_data.temp >= di->bm->temp_high) && |
650 | (di->batt_data.temp < | 650 | (di->batt_data.temp < |
651 | (di->bat->temp_over - di->t_hyst_lowhigh))) || | 651 | (di->bm->temp_over - di->t_hyst_lowhigh))) || |
652 | ((di->batt_data.temp > | 652 | ((di->batt_data.temp > |
653 | (di->bat->temp_under + di->t_hyst_lowhigh)) && | 653 | (di->bm->temp_under + di->t_hyst_lowhigh)) && |
654 | (di->batt_data.temp <= di->bat->temp_low))) { | 654 | (di->batt_data.temp <= di->bm->temp_low))) { |
655 | /* TEMP minor!!!!! */ | 655 | /* TEMP minor!!!!! */ |
656 | di->events.btemp_underover = false; | 656 | di->events.btemp_underover = false; |
657 | di->events.btemp_lowhigh = true; | 657 | di->events.btemp_lowhigh = true; |
658 | di->t_hyst_norm = di->bat->temp_hysteresis; | 658 | di->t_hyst_norm = di->bm->temp_hysteresis; |
659 | di->t_hyst_lowhigh = 0; | 659 | di->t_hyst_lowhigh = 0; |
660 | } else if (di->batt_data.temp <= di->bat->temp_under || | 660 | } else if (di->batt_data.temp <= di->bm->temp_under || |
661 | di->batt_data.temp >= di->bat->temp_over) { | 661 | di->batt_data.temp >= di->bm->temp_over) { |
662 | /* TEMP major!!!!! */ | 662 | /* TEMP major!!!!! */ |
663 | di->events.btemp_underover = true; | 663 | di->events.btemp_underover = true; |
664 | di->events.btemp_lowhigh = false; | 664 | di->events.btemp_lowhigh = false; |
665 | di->t_hyst_norm = 0; | 665 | di->t_hyst_norm = 0; |
666 | di->t_hyst_lowhigh = di->bat->temp_hysteresis; | 666 | di->t_hyst_lowhigh = di->bm->temp_hysteresis; |
667 | } else { | 667 | } else { |
668 | /* Within hysteresis */ | 668 | /* Within hysteresis */ |
669 | dev_dbg(di->dev, "Within hysteresis limit temp: %d " | 669 | dev_dbg(di->dev, "Within hysteresis limit temp: %d " |
@@ -682,12 +682,12 @@ static void abx500_chargalg_check_temp(struct abx500_chargalg *di) | |||
682 | */ | 682 | */ |
683 | static void abx500_chargalg_check_charger_voltage(struct abx500_chargalg *di) | 683 | static void abx500_chargalg_check_charger_voltage(struct abx500_chargalg *di) |
684 | { | 684 | { |
685 | if (di->chg_info.usb_volt > di->bat->chg_params->usb_volt_max) | 685 | if (di->chg_info.usb_volt > di->bm->chg_params->usb_volt_max) |
686 | di->chg_info.usb_chg_ok = false; | 686 | di->chg_info.usb_chg_ok = false; |
687 | else | 687 | else |
688 | di->chg_info.usb_chg_ok = true; | 688 | di->chg_info.usb_chg_ok = true; |
689 | 689 | ||
690 | if (di->chg_info.ac_volt > di->bat->chg_params->ac_volt_max) | 690 | if (di->chg_info.ac_volt > di->bm->chg_params->ac_volt_max) |
691 | di->chg_info.ac_chg_ok = false; | 691 | di->chg_info.ac_chg_ok = false; |
692 | else | 692 | else |
693 | di->chg_info.ac_chg_ok = true; | 693 | di->chg_info.ac_chg_ok = true; |
@@ -707,10 +707,10 @@ static void abx500_chargalg_end_of_charge(struct abx500_chargalg *di) | |||
707 | if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING && | 707 | if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING && |
708 | di->charge_state == STATE_NORMAL && | 708 | di->charge_state == STATE_NORMAL && |
709 | !di->maintenance_chg && (di->batt_data.volt >= | 709 | !di->maintenance_chg && (di->batt_data.volt >= |
710 | di->bat->bat_type[di->bat->batt_id].termination_vol || | 710 | di->bm->bat_type[di->bm->batt_id].termination_vol || |
711 | di->events.usb_cv_active || di->events.ac_cv_active) && | 711 | di->events.usb_cv_active || di->events.ac_cv_active) && |
712 | di->batt_data.avg_curr < | 712 | di->batt_data.avg_curr < |
713 | di->bat->bat_type[di->bat->batt_id].termination_curr && | 713 | di->bm->bat_type[di->bm->batt_id].termination_curr && |
714 | di->batt_data.avg_curr > 0) { | 714 | di->batt_data.avg_curr > 0) { |
715 | if (++di->eoc_cnt >= EOC_COND_CNT) { | 715 | if (++di->eoc_cnt >= EOC_COND_CNT) { |
716 | di->eoc_cnt = 0; | 716 | di->eoc_cnt = 0; |
@@ -733,12 +733,12 @@ static void abx500_chargalg_end_of_charge(struct abx500_chargalg *di) | |||
733 | static void init_maxim_chg_curr(struct abx500_chargalg *di) | 733 | static void init_maxim_chg_curr(struct abx500_chargalg *di) |
734 | { | 734 | { |
735 | di->ccm.original_iset = | 735 | di->ccm.original_iset = |
736 | di->bat->bat_type[di->bat->batt_id].normal_cur_lvl; | 736 | di->bm->bat_type[di->bm->batt_id].normal_cur_lvl; |
737 | di->ccm.current_iset = | 737 | di->ccm.current_iset = |
738 | di->bat->bat_type[di->bat->batt_id].normal_cur_lvl; | 738 | di->bm->bat_type[di->bm->batt_id].normal_cur_lvl; |
739 | di->ccm.test_delta_i = di->bat->maxi->charger_curr_step; | 739 | di->ccm.test_delta_i = di->bm->maxi->charger_curr_step; |
740 | di->ccm.max_current = di->bat->maxi->chg_curr; | 740 | di->ccm.max_current = di->bm->maxi->chg_curr; |
741 | di->ccm.condition_cnt = di->bat->maxi->wait_cycles; | 741 | di->ccm.condition_cnt = di->bm->maxi->wait_cycles; |
742 | di->ccm.level = 0; | 742 | di->ccm.level = 0; |
743 | } | 743 | } |
744 | 744 | ||
@@ -755,7 +755,7 @@ static enum maxim_ret abx500_chargalg_chg_curr_maxim(struct abx500_chargalg *di) | |||
755 | { | 755 | { |
756 | int delta_i; | 756 | int delta_i; |
757 | 757 | ||
758 | if (!di->bat->maxi->ena_maxi) | 758 | if (!di->bm->maxi->ena_maxi) |
759 | return MAXIM_RET_NOACTION; | 759 | return MAXIM_RET_NOACTION; |
760 | 760 | ||
761 | delta_i = di->ccm.original_iset - di->batt_data.inst_curr; | 761 | delta_i = di->ccm.original_iset - di->batt_data.inst_curr; |
@@ -766,7 +766,7 @@ static enum maxim_ret abx500_chargalg_chg_curr_maxim(struct abx500_chargalg *di) | |||
766 | if (di->ccm.wait_cnt == 0) { | 766 | if (di->ccm.wait_cnt == 0) { |
767 | dev_dbg(di->dev, "lowering current\n"); | 767 | dev_dbg(di->dev, "lowering current\n"); |
768 | di->ccm.wait_cnt++; | 768 | di->ccm.wait_cnt++; |
769 | di->ccm.condition_cnt = di->bat->maxi->wait_cycles; | 769 | di->ccm.condition_cnt = di->bm->maxi->wait_cycles; |
770 | di->ccm.max_current = | 770 | di->ccm.max_current = |
771 | di->ccm.current_iset - di->ccm.test_delta_i; | 771 | di->ccm.current_iset - di->ccm.test_delta_i; |
772 | di->ccm.current_iset = di->ccm.max_current; | 772 | di->ccm.current_iset = di->ccm.max_current; |
@@ -791,7 +791,7 @@ static enum maxim_ret abx500_chargalg_chg_curr_maxim(struct abx500_chargalg *di) | |||
791 | if (di->ccm.current_iset == di->ccm.original_iset) | 791 | if (di->ccm.current_iset == di->ccm.original_iset) |
792 | return MAXIM_RET_NOACTION; | 792 | return MAXIM_RET_NOACTION; |
793 | 793 | ||
794 | di->ccm.condition_cnt = di->bat->maxi->wait_cycles; | 794 | di->ccm.condition_cnt = di->bm->maxi->wait_cycles; |
795 | di->ccm.current_iset = di->ccm.original_iset; | 795 | di->ccm.current_iset = di->ccm.original_iset; |
796 | di->ccm.level = 0; | 796 | di->ccm.level = 0; |
797 | 797 | ||
@@ -803,7 +803,7 @@ static enum maxim_ret abx500_chargalg_chg_curr_maxim(struct abx500_chargalg *di) | |||
803 | di->ccm.max_current) { | 803 | di->ccm.max_current) { |
804 | if (di->ccm.condition_cnt-- == 0) { | 804 | if (di->ccm.condition_cnt-- == 0) { |
805 | /* Increse the iset with cco.test_delta_i */ | 805 | /* Increse the iset with cco.test_delta_i */ |
806 | di->ccm.condition_cnt = di->bat->maxi->wait_cycles; | 806 | di->ccm.condition_cnt = di->bm->maxi->wait_cycles; |
807 | di->ccm.current_iset += di->ccm.test_delta_i; | 807 | di->ccm.current_iset += di->ccm.test_delta_i; |
808 | di->ccm.level++; | 808 | di->ccm.level++; |
809 | dev_dbg(di->dev, " Maximization needed, increase" | 809 | dev_dbg(di->dev, " Maximization needed, increase" |
@@ -818,7 +818,7 @@ static enum maxim_ret abx500_chargalg_chg_curr_maxim(struct abx500_chargalg *di) | |||
818 | return MAXIM_RET_NOACTION; | 818 | return MAXIM_RET_NOACTION; |
819 | } | 819 | } |
820 | } else { | 820 | } else { |
821 | di->ccm.condition_cnt = di->bat->maxi->wait_cycles; | 821 | di->ccm.condition_cnt = di->bm->maxi->wait_cycles; |
822 | return MAXIM_RET_NOACTION; | 822 | return MAXIM_RET_NOACTION; |
823 | } | 823 | } |
824 | } | 824 | } |
@@ -838,7 +838,7 @@ static void handle_maxim_chg_curr(struct abx500_chargalg *di) | |||
838 | break; | 838 | break; |
839 | case MAXIM_RET_IBAT_TOO_HIGH: | 839 | case MAXIM_RET_IBAT_TOO_HIGH: |
840 | result = abx500_chargalg_update_chg_curr(di, | 840 | result = abx500_chargalg_update_chg_curr(di, |
841 | di->bat->bat_type[di->bat->batt_id].normal_cur_lvl); | 841 | di->bm->bat_type[di->bm->batt_id].normal_cur_lvl); |
842 | if (result) | 842 | if (result) |
843 | dev_err(di->dev, "failed to set chg curr\n"); | 843 | dev_err(di->dev, "failed to set chg curr\n"); |
844 | break; | 844 | break; |
@@ -1210,7 +1210,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1210 | * this way | 1210 | * this way |
1211 | */ | 1211 | */ |
1212 | if (!charger_status || | 1212 | if (!charger_status || |
1213 | (di->events.batt_unknown && !di->bat->chg_unknown_bat)) { | 1213 | (di->events.batt_unknown && !di->bm->chg_unknown_bat)) { |
1214 | if (di->charge_state != STATE_HANDHELD) { | 1214 | if (di->charge_state != STATE_HANDHELD) { |
1215 | di->events.safety_timer_expired = false; | 1215 | di->events.safety_timer_expired = false; |
1216 | abx500_chargalg_state_to(di, STATE_HANDHELD_INIT); | 1216 | abx500_chargalg_state_to(di, STATE_HANDHELD_INIT); |
@@ -1394,8 +1394,8 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1394 | 1394 | ||
1395 | case STATE_NORMAL_INIT: | 1395 | case STATE_NORMAL_INIT: |
1396 | abx500_chargalg_start_charging(di, | 1396 | abx500_chargalg_start_charging(di, |
1397 | di->bat->bat_type[di->bat->batt_id].normal_vol_lvl, | 1397 | di->bm->bat_type[di->bm->batt_id].normal_vol_lvl, |
1398 | di->bat->bat_type[di->bat->batt_id].normal_cur_lvl); | 1398 | di->bm->bat_type[di->bm->batt_id].normal_cur_lvl); |
1399 | abx500_chargalg_state_to(di, STATE_NORMAL); | 1399 | abx500_chargalg_state_to(di, STATE_NORMAL); |
1400 | abx500_chargalg_start_safety_timer(di); | 1400 | abx500_chargalg_start_safety_timer(di); |
1401 | abx500_chargalg_stop_maintenance_timer(di); | 1401 | abx500_chargalg_stop_maintenance_timer(di); |
@@ -1411,7 +1411,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1411 | handle_maxim_chg_curr(di); | 1411 | handle_maxim_chg_curr(di); |
1412 | if (di->charge_status == POWER_SUPPLY_STATUS_FULL && | 1412 | if (di->charge_status == POWER_SUPPLY_STATUS_FULL && |
1413 | di->maintenance_chg) { | 1413 | di->maintenance_chg) { |
1414 | if (di->bat->no_maintenance) | 1414 | if (di->bm->no_maintenance) |
1415 | abx500_chargalg_state_to(di, | 1415 | abx500_chargalg_state_to(di, |
1416 | STATE_WAIT_FOR_RECHARGE_INIT); | 1416 | STATE_WAIT_FOR_RECHARGE_INIT); |
1417 | else | 1417 | else |
@@ -1429,7 +1429,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1429 | 1429 | ||
1430 | case STATE_WAIT_FOR_RECHARGE: | 1430 | case STATE_WAIT_FOR_RECHARGE: |
1431 | if (di->batt_data.volt <= | 1431 | if (di->batt_data.volt <= |
1432 | di->bat->bat_type[di->bat->batt_id].recharge_vol) { | 1432 | di->bm->bat_type[di->bm->batt_id].recharge_vol) { |
1433 | if (di->rch_cnt-- == 0) | 1433 | if (di->rch_cnt-- == 0) |
1434 | abx500_chargalg_state_to(di, STATE_NORMAL_INIT); | 1434 | abx500_chargalg_state_to(di, STATE_NORMAL_INIT); |
1435 | } else | 1435 | } else |
@@ -1439,13 +1439,13 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1439 | case STATE_MAINTENANCE_A_INIT: | 1439 | case STATE_MAINTENANCE_A_INIT: |
1440 | abx500_chargalg_stop_safety_timer(di); | 1440 | abx500_chargalg_stop_safety_timer(di); |
1441 | abx500_chargalg_start_maintenance_timer(di, | 1441 | abx500_chargalg_start_maintenance_timer(di, |
1442 | di->bat->bat_type[ | 1442 | di->bm->bat_type[ |
1443 | di->bat->batt_id].maint_a_chg_timer_h); | 1443 | di->bm->batt_id].maint_a_chg_timer_h); |
1444 | abx500_chargalg_start_charging(di, | 1444 | abx500_chargalg_start_charging(di, |
1445 | di->bat->bat_type[ | 1445 | di->bm->bat_type[ |
1446 | di->bat->batt_id].maint_a_vol_lvl, | 1446 | di->bm->batt_id].maint_a_vol_lvl, |
1447 | di->bat->bat_type[ | 1447 | di->bm->bat_type[ |
1448 | di->bat->batt_id].maint_a_cur_lvl); | 1448 | di->bm->batt_id].maint_a_cur_lvl); |
1449 | abx500_chargalg_state_to(di, STATE_MAINTENANCE_A); | 1449 | abx500_chargalg_state_to(di, STATE_MAINTENANCE_A); |
1450 | power_supply_changed(&di->chargalg_psy); | 1450 | power_supply_changed(&di->chargalg_psy); |
1451 | /* Intentional fallthrough*/ | 1451 | /* Intentional fallthrough*/ |
@@ -1459,13 +1459,13 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1459 | 1459 | ||
1460 | case STATE_MAINTENANCE_B_INIT: | 1460 | case STATE_MAINTENANCE_B_INIT: |
1461 | abx500_chargalg_start_maintenance_timer(di, | 1461 | abx500_chargalg_start_maintenance_timer(di, |
1462 | di->bat->bat_type[ | 1462 | di->bm->bat_type[ |
1463 | di->bat->batt_id].maint_b_chg_timer_h); | 1463 | di->bm->batt_id].maint_b_chg_timer_h); |
1464 | abx500_chargalg_start_charging(di, | 1464 | abx500_chargalg_start_charging(di, |
1465 | di->bat->bat_type[ | 1465 | di->bm->bat_type[ |
1466 | di->bat->batt_id].maint_b_vol_lvl, | 1466 | di->bm->batt_id].maint_b_vol_lvl, |
1467 | di->bat->bat_type[ | 1467 | di->bm->bat_type[ |
1468 | di->bat->batt_id].maint_b_cur_lvl); | 1468 | di->bm->batt_id].maint_b_cur_lvl); |
1469 | abx500_chargalg_state_to(di, STATE_MAINTENANCE_B); | 1469 | abx500_chargalg_state_to(di, STATE_MAINTENANCE_B); |
1470 | power_supply_changed(&di->chargalg_psy); | 1470 | power_supply_changed(&di->chargalg_psy); |
1471 | /* Intentional fallthrough*/ | 1471 | /* Intentional fallthrough*/ |
@@ -1479,10 +1479,10 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di) | |||
1479 | 1479 | ||
1480 | case STATE_TEMP_LOWHIGH_INIT: | 1480 | case STATE_TEMP_LOWHIGH_INIT: |
1481 | abx500_chargalg_start_charging(di, | 1481 | abx500_chargalg_start_charging(di, |
1482 | di->bat->bat_type[ | 1482 | di->bm->bat_type[ |
1483 | di->bat->batt_id].low_high_vol_lvl, | 1483 | di->bm->batt_id].low_high_vol_lvl, |
1484 | di->bat->bat_type[ | 1484 | di->bm->bat_type[ |
1485 | di->bat->batt_id].low_high_cur_lvl); | 1485 | di->bm->batt_id].low_high_cur_lvl); |
1486 | abx500_chargalg_stop_maintenance_timer(di); | 1486 | abx500_chargalg_stop_maintenance_timer(di); |
1487 | di->charge_status = POWER_SUPPLY_STATUS_CHARGING; | 1487 | di->charge_status = POWER_SUPPLY_STATUS_CHARGING; |
1488 | abx500_chargalg_state_to(di, STATE_TEMP_LOWHIGH); | 1488 | abx500_chargalg_state_to(di, STATE_TEMP_LOWHIGH); |
@@ -1543,11 +1543,11 @@ static void abx500_chargalg_periodic_work(struct work_struct *work) | |||
1543 | if (di->chg_info.conn_chg) | 1543 | if (di->chg_info.conn_chg) |
1544 | queue_delayed_work(di->chargalg_wq, | 1544 | queue_delayed_work(di->chargalg_wq, |
1545 | &di->chargalg_periodic_work, | 1545 | &di->chargalg_periodic_work, |
1546 | di->bat->interval_charging * HZ); | 1546 | di->bm->interval_charging * HZ); |
1547 | else | 1547 | else |
1548 | queue_delayed_work(di->chargalg_wq, | 1548 | queue_delayed_work(di->chargalg_wq, |
1549 | &di->chargalg_periodic_work, | 1549 | &di->chargalg_periodic_work, |
1550 | di->bat->interval_not_charging * HZ); | 1550 | di->bm->interval_not_charging * HZ); |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | /** | 1553 | /** |
@@ -1614,7 +1614,7 @@ static int abx500_chargalg_get_property(struct power_supply *psy, | |||
1614 | if (di->events.batt_ovv) { | 1614 | if (di->events.batt_ovv) { |
1615 | val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; | 1615 | val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; |
1616 | } else if (di->events.btemp_underover) { | 1616 | } else if (di->events.btemp_underover) { |
1617 | if (di->batt_data.temp <= di->bat->temp_under) | 1617 | if (di->batt_data.temp <= di->bm->temp_under) |
1618 | val->intval = POWER_SUPPLY_HEALTH_COLD; | 1618 | val->intval = POWER_SUPPLY_HEALTH_COLD; |
1619 | else | 1619 | else |
1620 | val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; | 1620 | val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; |
@@ -1806,6 +1806,7 @@ static char *supply_interface[] = { | |||
1806 | static int abx500_chargalg_probe(struct platform_device *pdev) | 1806 | static int abx500_chargalg_probe(struct platform_device *pdev) |
1807 | { | 1807 | { |
1808 | struct device_node *np = pdev->dev.of_node; | 1808 | struct device_node *np = pdev->dev.of_node; |
1809 | struct abx500_bm_data *plat = pdev->dev.platform_data; | ||
1809 | struct abx500_chargalg *di; | 1810 | struct abx500_chargalg *di; |
1810 | int ret = 0; | 1811 | int ret = 0; |
1811 | 1812 | ||
@@ -1814,21 +1815,19 @@ static int abx500_chargalg_probe(struct platform_device *pdev) | |||
1814 | dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); | 1815 | dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); |
1815 | return -ENOMEM; | 1816 | return -ENOMEM; |
1816 | } | 1817 | } |
1817 | di->bat = pdev->mfd_cell->platform_data; | 1818 | |
1818 | if (!di->bat) { | 1819 | if (!plat) { |
1819 | if (np) { | 1820 | dev_err(&pdev->dev, "no battery management data supplied\n"); |
1820 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | 1821 | return -EINVAL; |
1821 | if (ret) { | 1822 | } |
1822 | dev_err(&pdev->dev, | 1823 | di->bm = plat; |
1823 | "failed to get battery information\n"); | 1824 | |
1824 | return ret; | 1825 | if (np) { |
1825 | } | 1826 | ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); |
1826 | } else { | 1827 | if (ret) { |
1827 | dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); | 1828 | dev_err(&pdev->dev, "failed to get battery information\n"); |
1828 | return -EINVAL; | 1829 | return ret; |
1829 | } | 1830 | } |
1830 | } else { | ||
1831 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | ||
1832 | } | 1831 | } |
1833 | 1832 | ||
1834 | /* get device struct */ | 1833 | /* get device struct */ |