Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A9F9C433EF for ; Tue, 12 Oct 2021 10:47:33 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B4F660E97 for ; Tue, 12 Oct 2021 10:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B4F660E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8347D83719; Tue, 12 Oct 2021 12:47:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 0D358834D1; Tue, 12 Oct 2021 12:47:28 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 908B58372F for ; Tue, 12 Oct 2021 12:47:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 622A3101E; Tue, 12 Oct 2021 03:47:18 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64AFA3F694; Tue, 12 Oct 2021 03:47:16 -0700 (PDT) Date: Tue, 12 Oct 2021 11:47:14 +0100 From: Andre Przywara To: Samuel Holland Cc: u-boot@lists.denx.de, Jagan Teki , Jaehoon Chung , Heiko Schocher , Anatolij Gustschin , Arnaud Ferraris , Bharat Gooty , Igor Opaniuk , Jernej Skrabec , Minkyu Kang , Rayagonda Kokatanur , Simon Glass , Stephan Gerhold , Tim Harvey , Tom Rini Subject: Re: [PATCH v2 03/12] power: pmic: Add a driver for X-Powers AXP PMICs Message-ID: <20211012114714.2307da46@donnerap.cambridge.arm.com> In-Reply-To: <20211008051725.29401-4-samuel@sholland.org> References: <20211008051725.29401-1-samuel@sholland.org> <20211008051725.29401-4-samuel@sholland.org> Organization: ARM X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Fri, 8 Oct 2021 00:17:16 -0500 Samuel Holland wrote: > 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. Looks indeed like a minimal I2C passthrough DM driver. > Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara Cheers, Andre > --- > > 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 > +#include > +#include > + > +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, > +};