]> www.infradead.org Git - users/willy/xarray.git/commitdiff
power: supply: bq24190_charger: Add support for "charge_types" property
authorHans de Goede <hdegoede@redhat.com>
Wed, 11 Dec 2024 17:44:50 +0000 (18:44 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 12 Dec 2024 23:39:38 +0000 (00:39 +0100)
The bq24190 power_supply class device has a writeable "charge_type"
property, add support for the new "charge_types" property. Reading this
returns a list of supported charge-types with the currently active type
surrounded by square brackets, allowing userspace to find out which
enum power_supply_charge_type values are supported.

This has been tested on a GPD win gaming-handheld.

Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241211174451.355421-4-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq24190_charger.c

index b71e21a0196a4becace5233c1cbe89c24e2004e2..1e49de3241811d1fbb5bce845d3fdcddb001d9d7 100644 (file)
@@ -1313,6 +1313,7 @@ static int bq24190_charger_get_property(struct power_supply *psy,
 
        switch (psp) {
        case POWER_SUPPLY_PROP_CHARGE_TYPE:
+       case POWER_SUPPLY_PROP_CHARGE_TYPES:
                ret = bq24190_charger_get_charge_type(bdi, val);
                break;
        case POWER_SUPPLY_PROP_HEALTH:
@@ -1393,6 +1394,7 @@ static int bq24190_charger_set_property(struct power_supply *psy,
                ret = bq24190_charger_set_temp_alert_max(bdi, val);
                break;
        case POWER_SUPPLY_PROP_CHARGE_TYPE:
+       case POWER_SUPPLY_PROP_CHARGE_TYPES:
                ret = bq24190_charger_set_charge_type(bdi, val);
                break;
        case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
@@ -1421,6 +1423,7 @@ static int bq24190_charger_property_is_writeable(struct power_supply *psy,
        case POWER_SUPPLY_PROP_ONLINE:
        case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
        case POWER_SUPPLY_PROP_CHARGE_TYPE:
+       case POWER_SUPPLY_PROP_CHARGE_TYPES:
        case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
        case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
        case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
@@ -1469,6 +1472,7 @@ static void bq24190_charger_external_power_changed(struct power_supply *psy)
 
 static enum power_supply_property bq24190_charger_properties[] = {
        POWER_SUPPLY_PROP_CHARGE_TYPE,
+       POWER_SUPPLY_PROP_CHARGE_TYPES,
        POWER_SUPPLY_PROP_HEALTH,
        POWER_SUPPLY_PROP_ONLINE,
        POWER_SUPPLY_PROP_STATUS,
@@ -1498,6 +1502,9 @@ static const struct power_supply_desc bq24190_charger_desc = {
        .set_property           = bq24190_charger_set_property,
        .property_is_writeable  = bq24190_charger_property_is_writeable,
        .external_power_changed = bq24190_charger_external_power_changed,
+       .charge_types           = BIT(POWER_SUPPLY_CHARGE_TYPE_NONE)    |
+                                 BIT(POWER_SUPPLY_CHARGE_TYPE_TRICKLE) |
+                                 BIT(POWER_SUPPLY_CHARGE_TYPE_FAST),
 };
 
 /* Battery power supply property routines */