aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/ab8500_bmdata.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c
index 2623b16b47d1..df5a590d760e 100644
--- a/drivers/power/ab8500_bmdata.c
+++ b/drivers/power/ab8500_bmdata.c
@@ -456,38 +456,29 @@ int __devinit bmdevs_of_probe(struct device *dev,
456 struct device_node *np, 456 struct device_node *np,
457 struct abx500_bm_data **battery) 457 struct abx500_bm_data **battery)
458{ 458{
459 struct abx500_battery_type *btype; 459 struct batres_vs_temp *tmp_batres_tbl;
460 struct device_node *np_bat_supply; 460 struct device_node *np_bat_supply;
461 struct abx500_bm_data *bat; 461 struct abx500_bm_data *bat;
462 const char *btech; 462 const char *btech;
463 int i, thermistor; 463 int i;
464 464
465 *battery = &ab8500_bm_data; 465 *battery = &ab8500_bm_data;
466 466
467 /* get phandle to 'battery-info' node */ 467 /* get phandle to 'battery-info' node */
468 np_bat_supply = of_parse_phandle(np, "battery", 0); 468 np_bat_supply = of_parse_phandle(np, "battery", 0);
469 if (!np_bat_supply) { 469 if (!np_bat_supply) {
470 dev_err(dev, "missing property battery\n"); 470 dev_err(dev, "battery node or reference missing\n");
471 return -EINVAL; 471 return -EINVAL;
472 } 472 }
473 473
474 if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl"))
475 thermistor = NTC_INTERNAL;
476 else
477 thermistor = NTC_EXTERNAL;
478
479 bat = *battery;
480 if (thermistor == NTC_EXTERNAL) {
481 bat->n_btypes = 4;
482 bat->bat_type = bat_type_ext_thermistor;
483 bat->adc_therm = ABx500_ADC_THERM_BATTEMP;
484 }
485
486 btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); 474 btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL);
487 if (!btech) { 475 if (!btech) {
488 dev_warn(dev, "missing property battery-name/type\n"); 476 dev_warn(dev, "missing property battery-name/type\n");
489 return -EINVAL; 477 return -EINVAL;
490 } 478 }
479
480 bat = *battery;
481
491 if (strncmp(btech, "LION", 4) == 0) { 482 if (strncmp(btech, "LION", 4) == 0) {
492 bat->no_maintenance = true; 483 bat->no_maintenance = true;
493 bat->chg_unknown_bat = true; 484 bat->chg_unknown_bat = true;
@@ -498,20 +489,22 @@ int __devinit bmdevs_of_probe(struct device *dev,
498 bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; 489 bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200;
499 } 490 }
500 491
501 /* select the battery resolution table */ 492 if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) {
502 for (i = 0; i < bat->n_btypes; ++i) { 493 if (strncmp(btech, "LION", 4) == 0)
503 btype = (bat->bat_type + i); 494 tmp_batres_tbl = temp_to_batres_tbl_9100;
504 if (thermistor == NTC_EXTERNAL) { 495 else
505 btype->batres_tbl = 496 tmp_batres_tbl = temp_to_batres_tbl_thermistor;
506 temp_to_batres_tbl_ext_thermistor; 497 } else {
507 } else if (strncmp(btech, "LION", 4) == 0) { 498 bat->n_btypes = 4;
508 btype->batres_tbl = 499 bat->bat_type = bat_type_ext_thermistor;
509 temp_to_batres_tbl_9100; 500 bat->adc_therm = ABx500_ADC_THERM_BATTEMP;
510 } else { 501 tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor;
511 btype->batres_tbl =
512 temp_to_batres_tbl_thermistor;
513 }
514 } 502 }
503
504 /* select the battery resolution table */
505 for (i = 0; i < bat->n_btypes; ++i)
506 bat->bat_type[i]->batres_tbl = tmp_batres_tbl;
507
515 of_node_put(np_bat_supply); 508 of_node_put(np_bat_supply);
516 509
517 return 0; 510 return 0;