All of lore.kernel.org
 help / color / mirror / Atom feed
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 v4 3/5] power: supply: core: Add POWER_SUPPLY_PROP_*CELL* entries
Date: Mon, 15 Apr 2024 10:13:03 +0200	[thread overview]
Message-ID: <20240415081305.316107-3-mike.looijmans@topic.nl> (raw)
In-Reply-To: <20240415081305.316107-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

  parent reply	other threads:[~2024-04-15  8:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.b2a893bc-f00b-47cf-ae07-b37ec1bace22@emailsignatures365.codetwo.com>
2024-04-15  8:13 ` [PATCH v4 1/5] dt-bindings: power: Extend battery chemistry with capacitor Mike Looijmans
     [not found]   ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.0aecd676-868f-4018-bb2f-56c7fe7c18ff@emailsignatures365.codetwo.com>
2024-04-15  8:13     ` [PATCH v4 2/5] power: supply: core: Add POWER_SUPPLY_TECHNOLOGY_CAPACITOR Mike Looijmans
     [not found]   ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.9dd4ffd7-8f51-463b-bf4f-d1ff27030b84@emailsignatures365.codetwo.com>
2024-04-15  8:13     ` Mike Looijmans [this message]
     [not found]   ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.9959538d-6257-47d8-9ef7-78f72d89b9a7@emailsignatures365.codetwo.com>
2024-04-15  8:13     ` [PATCH v4 4/5] dt-bindings: power: supply: ltc3350-charger: Add bindings Mike Looijmans
     [not found]   ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.f3ad88bc-748d-4d1b-abcf-bcf420d05ddf@emailsignatures365.codetwo.com>
2024-04-15  8:13     ` [PATCH v4 5/5] power: supply: ltc3350-charger: Add driver Mike Looijmans
2024-04-15 15:24   ` [PATCH v4 1/5] dt-bindings: power: Extend battery chemistry with capacitor Krzysztof Kozlowski
2024-04-22  7:50     ` Mike Looijmans
2024-04-22 11:56       ` Krzysztof Kozlowski
2024-04-22 12:12         ` Mike Looijmans

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=20240415081305.316107-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.