From: Svyatoslav Ryhel Date: Fri, 30 Jan 2026 13:40:21 +0000 (+0200) Subject: power: supply: cpcap-battery: pass static battery cell data from device tree X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f0c8407c83a596dcb5aeaa940b1f8ed43631ae46;p=thirdparty%2Fkernel%2Flinux.git power: supply: cpcap-battery: pass static battery cell data from device tree Add an option to populate battery cell properties from the device tree if the driver cannot access the battery's NVMEM. Signed-off-by: Svyatoslav Ryhel Reviewed-by: Tony Lindgren Link: https://patch.msgid.link/20260130134021.353688-3-clamor95@gmail.com Signed-off-by: Sebastian Reichel --- diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index f58269c755095..7b7bdce3162fc 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -404,6 +404,30 @@ static int cpcap_battery_match_nvmem(struct device *dev, const void *data) return 0; } +static void cpcap_battery_update_battery_data(struct cpcap_battery_ddata *ddata) +{ + struct power_supply_battery_info *info; + + if (power_supply_get_battery_info(ddata->psy, &info) < 0) + return; + + if (info->technology > 0) + ddata->config.info.technology = info->technology; + + if (info->voltage_max_design_uv > 0) + ddata->config.info.voltage_max_design = info->voltage_max_design_uv; + + if (info->voltage_min_design_uv > 0) + ddata->config.info.voltage_min_design = info->voltage_min_design_uv; + + if (info->charge_full_design_uah > 0) + ddata->config.info.charge_full_design = info->charge_full_design_uah; + + if (info->constant_charge_voltage_max_uv > 0) + ddata->config.bat.constant_charge_voltage_max_uv = + info->constant_charge_voltage_max_uv; +} + static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) { struct nvmem_device *nvmem; @@ -431,6 +455,9 @@ static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) default: ddata->config = cpcap_battery_unknown_data; } + + if (ddata->psy) + cpcap_battery_update_battery_data(ddata); } /**