From: Joonhoe Kim <26rote@gmail.com>
To: sre@kernel.org
Cc: konrad.dybcio@oss.qualcomm.com, kamal.wadhwa@oss.qualcomm.com,
linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] power: supply: qcom_battmgr: Allow setting the USB input current limit
Date: Wed, 7 Oct 2026 21:39:39 +0900 [thread overview]
Message-ID: <20261007123939.1679-1-26rote@gmail.com> (raw)
The SM8350 class USB power supply reports input_current_limit, but does
not allow writing it, although the firmware accepts
BATTMGR_USB_PROPERTY_SET for USB_INPUT_CURR_LIMIT (in uA).
On a Kaanapali tablet connected to a PC port, the firmware keeps the
input limit at 500 mA, which is less than the system draws with the
display on, so the battery discharges while the supply reports
"Charging". The vendor kernel sets 900 mA on the same port.
Make input_current_limit writable and pass the value to the firmware.
Handle the BATTMGR_USB_PROPERTY_SET response like the other set
requests.
On the PC port with the display on, writing 900000 raised the input
current from 494 mA to 891 mA, and the battery discharge current went
from about 540 mA to about 120 mA.
Assisted-by: LLM
Signed-off-by: Joonhoe Kim <26rote@gmail.com>
---
Tested on a Lenovo Legion Tab Y700 gen 5 (qcom,kaanapali-pmic-glink,
which uses the SM8550 path). With a USB PD charger the firmware keeps
its own limit and the written value is not reflected in
input_current_limit.
The value is left to the writer: userspace, or dwc3 through
usb-psy-name, which sets INPUT_CURRENT_LIMIT from vbus_draw. The 900 mA
above is what the vendor kernel uses on this port; the gadget here is
high-speed.
This is independent of "power: supply: qcom_battmgr: report the USB
type from USB_ADAP_TYPE" and applies before or after it.
drivers/power/supply/qcom_battmgr.c | 30 +++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 7716eb9e1aff..12692de7f982 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1065,6 +1065,33 @@ static const struct power_supply_desc sc8280xp_usb_psy_desc = {
BIT(POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID),
};
+static int qcom_battmgr_usb_set_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ const union power_supply_propval *pval)
+{
+ struct qcom_battmgr *battmgr = power_supply_get_drvdata(psy);
+ int ret;
+
+ if (!battmgr->service_up)
+ return -EAGAIN;
+
+ if (psp != POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT || pval->intval < 0)
+ return -EINVAL;
+
+ mutex_lock(&battmgr->lock);
+ ret = qcom_battmgr_request_property(battmgr, BATTMGR_USB_PROPERTY_SET,
+ USB_INPUT_CURR_LIMIT, pval->intval);
+ mutex_unlock(&battmgr->lock);
+
+ return ret;
+}
+
+static int qcom_battmgr_usb_is_writeable(struct power_supply *psy,
+ enum power_supply_property psp)
+{
+ return psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT;
+}
+
static const enum power_supply_property sm8350_usb_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -1081,6 +1108,8 @@ static const struct power_supply_desc sm8350_usb_psy_desc = {
.properties = sm8350_usb_props,
.num_properties = ARRAY_SIZE(sm8350_usb_props),
.get_property = qcom_battmgr_usb_get_property,
+ .set_property = qcom_battmgr_usb_set_property,
+ .property_is_writeable = qcom_battmgr_usb_is_writeable,
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
BIT(POWER_SUPPLY_USB_TYPE_SDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
@@ -1558,6 +1587,7 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
break;
case BATTMGR_REQUEST_NOTIFICATION:
case BATTMGR_CHG_CTRL_LIMIT_EN:
+ case BATTMGR_USB_PROPERTY_SET:
battmgr->error = 0;
break;
default:
base-commit: 6375e61c01e93e35ee7acd336a689ac1fae4b509
--
2.43.0
reply other threads:[~2026-10-07 12:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007123939.1679-1-26rote@gmail.com \
--to=26rote@gmail.com \
--cc=kamal.wadhwa@oss.qualcomm.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®