Przeglądaj źródła

power: supply: axp288_charger: Do not bind when the charge 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 charge function to avoid
exporting a non working power_supply class device.

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>
Hans de Goede 7 lat temu
rodzic
commit
efb440ecc1
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12 0
      drivers/power/supply/axp288_charger.c

+ 12 - 0
drivers/power/supply/axp288_charger.c

@@ -747,6 +747,18 @@ static int axp288_charger_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device *dev = &pdev->dev;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct power_supply_config charger_cfg = {};
 	struct power_supply_config charger_cfg = {};
+	unsigned int val;
+
+	/*
+	 * On some devices the fuelgauge and charger parts of the axp288 are
+	 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
+	 */
+	ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val);
+	if (ret < 0)
+		return ret;
+	if (val == 0)
+		return -ENODEV;
+
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 	if (!info)
 		return -ENOMEM;
 		return -ENOMEM;