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>] [day] [month] [year] [list]
Message-Id: <20240415151733.1986047-1-github.com@herrie.org>
Date: Mon, 15 Apr 2024 17:17:33 +0200
From: Herman van Hazendonk <github.com@...rie.org>
To: sre@...nel.org
Cc: benwolsieffer@...il.com,
	chris.chapuis@...il.com,
	Herman van Hazendonk <github.com@...rie.org>,
	linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] power: supply: max8903: configure USUS as output

The USUS pin was mistakenly configured as an input, when it should be an
output that specifies whether the USB power input is suspended. In addition
to fixing the pin mode, this patch also suspends the USB input when a DC
charger is connected, which should result in a slight reduction in USB
quiescent current.

Signed-off-by: Herman van Hazendonk <github.com@...rie.org>
---
 drivers/power/supply/max8903_charger.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max8903_charger.c b/drivers/power/supply/max8903_charger.c
index e65d0141f260..dd1cf77b101d 100644
--- a/drivers/power/supply/max8903_charger.c
+++ b/drivers/power/supply/max8903_charger.c
@@ -102,6 +102,11 @@ static irqreturn_t max8903_dcin(int irq, void *_data)
 	if (data->dcm)
 		gpiod_set_value(data->dcm, ta_in);
 
+	/* Set USB-Suspend 1:Suspended 0:Active */
+	if (data->usus)
+		gpiod_set_value(data->usus, ta_in);
+
+
 	/* Charger Enable / Disable */
 	if (data->cen) {
 		int val;
@@ -310,7 +315,15 @@ static int max8903_setup_gpios(struct platform_device *pdev)
 				     "failed to get FLT GPIO");
 	gpiod_set_consumer_name(data->flt, data->psy_desc.name);
 
-	data->usus = devm_gpiod_get_optional(dev, "usus", GPIOD_IN);
+	/*
+	 * Suspend the USB input if the DC charger is connected.
+	 *
+	 * The USUS line should be marked GPIO_ACTIVE_HIGH in the
+	 * device tree. Driving it low will enable the USB charger
+	 * input.
+	 */
+	flags = ta_in ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
+	data->usus = devm_gpiod_get_optional(dev, "usus", flags);
 	if (IS_ERR(data->usus))
 		return dev_err_probe(dev, PTR_ERR(data->usus),
 				     "failed to get USUS GPIO");

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ