[PATCH 11/14] power: supply: bq25890: show measured VBUS

From: MichaÅ MirosÅaw
Date: Thu Apr 02 2020 - 10:58:44 EST


Export VBUS measurement via INPUT_VOLTAGE_NOW property.

Signed-off-by: MichaÅ MirosÅaw <mirq-linux@xxxxxxxxxxxx>
---
drivers/power/supply/bq25890_charger.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index 250468f3ff18..d23274d13263 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -506,6 +506,24 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
val->intval = bq25890_find_val(ret, TBL_IILIM);
break;

+ case POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW:
+ ret = bq25890_field_read(bq, F_VBUS_GD); /* is VBUS connected? */
+ if (ret < 0)
+ return ret;
+
+ if (!ret) {
+ val->intval = 0;
+ break;
+ }
+
+ ret = bq25890_field_read(bq, F_VBUSV); /* read measured value */
+ if (ret < 0)
+ return ret;
+
+ /* converted_val = 2.6V + ADC_val * 100mV */
+ val->intval = 2600000 + ret * 100000;
+ break;
+
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
if (ret < 0)
@@ -705,6 +723,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = {
POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
+ POWER_SUPPLY_PROP_INPUT_VOLTAGE_NOW,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
};
--
2.20.1