linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds
@ 2015-06-08  1:11 Krzysztof Kozlowski
  2015-06-08  1:11 ` [PATCH 2/2] ARM: dts: Set max17047 over heat and over voltage thresholds Krzysztof Kozlowski
  2015-06-10 14:46 ` [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Sebastian Reichel
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2015-06-08  1:11 UTC (permalink / raw)
  To: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
	linux-pm, linux-kernel, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc
  Cc: Krzysztof Kozlowski

The commit edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_*
properties support") added support for setting voltage and temperature
thresholds with platform data. For DeviceTree default of 0 was always
used.

This caused reporting battery health always as over voltage or
over heated.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support")
---
 .../devicetree/bindings/power_supply/max17042_battery.txt   | 13 +++++++++++++
 drivers/power/max17042_battery.c                            |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/power_supply/max17042_battery.txt b/Documentation/devicetree/bindings/power_supply/max17042_battery.txt
index 5bc9b685cf8a..3f3894aaeebc 100644
--- a/Documentation/devicetree/bindings/power_supply/max17042_battery.txt
+++ b/Documentation/devicetree/bindings/power_supply/max17042_battery.txt
@@ -9,10 +9,23 @@ Optional properties :
                          (datasheet-recommended value is 10000).
    Defining this property enables current-sense functionality.
 
+Optional threshold properties :
+ If skipped the condition won't be reported.
+ - maxim,cold-temp :      Temperature threshold to report battery
+                          as cold (in tenths of degree Celsius).
+ - maxim,over-heat-temp : Temperature threshold to report battery
+                          as over heated (in tenths of degree Celsius).
+ - maxim,dead-volt :      Voltage threshold to report battery
+                          as dead (in mV).
+ - maxim,over-volt :      Voltage threshold to report battery
+                          as over voltage (in mV).
+
 Example:
 
 	battery-charger@36 {
 		compatible = "maxim,max17042";
 		reg = <0x36>;
 		maxim,rsns-microohm = <10000>;
+		maxim,over-heat-temp = <600>;
+		maxim,over-volt = <4300>;
 	};
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 62908eba2763..a8e16364c2aa 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -818,6 +818,15 @@ max17042_get_pdata(struct device *dev)
 		pdata->enable_current_sense = true;
 	}
 
+	if (of_property_read_s32(np, "maxim,cold-temp", &pdata->temp_min))
+		pdata->temp_min = INT_MIN;
+	if (of_property_read_s32(np, "maxim,over-heat-temp", &pdata->temp_max))
+		pdata->temp_max = INT_MAX;
+	if (of_property_read_s32(np, "maxim,dead-volt", &pdata->vmin))
+		pdata->vmin = INT_MIN;
+	if (of_property_read_s32(np, "maxim,over-volt", &pdata->vmax))
+		pdata->vmax = INT_MAX;
+
 	return pdata;
 }
 #else
-- 
1.9.1


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

* [PATCH 2/2] ARM: dts: Set max17047 over heat and over voltage thresholds
  2015-06-08  1:11 [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Krzysztof Kozlowski
@ 2015-06-08  1:11 ` Krzysztof Kozlowski
  2015-06-10 14:46 ` [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Sebastian Reichel
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2015-06-08  1:11 UTC (permalink / raw)
  To: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
	linux-pm, linux-kernel, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc
  Cc: Krzysztof Kozlowski

Add some safe values for over head and over voltage. The Trats2 uses 3.8
V battery and during testing it operated properly under 4.48 V.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-trats2.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 0b228ee14c64..8a87d39a28a0 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -595,6 +595,9 @@
 			interrupt-parent = <&gpx2>;
 			interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
 			reg = <0x36>;
+
+			maxim,over-heat-temp = <700>;
+			maxim,over-volt = <4500>;
 		};
 	};
 
-- 
1.9.1


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

* Re: [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds
  2015-06-08  1:11 [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Krzysztof Kozlowski
  2015-06-08  1:11 ` [PATCH 2/2] ARM: dts: Set max17047 over heat and over voltage thresholds Krzysztof Kozlowski
@ 2015-06-10 14:46 ` Sebastian Reichel
  1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2015-06-10 14:46 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel,
	Kukjin Kim, devicetree, linux-arm-kernel, linux-samsung-soc

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

Hi,

On Mon, Jun 08, 2015 at 10:11:38AM +0900, Krzysztof Kozlowski wrote:
> The commit edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_*
> properties support") added support for setting voltage and temperature
> thresholds with platform data. For DeviceTree default of 0 was always
> used.
> 
> This caused reporting battery health always as over voltage or
> over heated.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Fixes: edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support")

Thanks, queued.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-06-10 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08  1:11 [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Krzysztof Kozlowski
2015-06-08  1:11 ` [PATCH 2/2] ARM: dts: Set max17047 over heat and over voltage thresholds Krzysztof Kozlowski
2015-06-10 14:46 ` [PATCH 1/2] power_supply: max17042: Add OF support for setting thresholds Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).