mfd: axp20x: Add supplied-from property to axp288_fuel_gauge cell
authorHans de Goede <hdegoede@redhat.com>
Sat, 17 Jul 2021 16:25:28 +0000 (18:25 +0200)
committerLee Jones <lee.jones@linaro.org>
Thu, 5 Aug 2021 13:11:04 +0000 (14:11 +0100)
The power-supply framework has the notion of one power-supply device
being supplied by another. A typical example of this is a charger
charging a battery.

A tablet getting plugged in to charge (or plugged out) only results in
events seen by the axp288_charger device / MFD cell. Which means that
a change udev-event only gets send for the charger power-supply class
device, not for the battery (the axp288_fuel_gauge device).

The axp288_fuel_gauge does have an external_power_change'd callback
which will generate a change udev-event when called. But before this
commit this never got called because the power-supply core only calls
this when a power-supply class device's supplier changes and the
supplier link from axp288_charger to axp288_fuel_gauge was missing.

Add a "supplied-from" property to axp288_fuel_gauge cell, pointing
to the "axp288_charger" power-supply class device, so that the
axp288_fuel_gauge's external_power_change'd callback gets called on
axp288_charger state changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/axp20x.c

index d0ac019850d170ed867c57ae796376e88ad4e320..8161a5dc68e84bbd8eb6e20c32ea6f3afa0bc55e 100644 (file)
@@ -700,6 +700,18 @@ static const struct resource axp288_charger_resources[] = {
        DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
 };
 
+static const char * const axp288_fuel_gauge_suppliers[] = { "axp288_charger" };
+
+static const struct property_entry axp288_fuel_gauge_properties[] = {
+       PROPERTY_ENTRY_STRING_ARRAY("supplied-from", axp288_fuel_gauge_suppliers),
+       { }
+};
+
+static const struct software_node axp288_fuel_gauge_sw_node = {
+       .name = "axp288_fuel_gauge",
+       .properties = axp288_fuel_gauge_properties,
+};
+
 static const struct mfd_cell axp288_cells[] = {
        {
                .name           = "axp288_adc",
@@ -717,6 +729,7 @@ static const struct mfd_cell axp288_cells[] = {
                .name           = "axp288_fuel_gauge",
                .num_resources  = ARRAY_SIZE(axp288_fuel_gauge_resources),
                .resources      = axp288_fuel_gauge_resources,
+               .swnode         = &axp288_fuel_gauge_sw_node,
        }, {
                .name           = "axp221-pek",
                .num_resources  = ARRAY_SIZE(axp288_power_button_resources),