summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSvyatoslav Ryhel <clamor95@gmail.com>2026-01-30 16:40:21 +0300
committerSebastian Reichel <sebastian.reichel@collabora.com>2026-03-04 01:58:08 +0300
commitf0c8407c83a596dcb5aeaa940b1f8ed43631ae46 (patch)
tree0f933822747775e0f1ca6a3ba707a408b361e540
parent95a1fa0b0034d11a05b6b858bd6418e2b1ccab0a (diff)
downloadlinux-f0c8407c83a596dcb5aeaa940b1f8ed43631ae46.tar.xz
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 <clamor95@gmail.com> Reviewed-by: Tony Lindgren <tony@atomide.com> Link: https://patch.msgid.link/20260130134021.353688-3-clamor95@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r--drivers/power/supply/cpcap-battery.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index f58269c75509..7b7bdce3162f 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);
}
/**