From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Sebastian Reichel <sre@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Tony Lindgren <tony@atomide.com>,
Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/2] power: supply: cpcap-battery: pass static battery cell data from device tree
Date: Fri, 30 Jan 2026 15:40:21 +0200 [thread overview]
Message-ID: <20260130134021.353688-3-clamor95@gmail.com> (raw)
In-Reply-To: <20260130134021.353688-1-clamor95@gmail.com>
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>
---
drivers/power/supply/cpcap-battery.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 507fdc1c866d..9e686ba20282 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_unkown_data;
}
+
+ if (ddata->psy)
+ cpcap_battery_update_battery_data(ddata);
}
/**
--
2.51.0
next prev parent reply other threads:[~2026-01-30 13:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 13:40 [PATCH v1 0/2] " Svyatoslav Ryhel
2026-01-30 13:40 ` [PATCH v1 1/2] dt-bindings: power: supply: cpcap-battery: document monitored-battery property Svyatoslav Ryhel
2026-02-09 17:57 ` Rob Herring (Arm)
2026-01-30 13:40 ` Svyatoslav Ryhel [this message]
2026-02-06 4:24 ` [PATCH v1 2/2] power: supply: cpcap-battery: pass static battery cell data from device tree Tony Lindgren
2026-03-02 7:44 ` [PATCH v1 0/2] " Svyatoslav Ryhel
2026-03-02 23:51 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260130134021.353688-3-clamor95@gmail.com \
--to=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®