OSDN Git Service

power: supply: add charge_behaviour attributes
authorThomas Weißschuh <linux@weissschuh.net>
Tue, 23 Nov 2021 23:27:01 +0000 (00:27 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 21 Dec 2021 15:27:09 +0000 (16:27 +0100)
This a revised version of
"[RFC] add standardized attributes for force_discharge and inhibit_charge" [0],
incorporating discussion results.

The biggest change is the switch from two boolean attributes to a single
enum attribute.

[0] https://lore.kernel.org/platform-driver-x86/21569a89-8303-8573-05fb-c2fec29983d1@gmail.com/

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20211123232704.25394-2-linux@weissschuh.net
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Documentation/ABI/testing/sysfs-class-power
include/linux/power_supply.h

index f7904ef..cece094 100644 (file)
@@ -455,6 +455,20 @@ Description:
                              "Unknown", "Charging", "Discharging",
                              "Not charging", "Full"
 
+What:          /sys/class/power_supply/<supply_name>/charge_behaviour
+Date:          November 2021
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Represents the charging behaviour.
+
+               Access: Read, Write
+
+               Valid values:
+                       ================ ====================================
+                       auto:            Charge normally, respect thresholds
+                       inhibit-charge:  Do not charge while AC is attached
+                       force-discharge: Force discharge while AC is attached
+
 What:          /sys/class/power_supply/<supply_name>/technology
 Date:          May 2007
 Contact:       linux-pm@vger.kernel.org
index 9ca1f12..70c333e 100644 (file)
@@ -132,6 +132,7 @@ enum power_supply_property {
        POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
        POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD, /* in percents! */
        POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, /* in percents! */
+       POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR,
        POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
        POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT,
        POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
@@ -202,6 +203,12 @@ enum power_supply_usb_type {
        POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID,   /* Apple Charging Method */
 };
 
+enum power_supply_charge_behaviour {
+       POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO = 0,
+       POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE,
+       POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE,
+};
+
 enum power_supply_notifier_events {
        PSY_EVENT_PROP_CHANGED,
 };