[PATCH 2/3] power: supply: core: Read the charging temperature range and alert settings
From: Alexey Charkov
Date: Mon Nov 09 2026 - 04:47:57 EST
Read charge-temp-range-celsius into new temp_charge_min and
temp_charge_max fields, falling back to the operating range when it is
absent, so that a charger can stop charging outside a narrower range
while the battery stays in use. Read the alert-*-temp-charge-*
properties into the existing alert_*_temp_charge_* fields, which no
firmware description could set before, and document them as applying
between the alert and charging limits.
Signed-off-by: Alexey Charkov <alchark@xxxxxxxxxxx>
---
drivers/power/supply/power_supply_core.c | 16 ++++++++++++++++
include/linux/power_supply.h | 16 ++++++++++++----
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index de15314ef954..3bfc4fb8687e 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -855,6 +855,14 @@ int power_supply_get_battery_info(struct power_supply *psy,
&info->constant_charge_voltage_max_uv);
fwnode_property_read_u32(fwnode, "factory-internal-resistance-micro-ohms",
&info->factory_internal_resistance_uohm);
+ fwnode_property_read_u32(fwnode, "alert-low-temp-charge-current-microamp",
+ &info->alert_low_temp_charge_current_ua);
+ fwnode_property_read_u32(fwnode, "alert-low-temp-charge-voltage-microvolt",
+ &info->alert_low_temp_charge_voltage_uv);
+ fwnode_property_read_u32(fwnode, "alert-high-temp-charge-current-microamp",
+ &info->alert_high_temp_charge_current_ua);
+ fwnode_property_read_u32(fwnode, "alert-high-temp-charge-voltage-microvolt",
+ &info->alert_high_temp_charge_voltage_uv);
if (!fwnode_property_read_u32_array(fwnode, "ambient-celsius",
min_max, ARRAY_SIZE(min_max))) {
@@ -871,6 +879,14 @@ int power_supply_get_battery_info(struct power_supply *psy,
info->temp_min = min_max[0];
info->temp_max = min_max[1];
}
+ if (!fwnode_property_read_u32_array(fwnode, "charge-temp-range-celsius",
+ min_max, ARRAY_SIZE(min_max))) {
+ info->temp_charge_min = min_max[0];
+ info->temp_charge_max = min_max[1];
+ } else {
+ info->temp_charge_min = info->temp_min;
+ info->temp_charge_max = info->temp_max;
+ }
len = fwnode_property_count_u32(fwnode, "ocv-capacity-celsius");
if (len < 0 && len != -EINVAL) {
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index cce61137aef4..246fba40ea78 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -559,15 +559,15 @@ struct power_supply_maintenance_charge_table {
* maintenance_charge.
* @alert_low_temp_charge_current_ua: The charging current to use if the battery
* enters low alert temperature, i.e. if the internal temperature is between
- * temp_alert_min and temp_min. No matter the charging phase, this
+ * temp_charge_min and temp_alert_min. No matter the charging phase, this
* and alert_high_temp_charge_voltage_uv will be applied.
* @alert_low_temp_charge_voltage_uv: Same as alert_low_temp_charge_current_ua,
* but for the charging voltage.
* @alert_high_temp_charge_current_ua: The charging current to use if the
* battery enters high alert temperature, i.e. if the internal temperature is
- * between temp_alert_max and temp_max. No matter the charging phase, this
- * and alert_high_temp_charge_voltage_uv will be applied, usually lowering
- * the charging current as an evasive manouver.
+ * between temp_alert_max and temp_charge_max. No matter the charging phase,
+ * this and alert_high_temp_charge_voltage_uv will be applied, usually
+ * lowering the charging current as an evasive manouver.
* @alert_high_temp_charge_voltage_uv: Same as
* alert_high_temp_charge_current_ua, but for the charging voltage.
* @factory_internal_resistance_uohm: the internal resistance of the battery
@@ -603,6 +603,12 @@ struct power_supply_maintenance_charge_table {
* @temp_max: the battery will go outside of operating conditions when
* the internal temperature goes above this temperature in degrees Celsius.
* Normally this means the system should shut down.
+ * @temp_charge_min: the battery must not be charged when the internal
+ * temperature is below this temperature in degrees Celsius. Defaults to
+ * temp_min.
+ * @temp_charge_max: the battery must not be charged when the internal
+ * temperature is above this temperature in degrees Celsius. Defaults to
+ * temp_max.
* @ocv_table: for each entry in ocv_temp there is a corresponding entry in
* ocv_table and a size for each entry in ocv_table_size. These arrays
* determine the capacity in percent in relation to the voltage in microvolts
@@ -826,6 +832,8 @@ struct power_supply_battery_info {
int temp_alert_max;
int temp_min;
int temp_max;
+ int temp_charge_min;
+ int temp_charge_max;
const struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX];
int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
const struct power_supply_resistance_temp_table *resist_table;
--
2.56.0