diff mbox series

[3/4] power: supply: max17042: use microvolts for voltage comparison

Message ID 20241109-b4-max17042-v1-3-9e2b07e54e76@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: supply: max17042: cleanup and more features | expand

Commit Message

Dzmitry Sankouski Nov. 9, 2024, 12:44 p.m. UTC
Do not convert VCELL register value from uV to mV to compare
with vmin/vmax. Rather use uV for vim/vmax, since that's a
standard measure unit in power supply drivers.

Convert "maxim,dead-volt" and "maxim,over-volt" to uV.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 2 +-
 arch/arm/boot/dts/samsung/exynos4210-i9100.dts                     | 2 +-
 arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi                     | 2 +-
 arch/arm/boot/dts/samsung/exynos4412-midas.dtsi                    | 2 +-
 arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi                   | 2 +-
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi                  | 2 +-
 arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi           | 2 +-
 drivers/power/supply/max17042_battery.c                            | 4 ----
 11 files changed, 13 insertions(+), 17 deletions(-)

Comments

Krzysztof Kozlowski Nov. 9, 2024, 1:48 p.m. UTC | #1
On 09/11/2024 13:44, Dzmitry Sankouski wrote:
> Do not convert VCELL register value from uV to mV to compare
> with vmin/vmax. Rather use uV for vim/vmax, since that's a
> standard measure unit in power supply drivers.
> 
> Convert "maxim,dead-volt" and "maxim,over-volt" to uV.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 2 +-
>  arch/arm/boot/dts/samsung/exynos4210-i9100.dts                     | 2 +-
>  arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi                     | 2 +-
>  arch/arm/boot/dts/samsung/exynos4412-midas.dtsi                    | 2 +-
>  arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi                   | 2 +-
>  arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi                  | 2 +-
>  arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts               | 4 ++--
>  arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts               | 4 ++--
>  arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts               | 4 ++--
>  arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi           | 2 +-
>  drivers/power/supply/max17042_battery.c                            | 4 ----
>  11 files changed, 13 insertions(+), 17 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> index e98ffdad1ec3..d1ad597e0837 100644
> --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> @@ -83,7 +83,7 @@ examples:
>          reg = <0x36>;
>          maxim,rsns-microohm = <10000>;
>          maxim,over-heat-temp = <600>;
> -        maxim,over-volt = <4300>;
> +        maxim,over-volt = <4300000>;
>          shared-irq;

Property says this is mV so 4300 V? That's just wrong.

Entire commit touching bindings, drivers and DTS in one patch is an ABI
break and just clear NAK.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
index e98ffdad1ec3..d1ad597e0837 100644
--- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
@@ -83,7 +83,7 @@  examples:
         reg = <0x36>;
         maxim,rsns-microohm = <10000>;
         maxim,over-heat-temp = <600>;
-        maxim,over-volt = <4300>;
+        maxim,over-volt = <4300000>;
         shared-irq;
       };
     };
diff --git a/arch/arm/boot/dts/samsung/exynos4210-i9100.dts b/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
index 0d8495792a70..0ca755160bef 100644
--- a/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
+++ b/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
@@ -150,7 +150,7 @@  battery@36 {
 
 			reg = <0x36>;
 			maxim,over-heat-temp = <700>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <4500000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
index 9bc05961577d..758bfc10826f 100644
--- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
@@ -186,7 +186,7 @@  fuel-gauge@36 {
 			pinctrl-0 = <&max77693_fuel_irq>;
 
 			maxim,over-heat-temp = <500>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <450000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi b/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
index 3d5aace668dc..c744907b7c42 100644
--- a/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
@@ -263,7 +263,7 @@  fuel-gauge@36 {
 			reg = <0x36>;
 
 			maxim,over-heat-temp = <700>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <4500000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi b/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
index 28a605802733..3d52aa25c83c 100644
--- a/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
@@ -175,7 +175,7 @@  fuel-gauge@36 {
 			interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
 			maxim,rsns-microohm = <10000>;
 			maxim,over-heat-temp = <600>;
-			maxim,over-volt = <4300>;
+			maxim,over-volt = <4300000>;
 		};
 	};
 
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 1b39514d5c12..90beefaa644f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1141,7 +1141,7 @@  bat: fuel-gauge@36 {
 		pinctrl-0 = <&pinctrl_gauge>;
 		power-supplies = <&bq25895>;
 		maxim,over-heat-temp = <700>;
-		maxim,over-volt = <4500>;
+		maxim,over-volt = <4500000>;
 		maxim,rsns-microohm = <5000>;
 	};
 
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
index 8380451ebbf6..a02ece82ff5b 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
@@ -25,8 +25,8 @@  battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 	};
 
 	/* charger@6b */
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
index ec5589fc69bd..f567b7ffb613 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
@@ -36,8 +36,8 @@  battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
index eecf78ba45bb..45ddd17243e7 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
@@ -25,8 +25,8 @@  battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi b/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
index fbd2caf405d5..2c387c8b6344 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
@@ -105,7 +105,7 @@  fuelgauge@36 {
 
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
-		maxim,over-volt = <4400>;
+		maxim,over-volt = <4400000>;
 
 		interrupt-parent = <&tlmm>;
 		interrupts = <121 IRQ_TYPE_EDGE_FALLING>;
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index f3d89d4d5c42..ea212cb10360 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -182,8 +182,6 @@  static int max17042_get_battery_health(struct max17042_chip *chip, int *health)
 
 	/* bits [0-3] unused */
 	vavg = val * 625 / 8;
-	/* Convert to millivolts */
-	vavg /= 1000;
 
 	ret = regmap_read(chip->regmap, MAX17042_VCELL, &val);
 	if (ret < 0)
@@ -191,8 +189,6 @@  static int max17042_get_battery_health(struct max17042_chip *chip, int *health)
 
 	/* bits [0-3] unused */
 	vbatt = val * 625 / 8;
-	/* Convert to millivolts */
-	vbatt /= 1000;
 
 	if (vavg < chip->pdata->vmin) {
 		*health = POWER_SUPPLY_HEALTH_DEAD;