power: pmic: Add a driver for X-Powers AXP PMICs
authorSamuel Holland <samuel@sholland.org>
Fri, 8 Oct 2021 05:17:16 +0000 (00:17 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Tue, 12 Oct 2021 08:41:57 +0000 (09:41 +0100)
These PMICs provide some combination of battery charger, fuel gauge,
GPIOs, regulators, and VBUS routing. These functions are represented
as child nodes in the device tree. Add the minimal driver needed to
probe these child devices and provide the DM_PMIC ops.

Enable the driver by default for SoCs that normally pair with a PMIC.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
drivers/power/pmic/Kconfig
drivers/power/pmic/Makefile
drivers/power/pmic/axp.c [new file with mode: 0644]

index e8a0432..fcb517f 100644 (file)
@@ -63,6 +63,20 @@ config PMIC_ACT8846
        functions. It uses an I2C interface and is designed for use with
        tablets and smartphones.
 
+config PMIC_AXP
+       bool "Enable Driver Model for X-Powers AXP PMICs"
+       depends on DM_I2C
+       help
+         This config enables driver-model PMIC uclass features for
+         X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
+
+config SPL_PMIC_AXP
+       bool "Enable Driver Model for X-Powers AXP PMICs in SPL"
+       depends on SPL_DM_I2C && SPL_DM_PMIC
+       help
+         This config enables driver-model PMIC uclass features in the SPL for
+         X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
+
 config DM_PMIC_DA9063
        bool "Enable Driver Model for the Dialog DA9063 PMIC"
        help
index 5250eac..e1922df 100644 (file)
@@ -18,6 +18,7 @@ obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
 obj-$(CONFIG_PMIC_AB8500) += ab8500.o
 obj-$(CONFIG_PMIC_ACT8846) += act8846.o
 obj-$(CONFIG_PMIC_AS3722) += as3722.o as3722_gpio.o
+obj-$(CONFIG_$(SPL_)PMIC_AXP) += axp.o
 obj-$(CONFIG_PMIC_MAX8997) += max8997.o
 obj-$(CONFIG_PMIC_PM8916) += pm8916.o
 obj-$(CONFIG_$(SPL_TPL_)PMIC_RK8XX) += rk8xx.o
diff --git a/drivers/power/pmic/axp.c b/drivers/power/pmic/axp.c
new file mode 100644 (file)
index 0000000..74c94bd
--- /dev/null
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <dm.h>
+#include <i2c.h>
+#include <power/pmic.h>
+
+static int axp_pmic_reg_count(struct udevice *dev)
+{
+       /* TODO: Get the specific value from driver data. */
+       return 0x100;
+}
+
+static struct dm_pmic_ops axp_pmic_ops = {
+       .reg_count      = axp_pmic_reg_count,
+       .read           = dm_i2c_read,
+       .write          = dm_i2c_write,
+};
+
+static const struct udevice_id axp_pmic_ids[] = {
+       { .compatible = "x-powers,axp152" },
+       { .compatible = "x-powers,axp202" },
+       { .compatible = "x-powers,axp209" },
+       { .compatible = "x-powers,axp221" },
+       { .compatible = "x-powers,axp223" },
+       { .compatible = "x-powers,axp803" },
+       { .compatible = "x-powers,axp806" },
+       { .compatible = "x-powers,axp809" },
+       { .compatible = "x-powers,axp813" },
+       { }
+};
+
+U_BOOT_DRIVER(axp_pmic) = {
+       .name           = "axp_pmic",
+       .id             = UCLASS_PMIC,
+       .of_match       = axp_pmic_ids,
+       .bind           = dm_scan_fdt_dev,
+       .ops            = &axp_pmic_ops,
+};