Commit ae6fe7a3 authored by Angus Ainslie (Purism)'s avatar Angus Ainslie (Purism) Committed by Sebastian Reichel

power: supply: bq25890_charger: Read back the current battery voltage

The BQ2589x family has the capability of reading the current battery voltage.
Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarAngus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 2e1a2dde
...@@ -461,6 +461,15 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, ...@@ -461,6 +461,15 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM); val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
break; break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
if (ret < 0)
return ret;
/* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */
val->intval = 2304000 + ret * 20000;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -669,6 +678,7 @@ static enum power_supply_property bq25890_power_supply_props[] = { ...@@ -669,6 +678,7 @@ static enum power_supply_property bq25890_power_supply_props[] = {
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
}; };
static char *bq25890_charger_supplied_to[] = { static char *bq25890_charger_supplied_to[] = {
......
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