From: Vladyslav Tymoshchuk <tvlad744@gmail.com>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Sebastian Reichel <sre@kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Abel Vesa <abel.vesa@oss.qualcomm.com>,
Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>,
Joonhoe Kim <26rote@gmail.com>,
linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 5/5] power: supply: qcom_battmgr: Allow charger changes to wake up the system
Date: Sun, 29 Nov 2026 15:44:41 +0200 [thread overview]
Message-ID: <20261129134442.579-6-tvlad744@gmail.com> (raw)
In-Reply-To: <20261129134442.579-1-tvlad744@gmail.com>
Most notifications of the battery manager report battery status, which
is not worth a wakeup. Changes of the USB and wireless charger, like
plugging one in, can be.
Make the device wakeup capable, with a filter for the charger
notifications. Leave wakeup disabled by default, it is up to user space
through power/wakeup.
Do this only for the SM8350 and SM8550 firmware, as the SC8280XP and
X1E80100 firmware sends no notification when a charger changes.
Signed-off-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
---
drivers/power/supply/qcom_battmgr.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 69473ea753f6..9902192b2921 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -9,6 +9,7 @@
#include <linux/mutex.h>
#include <linux/nvmem-consumer.h>
#include <linux/of_device.h>
+#include <linux/pm_wakeup.h>
#include <linux/power_supply.h>
#include <linux/property.h>
#include <linux/soc/qcom/pdr.h>
@@ -1723,6 +1724,20 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
complete(&battmgr->ack);
}
+static bool qcom_battmgr_is_charger_notification(const void *data, size_t len, void *priv)
+{
+ const struct qcom_battmgr_message *msg = data;
+ unsigned int notification;
+
+ if (le32_to_cpu(msg->hdr.opcode) != BATTMGR_NOTIFICATION ||
+ len != sizeof(msg->hdr) + sizeof(msg->notification))
+ return false;
+
+ notification = le32_to_cpu(msg->notification) & 0xff;
+
+ return notification == NOTIF_USB_PROPERTY || notification == NOTIF_WLS_PROPERTY;
+}
+
static void qcom_battmgr_callback(const void *data, size_t len, void *priv)
{
const struct pmic_glink_hdr *hdr = data;
@@ -1896,6 +1911,13 @@ static int qcom_battmgr_probe(struct auxiliary_device *adev,
if (ret)
return ret;
+ if (battmgr->variant == QCOM_BATTMGR_SM8350 ||
+ battmgr->variant == QCOM_BATTMGR_SM8550) {
+ device_set_wakeup_capable(dev, true);
+ pmic_glink_client_set_wakeup_filter(battmgr->client,
+ qcom_battmgr_is_charger_notification);
+ }
+
pmic_glink_client_register(battmgr->client);
return 0;
next prev parent reply other threads:[~2026-11-29 13:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:44 [PATCH v2 0/5] soc: qcom: pmic_glink: Deliver notifications from a freezable workqueue Vladyslav Tymoshchuk
2026-11-29 13:44 ` [PATCH v2 1/5] usb: typec: ucsi: glink: Handle a restart of the remote before the work runs Vladyslav Tymoshchuk
2026-11-29 14:01 ` sashiko-bot
2026-11-29 13:44 ` [PATCH v2 2/5] soc: qcom: pmic_glink: Deliver notifications from a freezable workqueue Vladyslav Tymoshchuk
2026-11-29 13:44 ` [PATCH v2 3/5] soc: qcom: pmic_glink: Report wakeup events on behalf of clients Vladyslav Tymoshchuk
2026-11-29 13:44 ` [PATCH v2 4/5] usb: typec: ucsi: glink: Wake up the system on connector changes Vladyslav Tymoshchuk
2026-11-29 13:44 ` Vladyslav Tymoshchuk [this message]
2026-11-29 14:00 ` [PATCH v2 5/5] power: supply: qcom_battmgr: Allow charger changes to wake up the system sashiko-bot
2026-11-29 14:01 ` [PATCH v2 0/5] soc: qcom: pmic_glink: Deliver notifications from a freezable workqueue sashiko-bot
2026-11-29 23:29 ` Joonhoe Kim
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=20261129134442.579-6-tvlad744@gmail.com \
--to=tvlad744@gmail.com \
--cc=26rote@gmail.com \
--cc=abel.vesa@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jishnu.prakash@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=neil.armstrong@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.