[PATCH v2 3/9] power: supply: Support battery temperature device-tree properties
From: Dmitry Osipenko
Date: Sun Jun 07 2020 - 10:46:03 EST
The generic battery temperature properties are already supported by the
power-supply core. Let's support parsing of the common battery temperature
properties from a device-tree.
Signed-off-by: Dmitry Osipenko <digetx@xxxxxxxxx>
---
drivers/power/supply/power_supply_core.c | 18 ++++++++++++++++++
include/linux/power_supply.h | 6 ++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 02b37fe6061c..8b54a5a107d7 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -579,6 +579,12 @@ int power_supply_get_battery_info(struct power_supply *psy,
info->charge_term_current_ua = -EINVAL;
info->constant_charge_current_max_ua = -EINVAL;
info->constant_charge_voltage_max_uv = -EINVAL;
+ info->temp_ambient_alert_min = INT_MIN;
+ info->temp_ambient_alert_max = INT_MAX;
+ info->temp_alert_min = INT_MIN;
+ info->temp_alert_max = INT_MAX;
+ info->temp_min = INT_MIN;
+ info->temp_max = INT_MAX;
info->factory_internal_resistance_uohm = -EINVAL;
info->resist_table = NULL;
@@ -638,6 +644,18 @@ int power_supply_get_battery_info(struct power_supply *psy,
&info->constant_charge_voltage_max_uv);
of_property_read_u32(battery_np, "factory-internal-resistance-micro-ohms",
&info->factory_internal_resistance_uohm);
+ of_property_read_u32(battery_np, "temperature-ambient-min-alert-celsius",
+ &info->temp_ambient_alert_min);
+ of_property_read_u32(battery_np, "temperature-ambient-max-alert-celsius",
+ &info->temp_ambient_alert_max);
+ of_property_read_u32(battery_np, "temperature-min-alert-celsius",
+ &info->temp_alert_min);
+ of_property_read_u32(battery_np, "temperature-max-alert-celsius",
+ &info->temp_alert_max);
+ of_property_read_u32(battery_np, "temperature-min-celsius",
+ &info->temp_min);
+ of_property_read_u32(battery_np, "temperature-max-celsius",
+ &info->temp_max);
len = of_property_count_u32_elems(battery_np, "ocv-capacity-celsius");
if (len < 0 && len != -EINVAL) {
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..31fcadd81d63 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -361,6 +361,12 @@ struct power_supply_battery_info {
int constant_charge_voltage_max_uv; /* microVolts */
int factory_internal_resistance_uohm; /* microOhms */
int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */
+ int temp_ambient_alert_min; /* celsius */
+ int temp_ambient_alert_max; /* celsius */
+ int temp_alert_min; /* celsius */
+ int temp_alert_max; /* celsius */
+ int temp_min; /* celsius */
+ int temp_max; /* celsius */
struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX];
int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
struct power_supply_resistance_temp_table *resist_table;
--
2.26.0