From: Mike Looijmans <mike.looijmans@topic.nl>
To: linux-pm@vger.kernel.org
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Sebastian Reichel <sre@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 3/5] power: supply: core: Add POWER_SUPPLY_PROP_*CELL* entries
Date: Tue, 16 Apr 2024 14:18:16 +0200 [thread overview]
Message-ID: <20240416121818.543896-3-mike.looijmans@topic.nl> (raw)
In-Reply-To: <20240416121818.543896-1-mike.looijmans@topic.nl>
For multi-cell chargers (or stacks of capacitors), allow to report the
number of cells in series and the voltage of each cell.
Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
(no changes since v1)
Documentation/ABI/testing/sysfs-class-power | 51 +++++++++++++++++++++
Documentation/power/power_supply_class.rst | 7 +++
drivers/power/supply/power_supply_sysfs.c | 7 +++
include/linux/power_supply.h | 7 +++
4 files changed, 72 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index 1f6a04a17c81..f5b194ad61b3 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -516,6 +516,57 @@ Description:
Integer > 0: representing full cycles
Integer = 0: cycle_count info is not available
+What: /sys/class/power_supply/<supply_name>/number_of_serial_cells
+Date: April 2024
+Contact: linux-pm@vger.kernel.org
+Description:
+ If the energy storage is composed of multiple cells in series,
+ this provides the number of stacked cells. Parallel cells aren't
+ considered here.
+
+ Access: Read
+
+ Valid values:
+ Integer > 0: number of cells
+ Integer = 0: info is not available
+
+What: /sys/class/power_supply/<supply_name>/cell1_voltage_now
+Date: April 2024
+Contact: linux-pm@vger.kernel.org
+Description:
+ Reports an instant, single cell voltage reading. The voltage is
+ measured across the cell. The battery reports voltages for up to
+ 'number_of_serial_cells' cells, in cell2_voltage_now and so on.
+
+ Access: Read
+
+ Valid values: Represented in microvolts
+
+What: /sys/class/power_supply/<supply_name>/cell_voltage_max
+Date: April 2024
+Contact: linux-pm@vger.kernel.org
+Description:
+ Maximum allowed voltage for a single cell. This value is shared
+ across all cells in the range 1 to 'number_of_serial_cells'.
+ Typically used to trigger an alert for userspace.
+
+ Access: Read, Write
+
+ Valid values: Represented in microvolts
+
+What: /sys/class/power_supply/<supply_name>/cell_voltage_min
+Date: April 2024
+Contact: linux-pm@vger.kernel.org
+Description:
+ Minimum allowed voltage for a single cell. This value is shared
+ across all cells in the range 1 to 'number_of_serial_cells'.
+ Typically used to trigger an alert for userspace.
+
+ Access: Read, Write
+
+ Valid values: Represented in microvolts
+
+
**USB Properties**
What: /sys/class/power_supply/<supply_name>/input_current_limit
diff --git a/Documentation/power/power_supply_class.rst b/Documentation/power/power_supply_class.rst
index da8e275a14ff..42110cbbea4a 100644
--- a/Documentation/power/power_supply_class.rst
+++ b/Documentation/power/power_supply_class.rst
@@ -213,6 +213,13 @@ TIME_TO_FULL
seconds left for battery to be considered full
(i.e. while battery is charging)
+NUMBER_OF_SERIAL_CELLS
+ If the energy storage is composed of multiple cells in series, this provides
+ the number of stacked cells. Parallel cells aren't considered here.
+CELLn_VOLTAGE
+ voltage measured of the n-th cell in the stack
+CELL_VOLTAGE
+ single cell voltage when the cells share the same value (usually MIN or MAX)
Battery <-> external power supply interaction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 9d8540ce1f7e..4ea6b556f3fd 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -218,6 +218,13 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(MANUFACTURE_YEAR),
POWER_SUPPLY_ATTR(MANUFACTURE_MONTH),
POWER_SUPPLY_ATTR(MANUFACTURE_DAY),
+ POWER_SUPPLY_ATTR(NUMBER_OF_SERIAL_CELLS),
+ POWER_SUPPLY_ATTR(CELL1_VOLTAGE_NOW),
+ POWER_SUPPLY_ATTR(CELL2_VOLTAGE_NOW),
+ POWER_SUPPLY_ATTR(CELL3_VOLTAGE_NOW),
+ POWER_SUPPLY_ATTR(CELL4_VOLTAGE_NOW),
+ POWER_SUPPLY_ATTR(CELL_VOLTAGE_MIN),
+ POWER_SUPPLY_ATTR(CELL_VOLTAGE_MAX),
/* Properties of type `const char *' */
POWER_SUPPLY_ATTR(MODEL_NAME),
POWER_SUPPLY_ATTR(MANUFACTURER),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index af5a4e700881..3c208dff8af8 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -171,6 +171,13 @@ enum power_supply_property {
POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
POWER_SUPPLY_PROP_MANUFACTURE_DAY,
+ POWER_SUPPLY_PROP_NUMBER_OF_SERIAL_CELLS,
+ POWER_SUPPLY_PROP_CELL1_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CELL2_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CELL3_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CELL4_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CELL_VOLTAGE_MIN,
+ POWER_SUPPLY_PROP_CELL_VOLTAGE_MAX,
/* Properties of type `const char *' */
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
--
2.34.1
Met vriendelijke groet / kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@topic.nl
W: www.topic.nl
Please consider the environment before printing this e-mail
next prev parent reply other threads:[~2024-04-16 12:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.e2aac3eb-919a-41c3-81e9-f9030f4f80eb@emailsignatures365.codetwo.com>
2024-04-16 12:18 ` [PATCH v5 1/5] dt-bindings: power: Extend battery chemistry with capacitor Mike Looijmans
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.846cb2ab-fcec-478e-9752-6c7d0b6a347c@emailsignatures365.codetwo.com>
2024-04-16 12:18 ` [PATCH v5 2/5] power: supply: core: Add POWER_SUPPLY_TECHNOLOGY_CAPACITOR Mike Looijmans
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.dc197200-74ec-4cd3-a0dd-4f7fd874c623@emailsignatures365.codetwo.com>
2024-04-16 12:18 ` Mike Looijmans [this message]
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.217e6bb9-ab43-4da3-b354-1d8d288df2de@emailsignatures365.codetwo.com>
2024-04-16 12:18 ` [PATCH v5 4/5] dt-bindings: power: supply: ltc3350-charger: Add bindings Mike Looijmans
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.4a7cccf3-e7cb-4980-be8e-de8bd2795354@emailsignatures365.codetwo.com>
2024-04-16 12:18 ` [PATCH v5 5/5] power: supply: ltc3350-charger: Add driver Mike Looijmans
2024-05-27 20:40 ` Sebastian Reichel
2024-05-28 5:18 ` Mike Looijmans
2024-05-28 9:41 ` Mike Looijmans
2024-06-02 22:40 ` Sebastian Reichel
2024-04-20 0:56 ` [PATCH v5 1/5] dt-bindings: power: Extend battery chemistry with capacitor Krzysztof Kozlowski
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=20240416121818.543896-3-mike.looijmans@topic.nl \
--to=mike.looijmans@topic.nl \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=sre@kernel.org \
/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®