]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} properties
authorNick Crews <ncrews@chromium.org>
Thu, 18 Apr 2019 16:43:13 +0000 (10:43 -0600)
committerSebastian Reichel <sre@kernel.org>
Wed, 1 May 2019 23:11:32 +0000 (01:11 +0200)
Add POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD
and POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties, to expand
the existing CHARGE_CONTROL_* properties. I am adding them in order
to support a new Chrome OS device, but these properties should be
general enough that they can be used on other devices.

When the charge_type is "Custom", the charge controller uses the
POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some
other algorithm. For example, in the use case that I am supporting,
this means the battery begins charging when the percentage
level drops below POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and
charging ceases when the percentage level goes above
POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD.

v5 changes:
- Add the other missing CHARGE_CONTROL_* properties documentation in
  a separate commit
- Split up adding the charge types and adding the
  POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and
  POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties into
  two different commits.
v4 changes:
- Add documentation for the new properties, and add documentation for
  the the previously missing charge_control_limit and
  charge_control_limit_max properties.

Signed-off-by: Nick Crews <ncrews@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Documentation/ABI/testing/sysfs-class-power
drivers/power/supply/power_supply_sysfs.c
include/linux/power_supply.h

index 544c4e0ef8b678c4a9f599bbfb5bedf86a665b5f..a5b144f61de8428504d888f5114dcdcab2486b14 100644 (file)
@@ -114,6 +114,26 @@ Description:
                Access: Read
                Valid values: Represented in microamps
 
+What:          /sys/class/power_supply/<supply_name>/charge_control_start_threshold
+Date:          April 2019
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Represents a battery percentage level, below which charging will
+               begin.
+
+               Access: Read, Write
+               Valid values: 0 - 100 (percent)
+
+What:          /sys/class/power_supply/<supply_name>/charge_control_end_threshold
+Date:          April 2019
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Represents a battery percentage level, above which charging will
+               stop.
+
+               Access: Read, Write
+               Valid values: 0 - 100 (percent)
+
 What:          /sys/class/power_supply/<supply_name>/charge_type
 Date:          July 2009
 Contact:       linux-pm@vger.kernel.org
index 64dff5cfecc322f4241b67c12a3b1f5470719a53..6104a3f03d46de7b3d5a570c2e132fb098dd81a3 100644 (file)
@@ -274,6 +274,8 @@ static struct device_attribute power_supply_attrs[] = {
        POWER_SUPPLY_ATTR(constant_charge_voltage_max),
        POWER_SUPPLY_ATTR(charge_control_limit),
        POWER_SUPPLY_ATTR(charge_control_limit_max),
+       POWER_SUPPLY_ATTR(charge_control_start_threshold),
+       POWER_SUPPLY_ATTR(charge_control_end_threshold),
        POWER_SUPPLY_ATTR(input_current_limit),
        POWER_SUPPLY_ATTR(energy_full_design),
        POWER_SUPPLY_ATTR(energy_empty_design),
index e86e05d8134da1ec6632bf06538f269a0f409473..d59205170232ce54d489038cb93fda78f911af28 100644 (file)
@@ -125,6 +125,8 @@ enum power_supply_property {
        POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
        POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
        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_INPUT_CURRENT_LIMIT,
        POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
        POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,