From f5695a39833a2946479f6215f3afc4f672333713 Mon Sep 17 00:00:00 2001 From: "Rajanikanth H.V" Date: Thu, 29 Nov 2012 00:57:45 +0530 Subject: ab8500: remove explicit handling of battery type property, battery-type shall be one of supported technology type instead blank - refer: Documentation/devicetree/bindings/power_supply/ab8500/fg.txt for the list supported types - this patch appends to ab8500 bm devs DT binding patch set ref: commit-id e0f1abeba5c2d8a2183566717d99294fd1a29c2e git://git.infradead.org/battery-2.6.git - promote ab8500_fg probe to happen before ab8500_btemp probe as btemp driver depends on fuelgauge list, ref: ab8500_fg_get(...) Signed-off-by: Rajanikanth H.V --- drivers/power/ab8500_bmdata.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index 03cc528425cb..f16b60cd67de 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -461,7 +461,6 @@ bmdevs_of_probe(struct device *dev, struct device_node *np_bat_supply; struct abx500_bm_data *bat; const char *btech; - char bat_tech[8]; int i, thermistor; *battery = &ab8500_bm_data; @@ -488,12 +487,9 @@ bmdevs_of_probe(struct device *dev, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); - strcpy(bat_tech, "UNKNOWN"); - } else { - strcpy(bat_tech, btech); + return -EINVAL; } - - if (strncmp(bat_tech, "LION", 4) == 0) { + if (strncmp(btech, "LION", 4) == 0) { bat->no_maintenance = true; bat->chg_unknown_bat = true; bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; @@ -508,7 +504,7 @@ bmdevs_of_probe(struct device *dev, if (thermistor == NTC_EXTERNAL) { btype->batres_tbl = temp_to_batres_tbl_ext_thermistor; - } else if (strncmp(bat_tech, "LION", 4) == 0) { + } else if (strncmp(btech, "LION", 4) == 0) { btype->batres_tbl = temp_to_batres_tbl_9100; } else { -- cgit v1.2.3 From 43dc4470e3c8465b438676484280b6e4187b78e4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 29 Nov 2012 15:26:22 +0000 Subject: ab8500_btemp: Fix crazy tabbing implementation Simple patch to rectify incorrect tabbing. Also adds some coding style clean-ups to make it easier to read. Signed-off-by: Lee Jones --- drivers/power/ab8500_bmdata.c | 457 +++++++++++++++++++++--------------------- 1 file changed, 229 insertions(+), 228 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index f16b60cd67de..2623b16b47d1 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[] = { }; static struct abx500_battery_type bat_type_thermistor[] = { -[BATTERY_UNKNOWN] = { - /* First element always represent the UNKNOWN battery */ - .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, - .resis_high = 0, - .resis_low = 0, - .battery_resistance = 300, - .charge_full_design = 612, - .nominal_voltage = 3700, - .termination_vol = 4050, - .termination_curr = 200, - .recharge_vol = 3990, - .normal_cur_lvl = 400, - .normal_vol_lvl = 4100, - .maint_a_cur_lvl = 400, - .maint_a_vol_lvl = 4050, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 400, - .maint_b_vol_lvl = 4000, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), - .r_to_t_tbl = temp_tbl, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), - .v_to_cap_tbl = cap_tbl, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, -{ - .name = POWER_SUPPLY_TECHNOLOGY_LIPO, - .resis_high = 53407, - .resis_low = 12500, - .battery_resistance = 300, - .charge_full_design = 900, - .nominal_voltage = 3600, - .termination_vol = 4150, - .termination_curr = 80, - .recharge_vol = 4130, - .normal_cur_lvl = 700, - .normal_vol_lvl = 4200, - .maint_a_cur_lvl = 600, - .maint_a_vol_lvl = 4150, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 600, - .maint_b_vol_lvl = 4100, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_A_thermistor), - .r_to_t_tbl = temp_tbl_A_thermistor, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_A_thermistor), - .v_to_cap_tbl = cap_tbl_A_thermistor, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, + [BATTERY_UNKNOWN] = { + /* First element always represent the UNKNOWN battery */ + .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, + .resis_high = 0, + .resis_low = 0, + .battery_resistance = 300, + .charge_full_design = 612, + .nominal_voltage = 3700, + .termination_vol = 4050, + .termination_curr = 200, + .recharge_vol = 3990, + .normal_cur_lvl = 400, + .normal_vol_lvl = 4100, + .maint_a_cur_lvl = 400, + .maint_a_vol_lvl = 4050, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 400, + .maint_b_vol_lvl = 4000, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), + .r_to_t_tbl = temp_tbl, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), + .v_to_cap_tbl = cap_tbl, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, + { + .name = POWER_SUPPLY_TECHNOLOGY_LIPO, + .resis_high = 53407, + .resis_low = 12500, + .battery_resistance = 300, + .charge_full_design = 900, + .nominal_voltage = 3600, + .termination_vol = 4150, + .termination_curr = 80, + .recharge_vol = 4130, + .normal_cur_lvl = 700, + .normal_vol_lvl = 4200, + .maint_a_cur_lvl = 600, + .maint_a_vol_lvl = 4150, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 600, + .maint_b_vol_lvl = 4100, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_A_thermistor), + .r_to_t_tbl = temp_tbl_A_thermistor, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_A_thermistor), + .v_to_cap_tbl = cap_tbl_A_thermistor, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, -}, -{ - .name = POWER_SUPPLY_TECHNOLOGY_LIPO, - .resis_high = 200000, - .resis_low = 82869, - .battery_resistance = 300, - .charge_full_design = 900, - .nominal_voltage = 3600, - .termination_vol = 4150, - .termination_curr = 80, - .recharge_vol = 4130, - .normal_cur_lvl = 700, - .normal_vol_lvl = 4200, - .maint_a_cur_lvl = 600, - .maint_a_vol_lvl = 4150, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 600, - .maint_b_vol_lvl = 4100, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_B_thermistor), - .r_to_t_tbl = temp_tbl_B_thermistor, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_B_thermistor), - .v_to_cap_tbl = cap_tbl_B_thermistor, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, + }, + { + .name = POWER_SUPPLY_TECHNOLOGY_LIPO, + .resis_high = 200000, + .resis_low = 82869, + .battery_resistance = 300, + .charge_full_design = 900, + .nominal_voltage = 3600, + .termination_vol = 4150, + .termination_curr = 80, + .recharge_vol = 4130, + .normal_cur_lvl = 700, + .normal_vol_lvl = 4200, + .maint_a_cur_lvl = 600, + .maint_a_vol_lvl = 4150, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 600, + .maint_b_vol_lvl = 4100, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl_B_thermistor), + .r_to_t_tbl = temp_tbl_B_thermistor, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_B_thermistor), + .v_to_cap_tbl = cap_tbl_B_thermistor, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, }; static struct abx500_battery_type bat_type_ext_thermistor[] = { -[BATTERY_UNKNOWN] = { - /* First element always represent the UNKNOWN battery */ - .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, - .resis_high = 0, - .resis_low = 0, - .battery_resistance = 300, - .charge_full_design = 612, - .nominal_voltage = 3700, - .termination_vol = 4050, - .termination_curr = 200, - .recharge_vol = 3990, - .normal_cur_lvl = 400, - .normal_vol_lvl = 4100, - .maint_a_cur_lvl = 400, - .maint_a_vol_lvl = 4050, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 400, - .maint_b_vol_lvl = 4000, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), - .r_to_t_tbl = temp_tbl, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), - .v_to_cap_tbl = cap_tbl, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, + [BATTERY_UNKNOWN] = { + /* First element always represent the UNKNOWN battery */ + .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, + .resis_high = 0, + .resis_low = 0, + .battery_resistance = 300, + .charge_full_design = 612, + .nominal_voltage = 3700, + .termination_vol = 4050, + .termination_curr = 200, + .recharge_vol = 3990, + .normal_cur_lvl = 400, + .normal_vol_lvl = 4100, + .maint_a_cur_lvl = 400, + .maint_a_vol_lvl = 4050, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 400, + .maint_b_vol_lvl = 4000, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), + .r_to_t_tbl = temp_tbl, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), + .v_to_cap_tbl = cap_tbl, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, /* * These are the batteries that doesn't have an internal NTC resistor to measure * its temperature. The temperature in this case is measure with a NTC placed * near the battery but on the PCB. */ -{ - .name = POWER_SUPPLY_TECHNOLOGY_LIPO, - .resis_high = 76000, - .resis_low = 53000, - .battery_resistance = 300, - .charge_full_design = 900, - .nominal_voltage = 3700, - .termination_vol = 4150, - .termination_curr = 100, - .recharge_vol = 4130, - .normal_cur_lvl = 700, - .normal_vol_lvl = 4200, - .maint_a_cur_lvl = 600, - .maint_a_vol_lvl = 4150, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 600, - .maint_b_vol_lvl = 4100, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), - .r_to_t_tbl = temp_tbl, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), - .v_to_cap_tbl = cap_tbl, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, -{ - .name = POWER_SUPPLY_TECHNOLOGY_LION, - .resis_high = 30000, - .resis_low = 10000, - .battery_resistance = 300, - .charge_full_design = 950, - .nominal_voltage = 3700, - .termination_vol = 4150, - .termination_curr = 100, - .recharge_vol = 4130, - .normal_cur_lvl = 700, - .normal_vol_lvl = 4200, - .maint_a_cur_lvl = 600, - .maint_a_vol_lvl = 4150, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 600, - .maint_b_vol_lvl = 4100, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), - .r_to_t_tbl = temp_tbl, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), - .v_to_cap_tbl = cap_tbl, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, -{ - .name = POWER_SUPPLY_TECHNOLOGY_LION, - .resis_high = 95000, - .resis_low = 76001, - .battery_resistance = 300, - .charge_full_design = 950, - .nominal_voltage = 3700, - .termination_vol = 4150, - .termination_curr = 100, - .recharge_vol = 4130, - .normal_cur_lvl = 700, - .normal_vol_lvl = 4200, - .maint_a_cur_lvl = 600, - .maint_a_vol_lvl = 4150, - .maint_a_chg_timer_h = 60, - .maint_b_cur_lvl = 600, - .maint_b_vol_lvl = 4100, - .maint_b_chg_timer_h = 200, - .low_high_cur_lvl = 300, - .low_high_vol_lvl = 4000, - .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), - .r_to_t_tbl = temp_tbl, - .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), - .v_to_cap_tbl = cap_tbl, - .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), - .batres_tbl = temp_to_batres_tbl_thermistor, -}, + { + .name = POWER_SUPPLY_TECHNOLOGY_LIPO, + .resis_high = 76000, + .resis_low = 53000, + .battery_resistance = 300, + .charge_full_design = 900, + .nominal_voltage = 3700, + .termination_vol = 4150, + .termination_curr = 100, + .recharge_vol = 4130, + .normal_cur_lvl = 700, + .normal_vol_lvl = 4200, + .maint_a_cur_lvl = 600, + .maint_a_vol_lvl = 4150, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 600, + .maint_b_vol_lvl = 4100, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), + .r_to_t_tbl = temp_tbl, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), + .v_to_cap_tbl = cap_tbl, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, + { + .name = POWER_SUPPLY_TECHNOLOGY_LION, + .resis_high = 30000, + .resis_low = 10000, + .battery_resistance = 300, + .charge_full_design = 950, + .nominal_voltage = 3700, + .termination_vol = 4150, + .termination_curr = 100, + .recharge_vol = 4130, + .normal_cur_lvl = 700, + .normal_vol_lvl = 4200, + .maint_a_cur_lvl = 600, + .maint_a_vol_lvl = 4150, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 600, + .maint_b_vol_lvl = 4100, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), + .r_to_t_tbl = temp_tbl, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), + .v_to_cap_tbl = cap_tbl, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, + { + .name = POWER_SUPPLY_TECHNOLOGY_LION, + .resis_high = 95000, + .resis_low = 76001, + .battery_resistance = 300, + .charge_full_design = 950, + .nominal_voltage = 3700, + .termination_vol = 4150, + .termination_curr = 100, + .recharge_vol = 4130, + .normal_cur_lvl = 700, + .normal_vol_lvl = 4200, + .maint_a_cur_lvl = 600, + .maint_a_vol_lvl = 4150, + .maint_a_chg_timer_h = 60, + .maint_b_cur_lvl = 600, + .maint_b_vol_lvl = 4100, + .maint_b_chg_timer_h = 200, + .low_high_cur_lvl = 300, + .low_high_vol_lvl = 4000, + .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl), + .r_to_t_tbl = temp_tbl, + .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl), + .v_to_cap_tbl = cap_tbl, + .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor), + .batres_tbl = temp_to_batres_tbl_thermistor, + }, }; static const struct abx500_bm_capacity_levels cap_levels = { @@ -424,42 +424,41 @@ static const struct abx500_bm_charger_parameters chg = { }; struct abx500_bm_data ab8500_bm_data = { - .temp_under = 3, - .temp_low = 8, - .temp_high = 43, - .temp_over = 48, - .main_safety_tmr_h = 4, - .temp_interval_chg = 20, - .temp_interval_nochg = 120, - .usb_safety_tmr_h = 4, - .bkup_bat_v = BUP_VCH_SEL_2P6V, - .bkup_bat_i = BUP_ICH_SEL_150UA, - .no_maintenance = false, - .adc_therm = ABx500_ADC_THERM_BATCTRL, - .chg_unknown_bat = false, - .enable_overshoot = false, - .fg_res = 100, - .cap_levels = &cap_levels, - .bat_type = bat_type_thermistor, - .n_btypes = 3, - .batt_id = 0, - .interval_charging = 5, - .interval_not_charging = 120, - .temp_hysteresis = 3, - .gnd_lift_resistance = 34, - .maxi = &maxi_params, - .chg_params = &chg, - .fg_params = &fg, + .temp_under = 3, + .temp_low = 8, + .temp_high = 43, + .temp_over = 48, + .main_safety_tmr_h = 4, + .temp_interval_chg = 20, + .temp_interval_nochg = 120, + .usb_safety_tmr_h = 4, + .bkup_bat_v = BUP_VCH_SEL_2P6V, + .bkup_bat_i = BUP_ICH_SEL_150UA, + .no_maintenance = false, + .adc_therm = ABx500_ADC_THERM_BATCTRL, + .chg_unknown_bat = false, + .enable_overshoot = false, + .fg_res = 100, + .cap_levels = &cap_levels, + .bat_type = bat_type_thermistor, + .n_btypes = 3, + .batt_id = 0, + .interval_charging = 5, + .interval_not_charging = 120, + .temp_hysteresis = 3, + .gnd_lift_resistance = 34, + .maxi = &maxi_params, + .chg_params = &chg, + .fg_params = &fg, }; -int __devinit -bmdevs_of_probe(struct device *dev, - struct device_node *np, - struct abx500_bm_data **battery) +int __devinit bmdevs_of_probe(struct device *dev, + struct device_node *np, + struct abx500_bm_data **battery) { - struct abx500_battery_type *btype; - struct device_node *np_bat_supply; - struct abx500_bm_data *bat; + struct abx500_battery_type *btype; + struct device_node *np_bat_supply; + struct abx500_bm_data *bat; const char *btech; int i, thermistor; @@ -471,8 +470,8 @@ bmdevs_of_probe(struct device *dev, dev_err(dev, "missing property battery\n"); return -EINVAL; } - if (of_property_read_bool(np_bat_supply, - "thermistor-on-batctrl")) + + if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) thermistor = NTC_INTERNAL; else thermistor = NTC_EXTERNAL; @@ -483,8 +482,8 @@ bmdevs_of_probe(struct device *dev, bat->bat_type = bat_type_ext_thermistor; bat->adc_therm = ABx500_ADC_THERM_BATTEMP; } - btech = of_get_property(np_bat_supply, - "stericsson,battery-type", NULL); + + btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); return -EINVAL; @@ -498,6 +497,7 @@ bmdevs_of_probe(struct device *dev, bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } + /* select the battery resolution table */ for (i = 0; i < bat->n_btypes; ++i) { btype = (bat->bat_type + i); @@ -513,5 +513,6 @@ bmdevs_of_probe(struct device *dev, } } of_node_put(np_bat_supply); + return 0; } -- cgit v1.2.3 From 8e3a71e56c8c48862015ecf1ae0b9362dc28a453 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 30 Nov 2012 09:16:40 +0000 Subject: ab8500-bmdata: Re-jiggle bmdevs_of_probe to be more succinct We can actually write bmdevs_of_probe to be easier to follow, use less lines of code and we can even render a variable unused so that we can remove it completely. Signed-off-by: Lee Jones --- drivers/power/ab8500_bmdata.c | 49 +++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') 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, struct device_node *np, struct abx500_bm_data **battery) { - struct abx500_battery_type *btype; + struct batres_vs_temp *tmp_batres_tbl; struct device_node *np_bat_supply; struct abx500_bm_data *bat; const char *btech; - int i, thermistor; + int i; *battery = &ab8500_bm_data; /* get phandle to 'battery-info' node */ np_bat_supply = of_parse_phandle(np, "battery", 0); if (!np_bat_supply) { - dev_err(dev, "missing property battery\n"); + dev_err(dev, "battery node or reference missing\n"); return -EINVAL; } - if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) - thermistor = NTC_INTERNAL; - else - thermistor = NTC_EXTERNAL; - - bat = *battery; - if (thermistor == NTC_EXTERNAL) { - bat->n_btypes = 4; - bat->bat_type = bat_type_ext_thermistor; - bat->adc_therm = ABx500_ADC_THERM_BATTEMP; - } - btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); return -EINVAL; } + + bat = *battery; + if (strncmp(btech, "LION", 4) == 0) { bat->no_maintenance = true; bat->chg_unknown_bat = true; @@ -498,20 +489,22 @@ int __devinit bmdevs_of_probe(struct device *dev, bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } - /* select the battery resolution table */ - for (i = 0; i < bat->n_btypes; ++i) { - btype = (bat->bat_type + i); - if (thermistor == NTC_EXTERNAL) { - btype->batres_tbl = - temp_to_batres_tbl_ext_thermistor; - } else if (strncmp(btech, "LION", 4) == 0) { - btype->batres_tbl = - temp_to_batres_tbl_9100; - } else { - btype->batres_tbl = - temp_to_batres_tbl_thermistor; - } + if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) { + if (strncmp(btech, "LION", 4) == 0) + tmp_batres_tbl = temp_to_batres_tbl_9100; + else + tmp_batres_tbl = temp_to_batres_tbl_thermistor; + } else { + bat->n_btypes = 4; + bat->bat_type = bat_type_ext_thermistor; + bat->adc_therm = ABx500_ADC_THERM_BATTEMP; + tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor; } + + /* select the battery resolution table */ + for (i = 0; i < bat->n_btypes; ++i) + bat->bat_type[i]->batres_tbl = tmp_batres_tbl; + of_node_put(np_bat_supply); return 0; -- cgit v1.2.3 From b0284de05e07d56ff7de154d0c9263788755f5eb Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 30 Nov 2012 10:09:42 +0000 Subject: 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 --- drivers/power/ab8500_bmdata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index df5a590d760e..c2fb2c554019 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -452,9 +452,9 @@ struct abx500_bm_data ab8500_bm_data = { .fg_params = &fg, }; -int __devinit bmdevs_of_probe(struct device *dev, - struct device_node *np, - struct abx500_bm_data **battery) +int __devinit ab8500_bm_of_probe(struct device *dev, + struct device_node *np, + struct abx500_bm_data **battery) { struct batres_vs_temp *tmp_batres_tbl; struct device_node *np_bat_supply; -- cgit v1.2.3 From 23a04f9f40f2b32ee593b768483105b1c776814d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 29 Nov 2012 15:08:41 +0000 Subject: ab8500_bm: Always send platform specific battery information via pdata Currently the AB8500 battery management subsystem receives platform specific information via two different means depending on how the platform is booted. If DT is not enabled, a reference to a *_bm_data data structure containing each platform specific attribute is passed though platform_data. However, if DT is enabled, then platform_data is empty and the reference is gained though a DT specific probe function. There are two issues here 1) the same reference is being collected each time and 2) the DT way doesn't allow any provisions to select different platform specific attributes, which kind of defeats the object. Cc: Samuel Ortiz Signed-off-by: Lee Jones --- drivers/power/ab8500_bmdata.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index c2fb2c554019..6b772e5f515f 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -454,16 +454,13 @@ struct abx500_bm_data ab8500_bm_data = { int __devinit ab8500_bm_of_probe(struct device *dev, struct device_node *np, - struct abx500_bm_data **battery) + struct abx500_bm_data *bm) { struct batres_vs_temp *tmp_batres_tbl; struct device_node *np_bat_supply; - struct abx500_bm_data *bat; const char *btech; int i; - *battery = &ab8500_bm_data; - /* get phandle to 'battery-info' node */ np_bat_supply = of_parse_phandle(np, "battery", 0); if (!np_bat_supply) { @@ -477,16 +474,14 @@ int __devinit ab8500_bm_of_probe(struct device *dev, return -EINVAL; } - bat = *battery; - if (strncmp(btech, "LION", 4) == 0) { - bat->no_maintenance = true; - bat->chg_unknown_bat = true; - bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; - bat->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; - bat->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; - bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; - bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; + bm->no_maintenance = true; + bm->chg_unknown_bat = true; + bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; + bm->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; + bm->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; + bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; + bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) { @@ -495,15 +490,15 @@ int __devinit ab8500_bm_of_probe(struct device *dev, else tmp_batres_tbl = temp_to_batres_tbl_thermistor; } else { - bat->n_btypes = 4; - bat->bat_type = bat_type_ext_thermistor; - bat->adc_therm = ABx500_ADC_THERM_BATTEMP; - tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor; + bm->n_btypes = 4; + bm->bat_type = bat_type_ext_thermistor; + bm->adc_therm = ABx500_ADC_THERM_BATTEMP; + tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor; } /* select the battery resolution table */ - for (i = 0; i < bat->n_btypes; ++i) - bat->bat_type[i]->batres_tbl = tmp_batres_tbl; + for (i = 0; i < bm->n_btypes; ++i) + bm->bat_type[i].batres_tbl = tmp_batres_tbl; of_node_put(np_bat_supply); -- cgit v1.2.3 From 215cf5c93d2deda4df38d0c9b2429ab2e86808a5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 30 Nov 2012 11:38:52 +0000 Subject: ab8500_bm: Make the battery Device Tree node reference less cryptic Let's rename the Device Tree node which contains information about an attached battery to something more easily readable. Signed-off-by: Lee Jones --- drivers/power/ab8500_bmdata.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index 6b772e5f515f..0bf52369d6a5 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -457,18 +457,18 @@ int __devinit ab8500_bm_of_probe(struct device *dev, struct abx500_bm_data *bm) { struct batres_vs_temp *tmp_batres_tbl; - struct device_node *np_bat_supply; + struct device_node *battery_node; const char *btech; int i; /* get phandle to 'battery-info' node */ - np_bat_supply = of_parse_phandle(np, "battery", 0); - if (!np_bat_supply) { + battery_node = of_parse_phandle(np, "battery", 0); + if (!battery_node) { dev_err(dev, "battery node or reference missing\n"); return -EINVAL; } - btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); + btech = of_get_property(battery_node, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); return -EINVAL; @@ -484,7 +484,7 @@ int __devinit ab8500_bm_of_probe(struct device *dev, bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } - if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) { + if (of_property_read_bool(battery_node, "thermistor-on-batctrl")) { if (strncmp(btech, "LION", 4) == 0) tmp_batres_tbl = temp_to_batres_tbl_9100; else @@ -500,7 +500,7 @@ int __devinit ab8500_bm_of_probe(struct device *dev, for (i = 0; i < bm->n_btypes; ++i) bm->bat_type[i].batres_tbl = tmp_batres_tbl; - of_node_put(np_bat_supply); + of_node_put(battery_node); return 0; } -- cgit v1.2.3 From ea4024017831d61874351defe8f8c58ae73f8009 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Fri, 11 Jan 2013 13:12:54 +0000 Subject: ab8500_bm: Recharge condition not optimal for battery Today the battery recharge is determined with a voltage threshold. This voltage threshold is only valid when the battery is relaxed. In charging algorithm the voltage read is the loaded battery voltage and no compensation is done to get the relaxed voltage. When maintenance charging is not selected, this makes the recharging condition to almost immediately activate when there is a discharge present on the battery. Depending on which vendor the battery comes from this behavior can wear out the battery much faster than normal. The fuelgauge driver is responsible to monitor the actual battery capacity and is able to estimate the remaining capacity. It is better to use the remaining capacity as a limit to determine when battery should be recharged. Signed-off-by: Lee Jones Signed-off-by: Marcus Cooper Reviewed-by: Hakan BERG Reviewed-by: Jonas ABERG Signed-off-by: Anton Vorontsov --- drivers/power/ab8500_bmdata.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/power/ab8500_bmdata.c') diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index 0bf52369d6a5..20c157b4fe99 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -192,7 +192,7 @@ static struct abx500_battery_type bat_type_thermistor[] = { .nominal_voltage = 3700, .termination_vol = 4050, .termination_curr = 200, - .recharge_vol = 3990, + .recharge_cap = 95, .normal_cur_lvl = 400, .normal_vol_lvl = 4100, .maint_a_cur_lvl = 400, @@ -219,7 +219,7 @@ static struct abx500_battery_type bat_type_thermistor[] = { .nominal_voltage = 3600, .termination_vol = 4150, .termination_curr = 80, - .recharge_vol = 4130, + .recharge_cap = 95, .normal_cur_lvl = 700, .normal_vol_lvl = 4200, .maint_a_cur_lvl = 600, @@ -247,7 +247,7 @@ static struct abx500_battery_type bat_type_thermistor[] = { .nominal_voltage = 3600, .termination_vol = 4150, .termination_curr = 80, - .recharge_vol = 4130, + .recharge_cap = 95, .normal_cur_lvl = 700, .normal_vol_lvl = 4200, .maint_a_cur_lvl = 600, @@ -278,7 +278,7 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = { .nominal_voltage = 3700, .termination_vol = 4050, .termination_curr = 200, - .recharge_vol = 3990, + .recharge_cap = 95, .normal_cur_lvl = 400, .normal_vol_lvl = 4100, .maint_a_cur_lvl = 400, @@ -310,7 +310,7 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = { .nominal_voltage = 3700, .termination_vol = 4150, .termination_curr = 100, - .recharge_vol = 4130, + .recharge_cap = 95, .normal_cur_lvl = 700, .normal_vol_lvl = 4200, .maint_a_cur_lvl = 600, @@ -337,7 +337,7 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = { .nominal_voltage = 3700, .termination_vol = 4150, .termination_curr = 100, - .recharge_vol = 4130, + .recharge_cap = 95, .normal_cur_lvl = 700, .normal_vol_lvl = 4200, .maint_a_cur_lvl = 600, @@ -364,7 +364,7 @@ static struct abx500_battery_type bat_type_ext_thermistor[] = { .nominal_voltage = 3700, .termination_vol = 4150, .termination_curr = 100, - .recharge_vol = 4130, + .recharge_cap = 95, .normal_cur_lvl = 700, .normal_vol_lvl = 4200, .maint_a_cur_lvl = 600, @@ -405,8 +405,8 @@ static const struct abx500_fg_parameters fg = { .lowbat_threshold = 3100, .battok_falling_th_sel0 = 2860, .battok_raising_th_sel1 = 2860, + .maint_thres = 95, .user_cap_limit = 15, - .maint_thres = 97, }; static const struct abx500_maxim_parameters maxi_params = { @@ -435,6 +435,7 @@ struct abx500_bm_data ab8500_bm_data = { .bkup_bat_v = BUP_VCH_SEL_2P6V, .bkup_bat_i = BUP_ICH_SEL_150UA, .no_maintenance = false, + .capacity_scaling = false, .adc_therm = ABx500_ADC_THERM_BATCTRL, .chg_unknown_bat = false, .enable_overshoot = false, @@ -479,7 +480,7 @@ int __devinit ab8500_bm_of_probe(struct device *dev, bm->chg_unknown_bat = true; bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; bm->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; - bm->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; + bm->bat_type[BATTERY_UNKNOWN].recharge_cap = 95; bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } -- cgit v1.2.3