[PATCH v2 5/5] power: supply: qcom_battmgr: Allow charger changes to wake up the system

From: Vladyslav Tymoshchuk

Date: Sun Nov 29 2026 - 08:47:39 EST


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@xxxxxxxxx>
---
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;