Devicetree
 help / color / mirror / Atom feed
* [PATCH v2] arm64: dts: qcom: sm7125-samsung: add fuel gauge
@ 2026-12-02 17:56 Erikas Bitovtas
  2026-12-02 18:06 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Erikas Bitovtas @ 2026-12-02 17:56 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-msm, devicetree, ~postmarketos/upstreaming, phone-devel,
	Erikas Bitovtas

Samsung Galaxy A52 and A72 use Silicon Mitus SM5714 interface PMIC,
which includes a fuel gauge as one of its features. Enable GPI DMA and
I2C controllers, add battery bindings and enable the interface PMIC fuel
gauge.

Signed-off-by: Erikas Bitovtas <erikas99876@gmail.com>
---
Samsung Galaxy A52 and A72 use Silicon Mitus SM5714 interface PMIC which
includes a fuel gauge to measure battery state of charge. Add device
tree bindings for their lithium-ion 4,500 and 5,000 mAh batteries
respectfully, enable GPI DMA and I2C controllers and enable the SM5714
fuel gauge.

Tested on Samsung Galaxy A72. The driver reports the same SoC and energy
as on Android.

This patch depends on a currently unmerged series for SC7180 GPI DMA:
https://lore.kernel.org/all/20261112-sc7180-gpi-dma-v1-0-2a8eceb49563@gmail.com/
---
Changes in v2:
- Included additional properties for batteries. The values were taken
  from vendor code (https://github.com/LineageOS/android_kernel_samsung_sm7125/blob/lineage-24.0/arch/arm64/boot/dts/samsung/drivers/)
  as follows:
  - battery,low_temp_topoff -> trickle-charge-current-microamp
  - fuelgauge,sw_v_empty_voltage -> voltage-min-design-microvolt
  - battery,full_condition_vcell -> voltage-max-design-microvolt
  - battery,recharge_condition_vcell -> re-charge-voltage-microvolt
  - battery,max_charging_current -> constant-charge-current-max-microamp
- Link to v1: https://patch.msgid.link/20261123-sm7125-samsung-fuelgauge-v1-1-edcdef00a6ef@gmail.com

To: Bjorn Andersson <andersson@kernel.org>
To: Konrad Dybcio <konradybcio@kernel.org>
To: Abel Vesa <abelvesa@kernel.org>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: devicetree@vger.kernel.org
---
 arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts   |  6 ++++
 arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts   |  6 ++++
 .../arm64/boot/dts/qcom/sm7125-samsung-common.dtsi | 41 ++++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts b/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
index ecba5be8164e..33ce9e454017 100644
--- a/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
+++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
@@ -15,6 +15,12 @@ / {
 	qcom,board-id = <0x22 0x6>;
 };
 
+&battery {
+	charge-full-design-microamp-hours = <4500000>;
+	trickle-charge-current-microamp = <225000>;
+	constant-charge-current-max-microamp = <2800000>;
+};
+
 &rmtfs_mem {
 	reg = <0x0 0xf4f00000 0x0 0x202000>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts b/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
index f18d03de1585..fef0db054e1f 100644
--- a/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
+++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
@@ -15,6 +15,12 @@ / {
 	qcom,board-id = <0x22 0x5>;
 };
 
+&battery {
+	charge-full-design-microamp-hours = <5000000>;
+	trickle-charge-current-microamp = <250000>;
+	constant-charge-current-max-microamp = <2700000>;
+};
+
 &rmtfs_mem {
 	reg = <0x0 0xf3700000 0x0 0x202000>;
 };
diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi b/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
index 59ef4921f31e..a90e3b3184cd 100644
--- a/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
@@ -22,6 +22,14 @@ / {
 
 	qcom,msm-id = <QCOM_ID_SM7125 0x0>;
 
+	battery: battery {
+		compatible = "simple-battery";
+		device-chemistry = "lithium-ion";
+		voltage-min-design-microvolt = <3200000>;
+		voltage-max-design-microvolt = <4330000>;
+		re-charge-voltage-microvolt = <4310000>;
+	};
+
 	chosen {
 		#address-cells = <2>;
 		#size-cells = <2>;
@@ -379,6 +387,25 @@ &dispcc {
 	status = "disabled";
 };
 
+&gpi_dma0 {
+	status = "okay";
+};
+
+&gpi_dma1 {
+	status = "okay";
+};
+
+&i2c4 {
+	status = "okay";
+
+	fuel-gauge@71 {
+		compatible = "siliconmitus,sm5714-fuel-gauge";
+		reg = <0x71>;
+
+		monitored-battery = <&battery>;
+	};
+};
+
 &pm6150l_gpios {
 	key_vol_up_default: key-vol-up-default-state {
 		pins = "gpio8";
@@ -421,6 +448,20 @@ &qfprom {
 	vcc-supply = <&vreg_l11a_1p8>;
 };
 
+/* External pull-up */
+&qup_i2c4_default {
+	drive-strength = <2>;
+	bias-disable;
+};
+
+&qupv3_id_0 {
+	status = "okay";
+};
+
+&qupv3_id_1 {
+	status = "okay";
+};
+
 &sdhc_2 {
 	vmmc-supply = <&vreg_l9c_2p95>;
 	vqmmc-supply = <&vreg_l6c_3p0>;

---
base-commit: 368dbf53b0d21903f0b6d13a223c0a40ac7c2da8
change-id: 20261121-sm7125-samsung-fuelgauge-a57c6a0c916c
prerequisite-change-id: 20261111-sc7180-gpi-dma-a77963d9e1cc:v1
prerequisite-patch-id: 70dc64e33232cae6744eeb11e8f53e099eb49c1f
prerequisite-patch-id: 1ba00e1d0ffd80fa49f64e8b627ab07ce9478e74

Best regards,
--  
Erikas Bitovtas <erikas99876@gmail.com>


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

* Re: [PATCH v2] arm64: dts: qcom: sm7125-samsung: add fuel gauge
  2026-12-02 17:56 [PATCH v2] arm64: dts: qcom: sm7125-samsung: add fuel gauge Erikas Bitovtas
@ 2026-12-02 18:06 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02 18:06 UTC (permalink / raw)
  To: Erikas Bitovtas; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] arm64: dts: qcom: sm7125-samsung: wrong battery top-off and
  max voltage props
- [Low] arm64: dts: qcom: sm7125-samsung: unused gpi_dma1 and qupv3_id_1
  enabled
--

commit d1e4e816712da396c29d01ec3a61c854786a3077
Author: Erikas Bitovtas <erikas99876@gmail.com>

arm64: dts: qcom: sm7125-samsung: add fuel gauge

This commit adds simple-battery nodes, enables QUPv3, GPI DMA and I2C4
controllers, and enables the Silicon Mitus SM5714 fuel gauge on the
Samsung Galaxy A52 and Galaxy A72.

> diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts b/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
> index ecba5be8164ea..33ce9e454017d 100644
> --- a/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-a52q.dts
> @@ -15,6 +15,12 @@ / {
>  	qcom,board-id = <0x22 0x6>;
>  };
>  
> +&battery {
> +	charge-full-design-microamp-hours = <4500000>;
> +	trickle-charge-current-microamp = <225000>;
> +	constant-charge-current-max-microamp = <2800000>;
> +};
> +
>  &rmtfs_mem {
>  	reg = <0x0 0xf4f00000 0x0 0x202000>;
>  };
> diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts b/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
> index f18d03de1585e..fef0db054e1f7 100644
> --- a/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-a72q.dts
> @@ -15,6 +15,12 @@ / {
>  	qcom,board-id = <0x22 0x5>;
>  };
>  
> +&battery {
> +	charge-full-design-microamp-hours = <5000000>;
> +	trickle-charge-current-microamp = <250000>;
> +	constant-charge-current-max-microamp = <2700000>;
> +};
> +
>  &rmtfs_mem {
>  	reg = <0x0 0xf3700000 0x0 0x202000>;
>  };
> diff --git a/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi b/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
> index 59ef4921f31e9..a90e3b3184cd9 100644
> --- a/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm7125-samsung-common.dtsi
> @@ -22,6 +22,14 @@ / {
>  
>  	qcom,msm-id = <QCOM_ID_SM7125 0x0>;
>  
> +	battery: battery {
> +		compatible = "simple-battery";
> +		device-chemistry = "lithium-ion";
> +		voltage-min-design-microvolt = <3200000>;
> +		voltage-max-design-microvolt = <4330000>;
> +		re-charge-voltage-microvolt = <4310000>;
> +	};

[Severity: Medium]
Do trickle-charge-current-microamp and voltage-max-design-microvolt match
the vendor properties they were mapped from?

According to Documentation/devicetree/bindings/power/supply/battery.yaml,
trickle-charge-current-microamp is the wake-up or pre-pre-charge current
for very empty batteries, and explicitly notes that top-off charging is
different and not controlled by this property (CV-phase charge
termination current uses charge-term-current-microamp, and the vendor
battery,low_temp_topoff property is a low-temperature top-off
termination threshold).  Passing it as trickle-charge-current-microamp
causes power_supply_get_battery_info() to populate
info->tricklecharge_current_ua instead of info->charge_term_current_ua.

Similarly, the vendor battery,full_condition_vcell property (4.33 V) is
the minimum voltage threshold required to declare the battery full at
end-of-charge rather than the battery's maximum design voltage, so
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN will report 4.33 V.

> @@ -379,6 +387,25 @@ &dispcc {
>  	status = "disabled";
>  };
>  
> +&gpi_dma0 {
> +	status = "okay";
> +};
> +
> +&gpi_dma1 {
> +	status = "okay";
> +};

[ ... ]

> +&qupv3_id_0 {
> +	status = "okay";
> +};
> +
> +&qupv3_id_1 {
> +	status = "okay";
> +};

[Severity: Low]
Should gpi_dma1 and qupv3_id_1 remain disabled here?  The only enabled
QUPv3 serial engine in the SM7125 Samsung device trees is i2c4, which sits
under qupv3_id_0 and uses gpi_dma0, so enabling gpi_dma1 and qupv3_id_1
probes the second QUPv3 wrapper and GPI DMA controller with no active
consumers.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-sm7125-samsung-fuelgauge-v2-1-4a8f2977d50f@gmail.com?part=1

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

end of thread, other threads:[~2026-12-02 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 17:56 [PATCH v2] arm64: dts: qcom: sm7125-samsung: add fuel gauge Erikas Bitovtas
2026-12-02 18:06 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox