* [PATCH v6 1/2] arm64: dts: qcom: x1e80100-crd: Add charge limit nvmem
2025-09-19 3:18 [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Fenglin Wu via B4 Relay
@ 2025-09-19 3:18 ` Fenglin Wu via B4 Relay
2025-09-19 3:18 ` [PATCH v6 2/2] power: supply: qcom_battmgr: handle charging state change notifications Fenglin Wu via B4 Relay
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Fenglin Wu via B4 Relay @ 2025-09-19 3:18 UTC (permalink / raw)
To: kernel, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel,
Konrad Dybcio, Dmitry Baryshkov
Cc: Subbaraman Narayanamurthy, David Collins, linux-arm-msm,
devicetree, linux-kernel, linux-pm, Fenglin Wu, Neil Armstrong
From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
Add nvmem cells for getting charge control thresholds if they have
been set previously.
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Thinkpad T14S OLED
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/x1-crd.dtsi | 7 +++++++
arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/x1-crd.dtsi b/arch/arm64/boot/dts/qcom/x1-crd.dtsi
index c9f0d505267081af66b0973fe6c1e33832a2c86b..cd3c071624ce66f8c28ee4521fe3db8b737757a6 100644
--- a/arch/arm64/boot/dts/qcom/x1-crd.dtsi
+++ b/arch/arm64/boot/dts/qcom/x1-crd.dtsi
@@ -82,6 +82,13 @@ pmic-glink {
<&tlmm 123 GPIO_ACTIVE_HIGH>,
<&tlmm 125 GPIO_ACTIVE_HIGH>;
+ nvmem-cells = <&charge_limit_en>,
+ <&charge_limit_end>,
+ <&charge_limit_delta>;
+ nvmem-cell-names = "charge_limit_en",
+ "charge_limit_end",
+ "charge_limit_delta";
+
/* Left-side rear port */
connector@0 {
compatible = "usb-c-connector";
diff --git a/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi b/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi
index e3888bc143a0aaae23c92d400d48ea94423e0366..cc4994f890f83540c4fb238811bc879ac9356256 100644
--- a/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi
+++ b/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi
@@ -240,6 +240,26 @@ reboot_reason: reboot-reason@48 {
};
};
+ pmk8550_sdam_15: nvram@7e00 {
+ compatible = "qcom,spmi-sdam";
+ reg = <0x7e00>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges = <0 0x7e00 0x100>;
+
+ charge_limit_en: charge-limit-en@73 {
+ reg = <0x73 0x1>;
+ };
+
+ charge_limit_end: charge-limit-end@75 {
+ reg = <0x75 0x1>;
+ };
+
+ charge_limit_delta: charge-limit-delta@76 {
+ reg = <0x76 0x1>;
+ };
+ };
+
pmk8550_gpios: gpio@8800 {
compatible = "qcom,pmk8550-gpio", "qcom,spmi-gpio";
reg = <0xb800>;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v6 2/2] power: supply: qcom_battmgr: handle charging state change notifications
2025-09-19 3:18 [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Fenglin Wu via B4 Relay
2025-09-19 3:18 ` [PATCH v6 1/2] arm64: dts: qcom: x1e80100-crd: Add charge limit nvmem Fenglin Wu via B4 Relay
@ 2025-09-19 3:18 ` Fenglin Wu via B4 Relay
2025-09-19 11:06 ` (subset) [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Sebastian Reichel
2025-10-30 16:25 ` Bjorn Andersson
3 siblings, 0 replies; 5+ messages in thread
From: Fenglin Wu via B4 Relay @ 2025-09-19 3:18 UTC (permalink / raw)
To: kernel, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel,
Konrad Dybcio, Dmitry Baryshkov
Cc: Subbaraman Narayanamurthy, David Collins, linux-arm-msm,
devicetree, linux-kernel, linux-pm, Fenglin Wu, Sebastian Reichel
From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
The X1E80100 battery management firmware sends a notification with
code 0x83 when the battery charging state changes, such as switching
between fast charge, taper charge, end of charge, or any other error
charging states.
The same notification code is used with bit[8] set when charging stops
because the charge control end threshold is reached. Additionally,
a 2-bit value is included in bit[10:9] with the same code to indicate
the charging source capability, which is determined by the calculated
power from voltage and current readings from PDOs: 2 means a strong
charger over 60W, 1 indicates a weak charger, and 0 means there is no
charging source.
These 3-MSB [10:8] in the notification code is not much useful for now,
hence just ignore them and trigger a power supply change event whenever
0x83 notification code is received. This helps to eliminate the unknown
notification error messages.
Reported-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Closes: https://lore.kernel.org/all/r65idyc4of5obo6untebw4iqfj2zteiggnnzabrqtlcinvtddx@xc4aig5abesu/
Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
---
drivers/power/supply/qcom_battmgr.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 0fe14a109b70fcc15575730573a7a16d1d843613..3c2837ef3461730369b52a4edb096795a531926a 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -34,8 +34,9 @@ enum qcom_battmgr_variant {
#define NOTIF_BAT_PROPERTY 0x30
#define NOTIF_USB_PROPERTY 0x32
#define NOTIF_WLS_PROPERTY 0x34
-#define NOTIF_BAT_INFO 0x81
#define NOTIF_BAT_STATUS 0x80
+#define NOTIF_BAT_INFO 0x81
+#define NOTIF_BAT_CHARGING_STATE 0x83
#define BATTMGR_BAT_INFO 0x9
@@ -1209,12 +1210,14 @@ static void qcom_battmgr_notification(struct qcom_battmgr *battmgr,
}
notification = le32_to_cpu(msg->notification);
+ notification &= 0xff;
switch (notification) {
case NOTIF_BAT_INFO:
battmgr->info.valid = false;
fallthrough;
case NOTIF_BAT_STATUS:
case NOTIF_BAT_PROPERTY:
+ case NOTIF_BAT_CHARGING_STATE:
power_supply_changed(battmgr->bat_psy);
break;
case NOTIF_USB_PROPERTY:
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: (subset) [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver
2025-09-19 3:18 [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Fenglin Wu via B4 Relay
2025-09-19 3:18 ` [PATCH v6 1/2] arm64: dts: qcom: x1e80100-crd: Add charge limit nvmem Fenglin Wu via B4 Relay
2025-09-19 3:18 ` [PATCH v6 2/2] power: supply: qcom_battmgr: handle charging state change notifications Fenglin Wu via B4 Relay
@ 2025-09-19 11:06 ` Sebastian Reichel
2025-10-30 16:25 ` Bjorn Andersson
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2025-09-19 11:06 UTC (permalink / raw)
To: kernel, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel,
Konrad Dybcio, Dmitry Baryshkov, Fenglin Wu
Cc: Subbaraman Narayanamurthy, David Collins, linux-arm-msm,
devicetree, linux-kernel, linux-pm, Neil Armstrong
On Fri, 19 Sep 2025 11:18:49 +0800, Fenglin Wu wrote:
> This continues the effort of updating changes which haven't been accepted
> in patch v5. Including:
> 1. Add nvmem cells for x1-crd device to enable reading back charger
> control threshold.
> 2. Add handling for notification 0x83 to avoid unexpected error messages.
>
> Rebase the changes on linux-power-supply.git@for-next
>
> [...]
Applied, thanks!
[2/2] power: supply: qcom_battmgr: handle charging state change notifications
commit: 41307ec7df057239aae3d0f089cc35a0d735cdf8
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: (subset) [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver
2025-09-19 3:18 [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Fenglin Wu via B4 Relay
` (2 preceding siblings ...)
2025-09-19 11:06 ` (subset) [PATCH v6 0/2] power: supply: Add several features support in qcom-battmgr driver Sebastian Reichel
@ 2025-10-30 16:25 ` Bjorn Andersson
3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2025-10-30 16:25 UTC (permalink / raw)
To: kernel, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel, Konrad Dybcio, Dmitry Baryshkov,
Fenglin Wu
Cc: Subbaraman Narayanamurthy, David Collins, linux-arm-msm,
devicetree, linux-kernel, linux-pm, Neil Armstrong,
Sebastian Reichel
On Fri, 19 Sep 2025 11:18:49 +0800, Fenglin Wu wrote:
> This continues the effort of updating changes which haven't been accepted
> in patch v5. Including:
> 1. Add nvmem cells for x1-crd device to enable reading back charger
> control threshold.
> 2. Add handling for notification 0x83 to avoid unexpected error messages.
>
> Rebase the changes on linux-power-supply.git@for-next
>
> [...]
Applied, thanks!
[1/2] arm64: dts: qcom: x1e80100-crd: Add charge limit nvmem
commit: 74c2c1e0d0784a13d0709e6ec4dbac3ab1f29f97
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread