lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <32ec8cef47cb49e02542916ae15972ba2e619e5a.1585838679.git.mirq-linux@rere.qmqm.pl>
Date:   Thu, 02 Apr 2020 16:58:34 +0200
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Sebastian Reichel <sre@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: [PATCH 11/14] power: supply: bq25890: show measured VBUS

Export VBUS measurement via INPUT_VOLTAGE_NOW property.

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ