Commit b0284de0 authored by Lee Jones's avatar Lee Jones

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: default avatarLee Jones <lee.jones@linaro.org>
parent 8e3a71e5
...@@ -452,7 +452,7 @@ struct abx500_bm_data ab8500_bm_data = { ...@@ -452,7 +452,7 @@ struct abx500_bm_data ab8500_bm_data = {
.fg_params = &fg, .fg_params = &fg,
}; };
int __devinit bmdevs_of_probe(struct device *dev, int __devinit ab8500_bm_of_probe(struct device *dev,
struct device_node *np, struct device_node *np,
struct abx500_bm_data **battery) struct abx500_bm_data **battery)
{ {
......
...@@ -78,7 +78,7 @@ struct ab8500_btemp_ranges { ...@@ -78,7 +78,7 @@ struct ab8500_btemp_ranges {
* @parent: Pointer to the struct ab8500 * @parent: Pointer to the struct ab8500
* @gpadc: Pointer to the struct gpadc * @gpadc: Pointer to the struct gpadc
* @fg: Pointer to the struct fg * @fg: Pointer to the struct fg
* @bat: Pointer to the abx500_bm platform data * @bm: Platform specific battery management information
* @btemp_psy: Structure for BTEMP specific battery properties * @btemp_psy: Structure for BTEMP specific battery properties
* @events: Structure for information about events triggered * @events: Structure for information about events triggered
* @btemp_ranges: Battery temperature range structure * @btemp_ranges: Battery temperature range structure
...@@ -95,7 +95,7 @@ struct ab8500_btemp { ...@@ -95,7 +95,7 @@ struct ab8500_btemp {
struct ab8500 *parent; struct ab8500 *parent;
struct ab8500_gpadc *gpadc; struct ab8500_gpadc *gpadc;
struct ab8500_fg *fg; struct ab8500_fg *fg;
struct abx500_bm_data *bat; struct abx500_bm_data *bm;
struct power_supply btemp_psy; struct power_supply btemp_psy;
struct ab8500_btemp_events events; struct ab8500_btemp_events events;
struct ab8500_btemp_ranges btemp_ranges; struct ab8500_btemp_ranges btemp_ranges;
...@@ -149,13 +149,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di, ...@@ -149,13 +149,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di,
return (450000 * (v_batctrl)) / (1800 - v_batctrl); return (450000 * (v_batctrl)) / (1800 - v_batctrl);
} }
if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL) { if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL) {
/* /*
* If the battery has internal NTC, we use the current * If the battery has internal NTC, we use the current
* source to calculate the resistance, 7uA or 20uA * source to calculate the resistance, 7uA or 20uA
*/ */
rbs = (v_batctrl * 1000 rbs = (v_batctrl * 1000
- di->bat->gnd_lift_resistance * inst_curr) - di->bm->gnd_lift_resistance * inst_curr)
/ di->curr_source; / di->curr_source;
} else { } else {
/* /*
...@@ -211,7 +211,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, ...@@ -211,7 +211,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
return 0; return 0;
/* Only do this for batteries with internal NTC */ /* Only do this for batteries with internal NTC */
if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) { if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) {
if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA) if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA)
curr = BAT_CTRL_7U_ENA; curr = BAT_CTRL_7U_ENA;
else else
...@@ -243,7 +243,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di, ...@@ -243,7 +243,7 @@ static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
__func__); __func__);
goto disable_curr_source; goto disable_curr_source;
} }
} else if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) { } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) {
dev_dbg(di->dev, "Disable BATCTRL curr source\n"); dev_dbg(di->dev, "Disable BATCTRL curr source\n");
/* Write 0 to the curr bits */ /* Write 0 to the curr bits */
...@@ -459,9 +459,9 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) ...@@ -459,9 +459,9 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
int rbat, rntc, vntc; int rbat, rntc, vntc;
u8 id; u8 id;
id = di->bat->batt_id; id = di->bm->batt_id;
if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
id != BATTERY_UNKNOWN) { id != BATTERY_UNKNOWN) {
rbat = ab8500_btemp_get_batctrl_res(di); rbat = ab8500_btemp_get_batctrl_res(di);
...@@ -476,8 +476,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) ...@@ -476,8 +476,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
} }
temp = ab8500_btemp_res_to_temp(di, temp = ab8500_btemp_res_to_temp(di,
di->bat->bat_type[id].r_to_t_tbl, di->bm->bat_type[id].r_to_t_tbl,
di->bat->bat_type[id].n_temp_tbl_elements, rbat); di->bm->bat_type[id].n_temp_tbl_elements, rbat);
} else { } else {
vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL);
if (vntc < 0) { if (vntc < 0) {
...@@ -493,8 +493,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) ...@@ -493,8 +493,8 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
rntc = 230000 * vntc / (VTVOUT_V - vntc); rntc = 230000 * vntc / (VTVOUT_V - vntc);
temp = ab8500_btemp_res_to_temp(di, temp = ab8500_btemp_res_to_temp(di,
di->bat->bat_type[id].r_to_t_tbl, di->bm->bat_type[id].r_to_t_tbl,
di->bat->bat_type[id].n_temp_tbl_elements, rntc); di->bm->bat_type[id].n_temp_tbl_elements, rntc);
prev = temp; prev = temp;
} }
dev_dbg(di->dev, "Battery temperature is %d\n", temp); dev_dbg(di->dev, "Battery temperature is %d\n", temp);
...@@ -515,7 +515,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) ...@@ -515,7 +515,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
u8 i; u8 i;
di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA; di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA;
di->bat->batt_id = BATTERY_UNKNOWN; di->bm->batt_id = BATTERY_UNKNOWN;
res = ab8500_btemp_get_batctrl_res(di); res = ab8500_btemp_get_batctrl_res(di);
if (res < 0) { if (res < 0) {
...@@ -524,23 +524,23 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) ...@@ -524,23 +524,23 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
} }
/* BATTERY_UNKNOWN is defined on position 0, skip it! */ /* BATTERY_UNKNOWN is defined on position 0, skip it! */
for (i = BATTERY_UNKNOWN + 1; i < di->bat->n_btypes; i++) { for (i = BATTERY_UNKNOWN + 1; i < di->bm->n_btypes; i++) {
if ((res <= di->bat->bat_type[i].resis_high) && if ((res <= di->bm->bat_type[i].resis_high) &&
(res >= di->bat->bat_type[i].resis_low)) { (res >= di->bm->bat_type[i].resis_low)) {
dev_dbg(di->dev, "Battery detected on %s" dev_dbg(di->dev, "Battery detected on %s"
" low %d < res %d < high: %d" " low %d < res %d < high: %d"
" index: %d\n", " index: %d\n",
di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL ? di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL ?
"BATCTRL" : "BATTEMP", "BATCTRL" : "BATTEMP",
di->bat->bat_type[i].resis_low, res, di->bm->bat_type[i].resis_low, res,
di->bat->bat_type[i].resis_high, i); di->bm->bat_type[i].resis_high, i);
di->bat->batt_id = i; di->bm->batt_id = i;
break; break;
} }
} }
if (di->bat->batt_id == BATTERY_UNKNOWN) { if (di->bm->batt_id == BATTERY_UNKNOWN) {
dev_warn(di->dev, "Battery identified as unknown" dev_warn(di->dev, "Battery identified as unknown"
", resistance %d Ohm\n", res); ", resistance %d Ohm\n", res);
return -ENXIO; return -ENXIO;
...@@ -550,13 +550,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di) ...@@ -550,13 +550,13 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
* We only have to change current source if the * We only have to change current source if the
* detected type is Type 1, else we use the 7uA source * detected type is Type 1, else we use the 7uA source
*/ */
if (di->bat->adc_therm == ABx500_ADC_THERM_BATCTRL && if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
di->bat->batt_id == 1) { di->bm->batt_id == 1) {
dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n"); dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n");
di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA; di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA;
} }
return di->bat->batt_id; return di->bm->batt_id;
} }
/** /**
...@@ -586,9 +586,9 @@ static void ab8500_btemp_periodic_work(struct work_struct *work) ...@@ -586,9 +586,9 @@ static void ab8500_btemp_periodic_work(struct work_struct *work)
} }
if (di->events.ac_conn || di->events.usb_conn) if (di->events.ac_conn || di->events.usb_conn)
interval = di->bat->temp_interval_chg; interval = di->bm->temp_interval_chg;
else else
interval = di->bat->temp_interval_nochg; interval = di->bm->temp_interval_nochg;
/* Schedule a new measurement */ /* Schedule a new measurement */
queue_delayed_work(di->btemp_wq, queue_delayed_work(di->btemp_wq,
...@@ -815,7 +815,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy, ...@@ -815,7 +815,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy,
val->intval = 1; val->intval = 1;
break; break;
case POWER_SUPPLY_PROP_TECHNOLOGY: case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = di->bat->bat_type[di->bat->batt_id].name; val->intval = di->bm->bat_type[di->bm->batt_id].name;
break; break;
case POWER_SUPPLY_PROP_TEMP: case POWER_SUPPLY_PROP_TEMP:
val->intval = ab8500_btemp_get_temp(di); val->intval = ab8500_btemp_get_temp(di);
...@@ -985,10 +985,10 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) ...@@ -985,10 +985,10 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
di->bat = pdev->mfd_cell->platform_data; di->bm = pdev->mfd_cell->platform_data;
if (!di->bat) { if (!di->bm) {
if (np) { if (np) {
ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to get battery information\n"); "failed to get battery information\n");
......
...@@ -189,7 +189,7 @@ struct ab8500_charger_usb_state { ...@@ -189,7 +189,7 @@ struct ab8500_charger_usb_state {
* @autopower_cfg platform specific power config support for "pwron after pwrloss" * @autopower_cfg platform specific power config support for "pwron after pwrloss"
* @parent: Pointer to the struct ab8500 * @parent: Pointer to the struct ab8500
* @gpadc: Pointer to the struct gpadc * @gpadc: Pointer to the struct gpadc
* @bat: Pointer to the abx500_bm platform data * @bm: Platform specific battery management information
* @flags: Structure for information about events triggered * @flags: Structure for information about events triggered
* @usb_state: Structure for usb stack information * @usb_state: Structure for usb stack information
* @ac_chg: AC charger power supply * @ac_chg: AC charger power supply
...@@ -226,7 +226,7 @@ struct ab8500_charger { ...@@ -226,7 +226,7 @@ struct ab8500_charger {
bool autopower_cfg; bool autopower_cfg;
struct ab8500 *parent; struct ab8500 *parent;
struct ab8500_gpadc *gpadc; struct ab8500_gpadc *gpadc;
struct abx500_bm_data *bat; struct abx500_bm_data *bm;
struct ab8500_charger_event_flags flags; struct ab8500_charger_event_flags flags;
struct ab8500_charger_usb_state usb_state; struct ab8500_charger_usb_state usb_state;
struct ux500_charger ac_chg; struct ux500_charger ac_chg;
...@@ -1034,7 +1034,7 @@ static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di, ...@@ -1034,7 +1034,7 @@ static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di,
int min_value; int min_value;
/* We should always use to lowest current limit */ /* We should always use to lowest current limit */
min_value = min(di->bat->chg_params->usb_curr_max, ich_in); min_value = min(di->bm->chg_params->usb_curr_max, ich_in);
switch (min_value) { switch (min_value) {
case 100: case 100:
...@@ -1176,7 +1176,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, ...@@ -1176,7 +1176,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
volt_index = ab8500_voltage_to_regval(vset); volt_index = ab8500_voltage_to_regval(vset);
curr_index = ab8500_current_to_regval(iset); curr_index = ab8500_current_to_regval(iset);
input_curr_index = ab8500_current_to_regval( input_curr_index = ab8500_current_to_regval(
di->bat->chg_params->ac_curr_max); di->bm->chg_params->ac_curr_max);
if (volt_index < 0 || curr_index < 0 || input_curr_index < 0) { if (volt_index < 0 || curr_index < 0 || input_curr_index < 0) {
dev_err(di->dev, dev_err(di->dev,
"Charger voltage or current too high, " "Charger voltage or current too high, "
...@@ -1193,7 +1193,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, ...@@ -1193,7 +1193,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
} }
/* MainChInputCurr: current that can be drawn from the charger*/ /* MainChInputCurr: current that can be drawn from the charger*/
ret = ab8500_charger_set_main_in_curr(di, ret = ab8500_charger_set_main_in_curr(di,
di->bat->chg_params->ac_curr_max); di->bm->chg_params->ac_curr_max);
if (ret) { if (ret) {
dev_err(di->dev, "%s Failed to set MainChInputCurr\n", dev_err(di->dev, "%s Failed to set MainChInputCurr\n",
__func__); __func__);
...@@ -1209,7 +1209,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger, ...@@ -1209,7 +1209,7 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
} }
/* Check if VBAT overshoot control should be enabled */ /* Check if VBAT overshoot control should be enabled */
if (!di->bat->enable_overshoot) if (!di->bm->enable_overshoot)
overshoot = MAIN_CH_NO_OVERSHOOT_ENA_N; overshoot = MAIN_CH_NO_OVERSHOOT_ENA_N;
/* Enable Main Charger */ /* Enable Main Charger */
...@@ -1376,7 +1376,7 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger, ...@@ -1376,7 +1376,7 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger,
return ret; return ret;
} }
/* Check if VBAT overshoot control should be enabled */ /* Check if VBAT overshoot control should be enabled */
if (!di->bat->enable_overshoot) if (!di->bm->enable_overshoot)
overshoot = USB_CHG_NO_OVERSHOOT_ENA_N; overshoot = USB_CHG_NO_OVERSHOOT_ENA_N;
/* Enable USB Charger */ /* Enable USB Charger */
...@@ -2454,8 +2454,8 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) ...@@ -2454,8 +2454,8 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di)
ret = abx500_set_register_interruptible(di->dev, ret = abx500_set_register_interruptible(di->dev,
AB8500_RTC, AB8500_RTC,
AB8500_RTC_BACKUP_CHG_REG, AB8500_RTC_BACKUP_CHG_REG,
di->bat->bkup_bat_v | di->bm->bkup_bat_v |
di->bat->bkup_bat_i); di->bm->bkup_bat_i);
if (ret) { if (ret) {
dev_err(di->dev, "failed to setup backup battery charging\n"); dev_err(di->dev, "failed to setup backup battery charging\n");
goto out; goto out;
...@@ -2644,10 +2644,10 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev) ...@@ -2644,10 +2644,10 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "%s no mem for ab8500_charger\n", __func__); dev_err(&pdev->dev, "%s no mem for ab8500_charger\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
di->bat = pdev->mfd_cell->platform_data; di->bm = pdev->mfd_cell->platform_data;
if (!di->bat) { if (!di->bm) {
if (np) { if (np) {
ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to get battery information\n"); "failed to get battery information\n");
......
This diff is collapsed.
This diff is collapsed.
...@@ -279,7 +279,7 @@ enum { ...@@ -279,7 +279,7 @@ enum {
NTC_INTERNAL, NTC_INTERNAL,
}; };
int bmdevs_of_probe(struct device *dev, int ab8500_bm_of_probe(struct device *dev,
struct device_node *np, struct device_node *np,
struct abx500_bm_data **battery); struct abx500_bm_data **battery);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment