aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2018-04-18 08:08:21 -0400
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>2018-04-25 18:44:52 -0400
commit04d6f72f68eac61abbdaf56dcbfcc8382542f07e (patch)
tree968f726b2cb8951d22d62949292c75cf954dc31e
parentefb440ecc15610539dc7a177ae8eed4bf536da06 (diff)
power: supply: axp288_fuelguage: Do not bind when the fg function is not used
Some devices with an AXP288 PMIC do not have a battery at all, or use external charger and fuelgauge ICs instead of the AXP288 builtin functionality. On such devices we should not bind to the fuelgauge function to avoid exporting a non working power_supply class device. This also avoids the following errors repeating over and over again in dmesg: axp288_fuel_gauge axp288_fuel_gauge: capacity measurement not valid axp288_fuel_gauge axp288_fuel_gauge: Error 0xe2 contents not valid power_supply axp288_fuel_gauge: driver failed to report 'charge_now' property: -6 Cc: Carlo Caione <carlo@endlessm.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
-rw-r--r--drivers/power/supply/axp288_fuel_gauge.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index fd8f0b2210bc..dabcf0c6ea95 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -754,10 +754,21 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
754 [BAT_D_CURR] = "axp288-chrg-d-curr", 754 [BAT_D_CURR] = "axp288-chrg-d-curr",
755 [BAT_VOLT] = "axp288-batt-volt", 755 [BAT_VOLT] = "axp288-batt-volt",
756 }; 756 };
757 unsigned int val;
757 758
758 if (dmi_check_system(axp288_fuel_gauge_blacklist)) 759 if (dmi_check_system(axp288_fuel_gauge_blacklist))
759 return -ENODEV; 760 return -ENODEV;
760 761
762 /*
763 * On some devices the fuelgauge and charger parts of the axp288 are
764 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
765 */
766 ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val);
767 if (ret < 0)
768 return ret;
769 if (val == 0)
770 return -ENODEV;
771
761 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 772 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
762 if (!info) 773 if (!info)
763 return -ENOMEM; 774 return -ENOMEM;