* struct ab8500_battery_type - different batteries supported
* @resis_high: battery upper resistance limit
* @resis_low: battery lower resistance limit
- * @nominal_voltage: Nominal voltage of the battery in mV
- * @termination_vol: max voltage upto which battery can be charged
* @termination_curr battery charging termination current in mA
* @recharge_cap battery capacity limit that will trigger a new
* full charging cycle in the case where maintenan-
struct ab8500_battery_type {
int resis_high;
int resis_low;
- int nominal_voltage;
- int termination_vol;
int termination_curr;
int recharge_cap;
int normal_cur_lvl;
.resis_high = 0,
.resis_low = 0,
.battery_resistance = 300,
- .nominal_voltage = 3700,
- .termination_vol = 4050,
.termination_curr = 200,
.recharge_cap = 95,
.normal_cur_lvl = 400,
if (bi->charge_full_design_uah < 0)
/* The default capacity is 612 mAh for unknown batteries */
bi->charge_full_design_uah = 612000;
+
+ /*
+ * All of these voltages need to be specified or we will simply
+ * fall back to safe defaults.
+ */
+ if ((bi->voltage_min_design_uv < 0) ||
+ (bi->voltage_max_design_uv < 0) ||
+ (bi->overvoltage_limit_uv < 0)) {
+ /* Nominal voltage is 3.7V for unknown batteries */
+ bi->voltage_min_design_uv = 3700000;
+ bi->voltage_max_design_uv = 3700000;
+ /* Termination voltage (overcharge limit) 4.05V */
+ bi->overvoltage_limit_uv = 4050000;
+ }
+
if (bi->temp_min == INT_MIN)
bi->temp_min = AB8500_TEMP_UNDER;
if (bi->temp_max == INT_MAX)
struct ab8500_chargalg_battery_data {
int temp;
- int volt;
+ int volt_uv;
int avg_curr;
int inst_curr;
int percent;
{
if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING &&
di->charge_state == STATE_NORMAL &&
- !di->maintenance_chg && (di->batt_data.volt >=
- di->bm->bat_type->termination_vol ||
+ !di->maintenance_chg && (di->batt_data.volt_uv >=
+ di->bm->bi.overvoltage_limit_uv ||
di->events.usb_cv_active || di->events.ac_cv_active) &&
di->batt_data.avg_curr <
di->bm->bat_type->termination_curr &&
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
switch (ext->desc->type) {
case POWER_SUPPLY_TYPE_BATTERY:
- di->batt_data.volt = ret.intval / 1000;
+ di->batt_data.volt_uv = ret.intval;
break;
case POWER_SUPPLY_TYPE_MAINS:
di->chg_info.ac_volt = ret.intval / 1000;
"State %s Active_chg %d Chg_status %d AC %d USB %d "
"AC_online %d USB_online %d AC_CV %d USB_CV %d AC_I %d "
"USB_I %d AC_Vset %d AC_Iset %d USB_Vset %d USB_Iset %d\n",
- di->batt_data.volt,
+ di->batt_data.volt_uv,
di->batt_data.avg_curr,
di->batt_data.inst_curr,
di->batt_data.temp,
* @node: a list of AB8500 FGs, hence prepared for reentrance
* @irq holds the CCEOC interrupt number
* @vbat: Battery voltage in mV
- * @vbat_nom: Nominal battery voltage in mV
+ * @vbat_nom_uv: Nominal battery voltage in uV
* @inst_curr: Instantenous battery current in mA
* @avg_curr: Average battery current in mA
* @bat_temp battery temperature
struct list_head node;
int irq;
int vbat;
- int vbat_nom;
+ int vbat_nom_uv;
int inst_curr;
int avg_curr;
int bat_temp;
u64 div_res;
u32 div_rem;
- div_res = ((u64) cap_mah) * ((u64) di->vbat_nom);
- div_rem = do_div(div_res, 1000);
+ /*
+ * Capacity is in milli ampere hours (10^-3)Ah
+ * Nominal voltage is in microvolts (10^-6)V
+ * divide by 1000000 after multiplication to get to mWh
+ */
+ div_res = ((u64) cap_mah) * ((u64) di->vbat_nom_uv);
+ div_rem = do_div(div_res, 1000000);
/* Make sure to round upwards if necessary */
- if (div_rem >= 1000 / 2)
+ if (div_rem >= 1000000 / 2)
div_res++;
return (int) div_res;
di->bat_cap.max_mah =
di->bat_cap.max_mah_design;
- di->vbat_nom = b->nominal_voltage;
+ di->vbat_nom_uv =
+ di->bm->bi.voltage_max_design_uv;
}
if (ret.intval)
di->bat_cap.max_mah_design = di->bm->bi.charge_full_design_uah;
di->bat_cap.max_mah = di->bat_cap.max_mah_design;
-
- di->vbat_nom = di->bm->bat_type->nominal_voltage;
+ di->vbat_nom_uv = di->bm->bi.voltage_max_design_uv;
di->init_capacity = true;