mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] power: supply: qcom_smbx: report charger state changes
@ 2026-10-03 19:45 Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change Fabricio Akio via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Fabricio Akio via B4 Relay @ 2026-10-03 19:45 UTC (permalink / raw)
  To: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa
  Cc: Robin Snyders, David Heidelberg, phone-devel, Richard Acayan,
	linux-arm-msm, linux-pm, devicetree, linux-kernel,
	Sebastian Reichel, Fabricio Akio

qcom_smbx does not handle the charger's chg-state-change interrupt, so
a charge completing is not notified and consumers can keep a stale
status. Allow the interrupt in the binding, handle it in the driver,
and describe it for PM660 and PMI8998.

Tested on a Motorola Moto X4 (PM660) with the sdm660-mainline 7.2.3
tree: each charging-state change is notified and the battery status
follows. The PMI8998 patch is untested on hardware.

Robin Snyders' pending SMB5 series touches the same binding and
driver; whichever lands second needs a rebase.

---
Fabricio Akio (4):
      dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change
      power: supply: qcom_smbx: report charger state changes
      arm64: dts: qcom: pm660: Add the charger state change interrupt
      arm64: dts: qcom: pmi8998: Add the charger state change interrupt

 .../power/supply/qcom,pmi8998-charger.yaml         |  5 ++++-
 arch/arm64/boot/dts/qcom/pm660.dtsi                |  9 ++++++--
 arch/arm64/boot/dts/qcom/pmi8998.dtsi              |  6 ++++--
 drivers/power/supply/qcom_smbx.c                   | 24 ++++++++++++++++++++++
 4 files changed, 39 insertions(+), 5 deletions(-)
---
base-commit: 9f24d789f03b22941b905ded43cb5ff8eea9ce62
change-id: 20261003-qcom-smbx-chg-state-change-343c9b88ca5e

Best regards,
--  
Fabricio Akio <fabricioakio@gmail.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change
  2026-10-03 19:45 [PATCH 0/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
@ 2026-10-03 19:45 ` Fabricio Akio via B4 Relay
  2026-10-04  8:06   ` Krzysztof Kozlowski
  2026-10-03 19:45 ` [PATCH 2/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Fabricio Akio via B4 Relay @ 2026-10-03 19:45 UTC (permalink / raw)
  To: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa
  Cc: Robin Snyders, David Heidelberg, phone-devel, Richard Acayan,
	linux-arm-msm, linux-pm, devicetree, linux-kernel,
	Sebastian Reichel, Fabricio Akio

From: Fabricio Akio <fabricioakio@gmail.com>

The charger raises an interrupt when its charging state changes. Allow
it as an optional fifth interrupt.

Signed-off-by: Fabricio Akio <fabricioakio@gmail.com>
---
 .../devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml       | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
index 70f5cd6eaeab..7dfb0823ccbb 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
+++ b/Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml
@@ -19,14 +19,17 @@ properties:
     maxItems: 1
 
   interrupts:
-    maxItems: 4
+    minItems: 4
+    maxItems: 5
 
   interrupt-names:
+    minItems: 4
     items:
       - const: usb-plugin
       - const: bat-ov
       - const: wdog-bark
       - const: usbin-icl-change
+      - const: chg-state-change
 
   io-channels:
     items:

-- 
2.55.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] power: supply: qcom_smbx: report charger state changes
  2026-10-03 19:45 [PATCH 0/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change Fabricio Akio via B4 Relay
@ 2026-10-03 19:45 ` Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 3/4] arm64: dts: qcom: pm660: Add the charger state change interrupt Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 4/4] arm64: dts: qcom: pmi8998: " Fabricio Akio via B4 Relay
  3 siblings, 0 replies; 7+ messages in thread
From: Fabricio Akio via B4 Relay @ 2026-10-03 19:45 UTC (permalink / raw)
  To: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa
  Cc: Robin Snyders, David Heidelberg, phone-devel, Richard Acayan,
	linux-arm-msm, linux-pm, devicetree, linux-kernel,
	Sebastian Reichel, Fabricio Akio

From: Fabricio Akio <fabricioakio@gmail.com>

Nothing notifies consumers when the charging state changes on its own,
as when a charge completes, so they can keep a stale status.

Request the chg-state-change interrupt when the device tree provides
it, and notify consumers when it fires.

Fixes: 8648aeb5d7b7 ("power: supply: add Qualcomm PMI8998 SMB2 Charger driver")
Signed-off-by: Fabricio Akio <fabricioakio@gmail.com>
---
 drivers/power/supply/qcom_smbx.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
index f5557b8cc92a..3738eb8638bc 100644
--- a/drivers/power/supply/qcom_smbx.c
+++ b/drivers/power/supply/qcom_smbx.c
@@ -762,6 +762,15 @@ static irqreturn_t smb_handle_usb_icl_change(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t smb_handle_chg_state_change(int irq, void *data)
+{
+	struct smb_chip *chip = data;
+
+	power_supply_changed(chip->chg_psy);
+
+	return IRQ_HANDLED;
+}
+
 static irqreturn_t smb_handle_wdog_bark(int irq, void *data)
 {
 	struct smb_chip *chip = data;
@@ -1078,6 +1087,21 @@ static int smb_probe(struct platform_device *pdev)
 	if (rc < 0)
 		return rc;
 
+	/* Optional: not every device tree lists it */
+	irq = platform_get_irq_byname_optional(pdev, "chg-state-change");
+	if (irq > 0) {
+		rc = devm_request_threaded_irq(chip->dev, irq, NULL,
+					       smb_handle_chg_state_change,
+					       IRQF_ONESHOT, "chg-state-change",
+					       chip);
+		if (rc < 0)
+			return dev_err_probe(chip->dev, rc,
+					     "Couldn't request irq chg-state-change\n");
+	} else if (irq != -ENXIO) {
+		return dev_err_probe(chip->dev, irq,
+				     "Couldn't get irq chg-state-change\n");
+	}
+
 	devm_device_init_wakeup(chip->dev);
 
 	rc = devm_pm_set_wake_irq(chip->dev, chip->cable_irq);

-- 
2.55.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] arm64: dts: qcom: pm660: Add the charger state change interrupt
  2026-10-03 19:45 [PATCH 0/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 2/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
@ 2026-10-03 19:45 ` Fabricio Akio via B4 Relay
  2026-10-03 19:45 ` [PATCH 4/4] arm64: dts: qcom: pmi8998: " Fabricio Akio via B4 Relay
  3 siblings, 0 replies; 7+ messages in thread
From: Fabricio Akio via B4 Relay @ 2026-10-03 19:45 UTC (permalink / raw)
  To: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa
  Cc: Robin Snyders, David Heidelberg, phone-devel, Richard Acayan,
	linux-arm-msm, linux-pm, devicetree, linux-kernel,
	Sebastian Reichel, Fabricio Akio

From: Fabricio Akio <fabricioakio@gmail.com>

Describe the charger's chg-state-change interrupt, as the vendor device
tree does.

Signed-off-by: Fabricio Akio <fabricioakio@gmail.com>
---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/pm660.dtsi b/arch/arm64/boot/dts/qcom/pm660.dtsi
index 156b2ddff0dc..9e84f16f4b06 100644
--- a/arch/arm64/boot/dts/qcom/pm660.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm660.dtsi
@@ -80,8 +80,13 @@ pm660_charger: charger@1000 {
 			interrupts = <0x0 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
 				     <0x0 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
 				     <0x0 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
-				     <0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>;
-			interrupt-names = "usb-plugin", "bat-ov", "wdog-bark", "usbin-icl-change";
+				     <0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
+				     <0x0 0x10 0x1 IRQ_TYPE_EDGE_RISING>;
+			interrupt-names = "usb-plugin",
+					  "bat-ov",
+					  "wdog-bark",
+					  "usbin-icl-change",
+					  "chg-state-change";
 
 			io-channels = <&pm660_rradc 3>,
 				      <&pm660_rradc 4>;

-- 
2.55.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] arm64: dts: qcom: pmi8998: Add the charger state change interrupt
  2026-10-03 19:45 [PATCH 0/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
                   ` (2 preceding siblings ...)
  2026-10-03 19:45 ` [PATCH 3/4] arm64: dts: qcom: pm660: Add the charger state change interrupt Fabricio Akio via B4 Relay
@ 2026-10-03 19:45 ` Fabricio Akio via B4 Relay
  3 siblings, 0 replies; 7+ messages in thread
From: Fabricio Akio via B4 Relay @ 2026-10-03 19:45 UTC (permalink / raw)
  To: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa
  Cc: Robin Snyders, David Heidelberg, phone-devel, Richard Acayan,
	linux-arm-msm, linux-pm, devicetree, linux-kernel,
	Sebastian Reichel, Fabricio Akio

From: Fabricio Akio <fabricioakio@gmail.com>

Describe the charger's chg-state-change interrupt, as the vendor device
tree does.

Signed-off-by: Fabricio Akio <fabricioakio@gmail.com>
---
 arch/arm64/boot/dts/qcom/pmi8998.dtsi | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/pmi8998.dtsi b/arch/arm64/boot/dts/qcom/pmi8998.dtsi
index cd3f0790fd42..bd07ff137947 100644
--- a/arch/arm64/boot/dts/qcom/pmi8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmi8998.dtsi
@@ -16,11 +16,13 @@ pmi8998_charger: charger@1000 {
 			interrupts = <0x2 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
 				     <0x2 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
 				     <0x2 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
-				     <0x2 0x13 0x6 IRQ_TYPE_EDGE_RISING>;
+				     <0x2 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
+				     <0x2 0x10 0x1 IRQ_TYPE_EDGE_RISING>;
 			interrupt-names = "usb-plugin",
 					  "bat-ov",
 					  "wdog-bark",
-					  "usbin-icl-change";
+					  "usbin-icl-change",
+					  "chg-state-change";
 
 			io-channels = <&pmi8998_rradc 3>,
 				      <&pmi8998_rradc 4>;

-- 
2.55.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change
  2026-10-03 19:45 ` [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change Fabricio Akio via B4 Relay
@ 2026-10-04  8:06   ` Krzysztof Kozlowski
  2026-10-04 11:58     ` Fabricio Akio
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-04  8:06 UTC (permalink / raw)
  To: Fabricio Akio
  Cc: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa, Robin Snyders, David Heidelberg,
	phone-devel, Richard Acayan, linux-arm-msm, linux-pm, devicetree,
	linux-kernel, Sebastian Reichel

On Sat, Oct 03, 2026 at 04:45:21PM -0300, Fabricio Akio wrote:
> The charger raises an interrupt when its charging state changes. Allow

Each of the ones mentioned in the binding?

> it as an optional fifth interrupt.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change
  2026-10-04  8:06   ` Krzysztof Kozlowski
@ 2026-10-04 11:58     ` Fabricio Akio
  0 siblings, 0 replies; 7+ messages in thread
From: Fabricio Akio @ 2026-10-04 11:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Casey Connolly, Sebastian Reichel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
	Konrad Dybcio, Abel Vesa, Robin Snyders, David Heidelberg,
	phone-devel, Richard Acayan, linux-arm-msm, linux-pm, devicetree,
	linux-kernel, Sebastian Reichel

On Sun, Oct 04, 2026 at 10:06:52AM +0200, Krzysztof Kozlowski wrote:
> On Sat, Oct 03, 2026 at 04:45:21PM -0300, Fabricio Akio wrote:
> > The charger raises an interrupt when its charging state changes. Allow
>
> Each of the ones mentioned in the binding?

Yes, both. PMI8998 and PM660 have it as interrupt 1 of the charger
peripheral at 0x1000, as the downstream msm-pmi8998.dtsi and
msm-pm660.dtsi describe.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-04 11:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03 19:45 [PATCH 0/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
2026-10-03 19:45 ` [PATCH 1/4] dt-bindings: power: supply: qcom,pmi8998-charger: add chg-state-change Fabricio Akio via B4 Relay
2026-10-04  8:06   ` Krzysztof Kozlowski
2026-10-04 11:58     ` Fabricio Akio
2026-10-03 19:45 ` [PATCH 2/4] power: supply: qcom_smbx: report charger state changes Fabricio Akio via B4 Relay
2026-10-03 19:45 ` [PATCH 3/4] arm64: dts: qcom: pm660: Add the charger state change interrupt Fabricio Akio via B4 Relay
2026-10-03 19:45 ` [PATCH 4/4] arm64: dts: qcom: pmi8998: " Fabricio Akio via B4 Relay

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®