All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: u-boot@lists.denx.de, Jagan Teki <jagan@amarulasolutions.com>,
	Andre Przywara <andre.przywara@arm.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Heiko Schocher <hs@denx.de>, Samuel Holland <samuel@sholland.org>,
	Anatolij Gustschin <agust@denx.de>,
	Arnaud Ferraris <arnaud.ferraris@gmail.com>,
	Bharat Gooty <bharat.gooty@broadcom.com>,
	Igor Opaniuk <igor.opaniuk@gmail.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Minkyu Kang <mk7.kang@samsung.com>,
	Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>,
	Simon Glass <sjg@chromium.org>,
	Stephan Gerhold <stephan@gerhold.net>,
	Tim Harvey <tharvey@gateworks.com>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 03/12] power: pmic: Add a driver for X-Powers AXP PMICs
Date: Fri,  8 Oct 2021 00:17:16 -0500	[thread overview]
Message-ID: <20211008051725.29401-4-samuel@sholland.org> (raw)
In-Reply-To: <20211008051725.29401-1-samuel@sholland.org>

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>
---

Changes in v2:
- Replace axp_pmic_bind() with `.bind = dm_scan_fdt_dev`

 drivers/power/pmic/Kconfig  | 14 ++++++++++++++
 drivers/power/pmic/Makefile |  1 +
 drivers/power/pmic/axp.c    | 38 +++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/power/pmic/axp.c

diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index e8a04325f85..fcb517f1044 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -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
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 5250eac12f2..e1922df00f8 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -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
index 00000000000..74c94bdb47b
--- /dev/null
+++ b/drivers/power/pmic/axp.c
@@ -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,
+};
-- 
2.32.0


  parent reply	other threads:[~2021-10-08  5:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  5:17 [PATCH v2 00/12] sunxi: Migrate to DM_I2C Samuel Holland
2021-10-08  5:17 ` [PATCH v2 01/12] power: pmic: Consistently depend on DM_PMIC Samuel Holland
2021-10-08  5:17 ` [PATCH v2 02/12] power: pmic: Consistently depend on SPL_DM_PMIC Samuel Holland
2021-10-12 10:46   ` Andre Przywara
2021-10-08  5:17 ` Samuel Holland [this message]
2021-10-12 10:47   ` [PATCH v2 03/12] power: pmic: Add a driver for X-Powers AXP PMICs Andre Przywara
2021-10-08  5:17 ` [PATCH v2 04/12] sunxi: Only initialize legacy I2C when enabled Samuel Holland
2021-10-12 10:47   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 05/12] sunxi: Select SUN8I_RSB more carefully Samuel Holland
2021-10-12 10:47   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 06/12] sunxi: pmic_bus: Fix Kconfig dependencies Samuel Holland
2021-10-08  5:17 ` [PATCH v2 07/12] i2c: Add a DM_I2C driver for the sun6i P2WI controller Samuel Holland
2021-10-12 10:49   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 08/12] i2c: Add a DM_I2C driver for the sun8i RSB controller Samuel Holland
2021-10-12 10:49   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 09/12] sunxi: pmic_bus: Clean up preprocessor conditions Samuel Holland
2021-10-12 10:49   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 10/12] sunxi: pmic_bus: Use the DM PMIC interface when possible Samuel Holland
2021-10-12 10:49   ` Andre Przywara
2021-10-08  5:17 ` [PATCH v2 11/12] sunxi: video: Convert panel I2C to use DM_I2C Samuel Holland
2021-10-08  5:17 ` [PATCH v2 12/12] sunxi: Enable DM_I2C for all sunxi boards Samuel Holland
2021-10-12 11:24 ` [PATCH v2 00/12] sunxi: Migrate to DM_I2C Andre Przywara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211008051725.29401-4-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=agust@denx.de \
    --cc=andre.przywara@arm.com \
    --cc=arnaud.ferraris@gmail.com \
    --cc=bharat.gooty@broadcom.com \
    --cc=hs@denx.de \
    --cc=igor.opaniuk@gmail.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=mk7.kang@samsung.com \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=sjg@chromium.org \
    --cc=stephan@gerhold.net \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.