diff options
author | Michel JAOUEN <michel.jaouen@stericsson.com> | 2012-05-22 09:46:46 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-01-23 06:33:04 -0500 |
commit | e6aac611b86956bdd981f30e8862ee2ac8aaf664 (patch) | |
tree | a76481d688f259373570fb3a7c070bcd3e31ce5f /drivers/power | |
parent | 75f2a219ff11e6707903194009656820bba2d5c6 (diff) |
ab8500-btemp: Adaptation to AB8505 and AB9540 platforms
Add AB9540 and AB8505 support to ABx500 BTEMP driver.
Signed-off-by: Rajkumar Kasirajan <rajkumar.kasirajan@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Michel JAOUEN <michel.jaouen@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Tested-by: Michel JAOUEN <michel.jaouen@stericsson.com>
Tested-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/ab8500_btemp.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 8ccf3590fd76..301a9ad3474d 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c | |||
@@ -39,6 +39,9 @@ | |||
39 | #define BTEMP_BATCTRL_CURR_SRC_7UA 7 | 39 | #define BTEMP_BATCTRL_CURR_SRC_7UA 7 |
40 | #define BTEMP_BATCTRL_CURR_SRC_20UA 20 | 40 | #define BTEMP_BATCTRL_CURR_SRC_20UA 20 |
41 | 41 | ||
42 | #define BTEMP_BATCTRL_CURR_SRC_16UA 16 | ||
43 | #define BTEMP_BATCTRL_CURR_SRC_18UA 18 | ||
44 | |||
42 | #define to_ab8500_btemp_device_info(x) container_of((x), \ | 45 | #define to_ab8500_btemp_device_info(x) container_of((x), \ |
43 | struct ab8500_btemp, btemp_psy); | 46 | struct ab8500_btemp, btemp_psy); |
44 | 47 | ||
@@ -212,10 +215,18 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, | |||
212 | 215 | ||
213 | /* Only do this for batteries with internal NTC */ | 216 | /* Only do this for batteries with internal NTC */ |
214 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { | 217 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { |
215 | if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) | 218 | |
216 | curr = BAT_CTRL_7U_ENA; | 219 | if (is_ab9540(di->parent) || is_ab8505(di->parent)) { |
217 | else | 220 | if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_16UA) |
218 | curr = BAT_CTRL_20U_ENA; | 221 | curr = BAT_CTRL_16U_ENA; |
222 | else | ||
223 | curr = BAT_CTRL_18U_ENA; | ||
224 | } else { | ||
225 | if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) | ||
226 | curr = BAT_CTRL_7U_ENA; | ||
227 | else | ||
228 | curr = BAT_CTRL_20U_ENA; | ||
229 | } | ||
219 | 230 | ||
220 | dev_dbg(di->dev, "Set BATCTRL %duA\n", di->curr_source); | 231 | dev_dbg(di->dev, "Set BATCTRL %duA\n", di->curr_source); |
221 | 232 | ||
@@ -246,11 +257,22 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, | |||
246 | } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { | 257 | } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { |
247 | dev_dbg(di->dev, "Disable BATCTRL curr source\n"); | 258 | dev_dbg(di->dev, "Disable BATCTRL curr source\n"); |
248 | 259 | ||
249 | /* Write 0 to the curr bits */ | 260 | if (is_ab9540(di->parent) || is_ab8505(di->parent)) { |
250 | ret = abx500_mask_and_set_register_interruptible(di->dev, | 261 | /* Write 0 to the curr bits */ |
251 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, | 262 | ret = abx500_mask_and_set_register_interruptible( |
252 | BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA, | 263 | di->dev, |
253 | ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA)); | 264 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, |
265 | BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA, | ||
266 | ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA)); | ||
267 | } else { | ||
268 | /* Write 0 to the curr bits */ | ||
269 | ret = abx500_mask_and_set_register_interruptible( | ||
270 | di->dev, | ||
271 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, | ||
272 | BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA, | ||
273 | ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA)); | ||
274 | } | ||
275 | |||
254 | if (ret) { | 276 | if (ret) { |
255 | dev_err(di->dev, "%s failed disabling current source\n", | 277 | dev_err(di->dev, "%s failed disabling current source\n", |
256 | __func__); | 278 | __func__); |
@@ -292,11 +314,20 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, | |||
292 | * if we got an error above | 314 | * if we got an error above |
293 | */ | 315 | */ |
294 | disable_curr_source: | 316 | disable_curr_source: |
295 | /* Write 0 to the curr bits */ | 317 | if (is_ab9540(di->parent) || is_ab8505(di->parent)) { |
296 | ret = abx500_mask_and_set_register_interruptible(di->dev, | 318 | /* Write 0 to the curr bits */ |
319 | ret = abx500_mask_and_set_register_interruptible(di->dev, | ||
320 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, | ||
321 | BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA, | ||
322 | ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA)); | ||
323 | } else { | ||
324 | /* Write 0 to the curr bits */ | ||
325 | ret = abx500_mask_and_set_register_interruptible(di->dev, | ||
297 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, | 326 | AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE, |
298 | BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA, | 327 | BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA, |
299 | ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA)); | 328 | ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA)); |
329 | } | ||
330 | |||
300 | if (ret) { | 331 | if (ret) { |
301 | dev_err(di->dev, "%s failed disabling current source\n", | 332 | dev_err(di->dev, "%s failed disabling current source\n", |
302 | __func__); | 333 | __func__); |
@@ -510,8 +541,11 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) | |||
510 | { | 541 | { |
511 | int res; | 542 | int res; |
512 | u8 i; | 543 | u8 i; |
544 | if (is_ab9540(di->parent) || is_ab8505(di->parent)) | ||
545 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA; | ||
546 | else | ||
547 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; | ||
513 | 548 | ||
514 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; | ||
515 | di->bm->batt_id = BATTERY_UNKNOWN; | 549 | di->bm->batt_id = BATTERY_UNKNOWN; |
516 | 550 | ||
517 | res = ab8500_btemp_get_batctrl_res(di); | 551 | res = ab8500_btemp_get_batctrl_res(di); |
@@ -549,8 +583,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) | |||
549 | */ | 583 | */ |
550 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && | 584 | if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && |
551 | di->bm->batt_id == 1) { | 585 | di->bm->batt_id == 1) { |
552 | dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); | 586 | if (is_ab9540(di->parent) || is_ab8505(di->parent)) { |
553 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; | 587 | dev_dbg(di->dev, "Set BATCTRL current source to 16uA\n"); |
588 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA; | ||
589 | } else { | ||
590 | dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); | ||
591 | di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; | ||
592 | } | ||
554 | } | 593 | } |
555 | 594 | ||
556 | return di->bm->batt_id; | 595 | return di->bm->batt_id; |