aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Ainslie (Purism) <angus@akkea.ca>2018-07-31 13:49:09 -0400
committerSebastian Reichel <sre@kernel.org>2018-09-16 05:29:10 -0400
commitae6fe7a387e97e2ea8cc275fff5ef55568c4daf3 (patch)
tree9402e9787fa5d829bf3848f62c30fbd5db87e396
parent2e1a2ddee9cef07f5b1fab5625dcc56078139a4e (diff)
power: supply: bq25890_charger: Read back the current battery voltage
The BQ2589x family has the capability of reading the current battery voltage. Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r--drivers/power/supply/bq25890_charger.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index 23b39da07e56..1aa7872ddeb0 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -461,6 +461,15 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
461 val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM); 461 val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
462 break; 462 break;
463 463
464 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
465 ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
466 if (ret < 0)
467 return ret;
468
469 /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */
470 val->intval = 2304000 + ret * 20000;
471 break;
472
464 default: 473 default:
465 return -EINVAL; 474 return -EINVAL;
466 } 475 }
@@ -669,6 +678,7 @@ static enum power_supply_property bq25890_power_supply_props[] = {
669 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, 678 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
670 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, 679 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
671 POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, 680 POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
681 POWER_SUPPLY_PROP_VOLTAGE_NOW,
672}; 682};
673 683
674static char *bq25890_charger_supplied_to[] = { 684static char *bq25890_charger_supplied_to[] = {