power_supply: max17042: Add OF support for setting thresholds
The commitedd4ab0559
("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:edd4ab0559
("power: max17042_battery: add HEALTH and TEMP_* properties support") Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
5c6e3a97e9
commit
a6e6b63ee2
|
@ -9,10 +9,23 @@ Optional properties :
|
||||||
(datasheet-recommended value is 10000).
|
(datasheet-recommended value is 10000).
|
||||||
Defining this property enables current-sense functionality.
|
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:
|
Example:
|
||||||
|
|
||||||
battery-charger@36 {
|
battery-charger@36 {
|
||||||
compatible = "maxim,max17042";
|
compatible = "maxim,max17042";
|
||||||
reg = <0x36>;
|
reg = <0x36>;
|
||||||
maxim,rsns-microohm = <10000>;
|
maxim,rsns-microohm = <10000>;
|
||||||
|
maxim,over-heat-temp = <600>;
|
||||||
|
maxim,over-volt = <4300>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -809,6 +809,15 @@ max17042_get_pdata(struct device *dev)
|
||||||
pdata->enable_current_sense = true;
|
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;
|
return pdata;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue