platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] add standardized attributes for force_discharge and inhibit_charge
@ 2021-09-28 20:11 Nicolò Piazzalunga
  2021-09-29  9:38 ` Hans de Goede
  2021-09-29 16:22 ` Nicolò Piazzalunga
  0 siblings, 2 replies; 16+ messages in thread
From: Nicolò Piazzalunga @ 2021-09-28 20:11 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, platform-driver-x86, Thomas Koch, smclt30p

Hi Sebastian,

this is a proposal to introduce separate and standardized attributes
for force_discharge and inhibit_charge of a battery.
These are simpler than using status from a user-space perspective,
as discussed on the platform-driver-x86 mail list.

Regards,
Nicolò

---
 Documentation/ABI/testing/sysfs-class-power | 27 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  2 ++
 include/linux/power_supply.h                |  2 ++
 3 files changed, 31 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index ca830c6cd809..2c5f48f49273 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -455,6 +455,33 @@ Description:
 			      "Unknown", "Charging", "Discharging",
 			      "Not charging", "Full"
 
+What:		/sys/class/power_supply/<supply_name>/force_discharge
+Date:		September 2021
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Represents the forced discharging status of the battery.
+
+		Access: Read, Write
+
+		Valid values:
+			== ====================================
+			0: Force discharge while AC is attached
+			1: Terminate forced discharging
+
+What:		/sys/class/power_supply/<supply_name>/inhibit_charge
+Date:		September 2021
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Represents the presence of a manual override over the threshold
+		attributes of the battery, thus inhibiting battery charge.
+
+		Access: Read, Write
+
+		Valid values:
+			== ======================
+			1: Stop charging
+			0: Terminate the override
+
 What:		/sys/class/power_supply/<supply_name>/technology
 Date:		May 2007
 Contact:	linux-pm@vger.kernel.org
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index c3d7cbcd4fad..6e7303935810 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -136,6 +136,8 @@ static const char * const POWER_SUPPLY_SCOPE_TEXT[] = {
 static struct power_supply_attr power_supply_attrs[] = {
 	/* Properties of type `int' */
 	POWER_SUPPLY_ENUM_ATTR(STATUS),
+	POWER_SUPPLY_ENUM_ATTR(FORCE_DISCHARGE),
+	POWER_SUPPLY_ENUM_ATTR(INHIBIT_CHARGE),
 	POWER_SUPPLY_ENUM_ATTR(CHARGE_TYPE),
 	POWER_SUPPLY_ENUM_ATTR(HEALTH),
 	POWER_SUPPLY_ATTR(PRESENT),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 9ca1f120a211..4340fe65df4d 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -96,6 +96,8 @@ enum {
 enum power_supply_property {
 	/* Properties of type `int' */
 	POWER_SUPPLY_PROP_STATUS = 0,
+	POWER_SUPPLY_PROP_FORCE_DISCHARGE,
+	POWER_SUPPLY_PROP_INHIBIT_CHARGE,
 	POWER_SUPPLY_PROP_CHARGE_TYPE,
 	POWER_SUPPLY_PROP_HEALTH,
 	POWER_SUPPLY_PROP_PRESENT,
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-10-07 11:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 20:11 [RFC] add standardized attributes for force_discharge and inhibit_charge Nicolò Piazzalunga
2021-09-29  9:38 ` Hans de Goede
2021-10-05 16:23   ` Sebastian Reichel
2021-10-05 18:01     ` Hans de Goede
2021-10-05 22:06       ` Sebastian Reichel
2021-10-06  8:10         ` Hans de Goede
2021-10-06 14:39           ` Sebastian Reichel
2021-10-06 14:49           ` Thomas Weißschuh
2021-10-06 15:27             ` Hans de Goede
2021-10-06 16:28               ` Sebastian Reichel
2021-10-06 17:47                 ` Hans de Goede
2021-10-06 19:24                   ` Thomas Koch
2021-10-06 21:39                     ` Thomas Weißschuh
2021-10-07  5:56                       ` Thomas Koch
2021-10-07 11:28                         ` Sebastian Reichel
2021-09-29 16:22 ` Nicolò Piazzalunga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).