]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
power: supply: core: Add Standard, Adaptive, and Custom charge types
authorNick Crews <ncrews@chromium.org>
Thu, 18 Apr 2019 16:43:12 +0000 (10:43 -0600)
committerSebastian Reichel <sre@kernel.org>
Wed, 1 May 2019 23:11:25 +0000 (01:11 +0200)
Add "Standard", "Adaptive", and "Custom" modes to the charge_type
property, to expand the existing "Trickle" and "Fast" modes.
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.

The meaning of "Standard" is obvious, but "Adaptive" and "Custom" are
more tricky: "Adaptive" means that the charge controller uses some
custom algorithm to change the charge type automatically, with no
configuration needed. "Custom" means that the charge controller uses the
POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some
other algorithm.

v5 changes:
- 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 5e23e22dce1b514d133ac6371163da37fe5a7ed1..544c4e0ef8b678c4a9f599bbfb5bedf86a665b5f 100644 (file)
@@ -119,10 +119,16 @@ Date:             July 2009
 Contact:       linux-pm@vger.kernel.org
 Description:
                Represents the type of charging currently being applied to the
-               battery.
+               battery. "Trickle", "Fast", and "Standard" all mean different
+               charging speeds. "Adaptive" means that the charger uses some
+               algorithm to adjust the charge rate dynamically, without
+               any user configuration required. "Custom" means that the charger
+               uses the charge_control_* properties as configuration for some
+               different algorithm.
 
-               Access: Read
-               Valid values: "Unknown", "N/A", "Trickle", "Fast"
+               Access: Read, Write
+               Valid values: "Unknown", "N/A", "Trickle", "Fast", "Standard",
+                             "Adaptive", "Custom"
 
 What:          /sys/class/power_supply/<supply_name>/charge_term_current
 Date:          July 2014
index dce24f596160973f4b6e27827741d17e86f7e73c..64dff5cfecc322f4241b67c12a3b1f5470719a53 100644 (file)
@@ -56,7 +56,7 @@ static const char * const power_supply_status_text[] = {
 };
 
 static const char * const power_supply_charge_type_text[] = {
-       "Unknown", "N/A", "Trickle", "Fast"
+       "Unknown", "N/A", "Trickle", "Fast", "Standard", "Adaptive", "Custom"
 };
 
 static const char * const power_supply_health_text[] = {
index 2f9c201a54d1b6865640ed297fd61168ae9b7e10..e86e05d8134da1ec6632bf06538f269a0f409473 100644 (file)
@@ -40,11 +40,15 @@ enum {
        POWER_SUPPLY_STATUS_FULL,
 };
 
+/* What algorithm is the charger using? */
 enum {
        POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0,
        POWER_SUPPLY_CHARGE_TYPE_NONE,
-       POWER_SUPPLY_CHARGE_TYPE_TRICKLE,
-       POWER_SUPPLY_CHARGE_TYPE_FAST,
+       POWER_SUPPLY_CHARGE_TYPE_TRICKLE,       /* slow speed */
+       POWER_SUPPLY_CHARGE_TYPE_FAST,          /* fast speed */
+       POWER_SUPPLY_CHARGE_TYPE_STANDARD,      /* normal speed */
+       POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE,      /* dynamically adjusted speed */
+       POWER_SUPPLY_CHARGE_TYPE_CUSTOM,        /* use CHARGE_CONTROL_* props */
 };
 
 enum {