Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power_supply: max17042: Add OF support for setting thresholds

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")
Signed-off-by: Sebastian Reichel <sre@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Sebastian Reichel
a6e6b63e 5c6e3a97

+22
+13
Documentation/devicetree/bindings/power_supply/max17042_battery.txt
··· 9 9 (datasheet-recommended value is 10000). 10 10 Defining this property enables current-sense functionality. 11 11 12 + Optional threshold properties : 13 + If skipped the condition won't be reported. 14 + - maxim,cold-temp : Temperature threshold to report battery 15 + as cold (in tenths of degree Celsius). 16 + - maxim,over-heat-temp : Temperature threshold to report battery 17 + as over heated (in tenths of degree Celsius). 18 + - maxim,dead-volt : Voltage threshold to report battery 19 + as dead (in mV). 20 + - maxim,over-volt : Voltage threshold to report battery 21 + as over voltage (in mV). 22 + 12 23 Example: 13 24 14 25 battery-charger@36 { 15 26 compatible = "maxim,max17042"; 16 27 reg = <0x36>; 17 28 maxim,rsns-microohm = <10000>; 29 + maxim,over-heat-temp = <600>; 30 + maxim,over-volt = <4300>; 18 31 };
+9
drivers/power/max17042_battery.c
··· 809 809 pdata->enable_current_sense = true; 810 810 } 811 811 812 + if (of_property_read_s32(np, "maxim,cold-temp", &pdata->temp_min)) 813 + pdata->temp_min = INT_MIN; 814 + if (of_property_read_s32(np, "maxim,over-heat-temp", &pdata->temp_max)) 815 + pdata->temp_max = INT_MAX; 816 + if (of_property_read_s32(np, "maxim,dead-volt", &pdata->vmin)) 817 + pdata->vmin = INT_MIN; 818 + if (of_property_read_s32(np, "maxim,over-volt", &pdata->vmax)) 819 + pdata->vmax = INT_MAX; 820 + 812 821 return pdata; 813 822 } 814 823 #else