mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 18:22:00 -04:00
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>
This commit is contained in:
committed by
Sebastian Reichel
parent
95a1fa0b00
commit
f0c8407c83
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user