aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/ab8500_btemp.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-11-30 05:09:42 -0500
committerLee Jones <lee.jones@linaro.org>2012-12-11 03:43:53 -0500
commitb0284de05e07d56ff7de154d0c9263788755f5eb (patch)
tree31821d80be26bdbc701f86192da26489d30c3d9a /drivers/power/ab8500_btemp.c
parent8e3a71e56c8c48862015ecf1ae0b9362dc28a453 (diff)
ab8500_bm: Rename battery management platform data to something more logical
The platform specific battery management configuration data structure is currently called 'bat' short for 'battery'; however, it contains information for all components of the battery management group, rather than information pertaining to the battery itself - there are other structures for that. So, in keeping with its structure namesake 'abx500_bm_data', we rename it to 'bm' here. Using similar logic, we're also renaming 'bmdevs_of_probe' to the more device specific 'ab8500_bm_of_probe'. Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/power/ab8500_btemp.c')
-rw-r--r--drivers/power/ab8500_btemp.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
index 5d1bf0bd6fa5..33ed0fccbd0e 100644
--- a/drivers/power/ab8500_btemp.c
+++ b/drivers/power/ab8500_btemp.c
@@ -78,7 +78,7 @@ 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
@@ -95,7 +95,7 @@ struct ab8500_btemp {
95 struct ab8500 *parent; 95 struct ab8500 *parent;
96 struct ab8500_gpadc *gpadc; 96 struct ab8500_gpadc *gpadc;
97 struct ab8500_fg *fg; 97 struct ab8500_fg *fg;
98 struct abx500_bm_data *bat; 98 struct abx500_bm_data *bm;
99 struct power_supply btemp_psy; 99 struct power_supply btemp_psy;
100 struct ab8500_btemp_events events; 100 struct ab8500_btemp_events events;
101 struct ab8500_btemp_ranges btemp_ranges; 101 struct ab8500_btemp_ranges btemp_ranges;
@@ -149,13 +149,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di,
149 return (450000 * (v_batctrl)) / (1800 - v_batctrl); 149 return (450000 * (v_batctrl)) / (1800 - v_batctrl);
150 } 150 }
151 151
152 if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL) { 152 if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL) {
153 /* 153 /*
154 * If the battery has internal NTC, we use the current 154 * If the battery has internal NTC, we use the current
155 * source to calculate the resistance, 7uA or 20uA 155 * source to calculate the resistance, 7uA or 20uA
156 */ 156 */
157 rbs = (v_batctrl * 1000 157 rbs = (v_batctrl * 1000
158 - di->bat->gnd_lift_resistance * inst_curr) 158 - di->bm->gnd_lift_resistance * inst_curr)
159 / di->curr_source; 159 / di->curr_source;
160 } else { 160 } else {
161 /* 161 /*
@@ -211,7 +211,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
211 return 0; 211 return 0;
212 212
213 /* Only do this for batteries with internal NTC */ 213 /* Only do this for batteries with internal NTC */
214 if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { 214 if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) {
215 if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) 215 if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA)
216 curr = BAT_CTRL_7U_ENA; 216 curr = BAT_CTRL_7U_ENA;
217 else 217 else
@@ -243,7 +243,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
243 __func__); 243 __func__);
244 goto disable_curr_source; 244 goto disable_curr_source;
245 } 245 }
246 } else if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { 246 } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) {
247 dev_dbg(di->dev, "Disable BATCTRL curr source\n"); 247 dev_dbg(di->dev, "Disable BATCTRL curr source\n");
248 248
249 /* Write 0 to the curr bits */ 249 /* Write 0 to the curr bits */
@@ -459,9 +459,9 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
459 int rbat, rntc, vntc; 459 int rbat, rntc, vntc;
460 u8 id; 460 u8 id;
461 461
462 id = di->bat->batt_id; 462 id = di->bm->batt_id;
463 463
464 if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && 464 if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
465 id != BATTERY_UNKNOWN) { 465 id != BATTERY_UNKNOWN) {
466 466
467 rbat = ab8500_btemp_get_batctrl_res(di); 467 rbat = ab8500_btemp_get_batctrl_res(di);
@@ -476,8 +476,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
476 } 476 }
477 477
478 temp = ab8500_btemp_res_to_temp(di, 478 temp = ab8500_btemp_res_to_temp(di,
479 di->bat->bat_type[id].r_to_t_tbl, 479 di->bm->bat_type[id].r_to_t_tbl,
480 di->bat->bat_type[id].n_temp_tbl_elements, rbat); 480 di->bm->bat_type[id].n_temp_tbl_elements, rbat);
481 } else { 481 } else {
482 vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); 482 vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL);
483 if (vntc < 0) { 483 if (vntc < 0) {
@@ -493,8 +493,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
493 rntc = 230000 * vntc / (VTVOUT_V - vntc); 493 rntc = 230000 * vntc / (VTVOUT_V - vntc);
494 494
495 temp = ab8500_btemp_res_to_temp(di, 495 temp = ab8500_btemp_res_to_temp(di,
496 di->bat->bat_type[id].r_to_t_tbl, 496 di->bm->bat_type[id].r_to_t_tbl,
497 di->bat->bat_type[id].n_temp_tbl_elements, rntc); 497 di->bm->bat_type[id].n_temp_tbl_elements, rntc);
498 prev = temp; 498 prev = temp;
499 } 499 }
500 dev_dbg(di->dev, "Battery temperature is %d\n", temp); 500 dev_dbg(di->dev, "Battery temperature is %d\n", temp);
@@ -515,7 +515,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
515 u8 i; 515 u8 i;
516 516
517 di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; 517 di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA;
518 di->bat->batt_id = BATTERY_UNKNOWN; 518 di->bm->batt_id = BATTERY_UNKNOWN;
519 519
520 res = ab8500_btemp_get_batctrl_res(di); 520 res = ab8500_btemp_get_batctrl_res(di);
521 if (res < 0) { 521 if (res < 0) {
@@ -524,23 +524,23 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
524 } 524 }
525 525
526 /* BATTERY_UNKNOWN is defined on position 0, skip it! */ 526 /* BATTERY_UNKNOWN is defined on position 0, skip it! */
527 for (i = BATTERY_UNKNOWN + 1; i < di->bat->n_btypes; i++) { 527 for (i = BATTERY_UNKNOWN + 1; i < di->bm->n_btypes; i++) {
528 if ((res <= di->bat->bat_type[i].resis_high) && 528 if ((res <= di->bm->bat_type[i].resis_high) &&
529 (res >= di->bat->bat_type[i].resis_low)) { 529 (res >= di->bm->bat_type[i].resis_low)) {
530 dev_dbg(di->dev, "Battery detected on %s" 530 dev_dbg(di->dev, "Battery detected on %s"
531 " low %d < res %d < high: %d" 531 " low %d < res %d < high: %d"
532 " index: %d\n", 532 " index: %d\n",
533 di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL ? 533 di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL ?
534 "BATCTRL" : "BATTEMP", 534 "BATCTRL" : "BATTEMP",
535 di->bat->bat_type[i].resis_low, res, 535 di->bm->bat_type[i].resis_low, res,
536 di->bat->bat_type[i].resis_high, i); 536 di->bm->bat_type[i].resis_high, i);
537 537
538 di->bat->batt_id = i; 538 di->bm->batt_id = i;
539 break; 539 break;
540 } 540 }
541 } 541 }
542 542
543 if (di->bat->batt_id == BATTERY_UNKNOWN) { 543 if (di->bm->batt_id == BATTERY_UNKNOWN) {
544 dev_warn(di->dev, "Battery identified as unknown" 544 dev_warn(di->dev, "Battery identified as unknown"
545 ", resistance %d Ohm\n", res); 545 ", resistance %d Ohm\n", res);
546 return -ENXIO; 546 return -ENXIO;
@@ -550,13 +550,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
550 * We only have to change current source if the 550 * We only have to change current source if the
551 * detected type is Type 1, else we use the 7uA source 551 * detected type is Type 1, else we use the 7uA source
552 */ 552 */
553 if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && 553 if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
554 di->bat->batt_id == 1) { 554 di->bm->batt_id == 1) {
555 dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); 555 dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n");
556 di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; 556 di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA;
557 } 557 }
558 558
559 return di->bat->batt_id; 559 return di->bm->batt_id;
560} 560}
561 561
562/** 562/**
@@ -586,9 +586,9 @@ static void ab8500_btemp_periodic_work(struct work_struct *work)
586 } 586 }
587 587
588 if (di->events.ac_conn || di->events.usb_conn) 588 if (di->events.ac_conn || di->events.usb_conn)
589 interval = di->bat->temp_interval_chg; 589 interval = di->bm->temp_interval_chg;
590 else 590 else
591 interval = di->bat->temp_interval_nochg; 591 interval = di->bm->temp_interval_nochg;
592 592
593 /* Schedule a new measurement */ 593 /* Schedule a new measurement */
594 queue_delayed_work(di->btemp_wq, 594 queue_delayed_work(di->btemp_wq,
@@ -815,7 +815,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy,
815 val->intval = 1; 815 val->intval = 1;
816 break; 816 break;
817 case POWER_SUPPLY_PROP_TECHNOLOGY: 817 case POWER_SUPPLY_PROP_TECHNOLOGY:
818 val->intval = di->bat->bat_type[di->bat->batt_id].name; 818 val->intval = di->bm->bat_type[di->bm->batt_id].name;
819 break; 819 break;
820 case POWER_SUPPLY_PROP_TEMP: 820 case POWER_SUPPLY_PROP_TEMP:
821 val->intval = ab8500_btemp_get_temp(di); 821 val->intval = ab8500_btemp_get_temp(di);
@@ -985,10 +985,10 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
985 dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); 985 dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__);
986 return -ENOMEM; 986 return -ENOMEM;
987 } 987 }
988 di->bat = pdev->mfd_cell->platform_data; 988 di->bm = pdev->mfd_cell->platform_data;
989 if (!di->bat) { 989 if (!di->bm) {
990 if (np) { 990 if (np) {
991 ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); 991 ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
992 if (ret) { 992 if (ret) {
993 dev_err(&pdev->dev, 993 dev_err(&pdev->dev,
994 "failed to get battery information\n"); 994 "failed to get battery information\n");