All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Heiko Schocher <hs@denx.de>, 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@siol.net>,
	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>,
	u-boot@lists.denx.de, Jagan Teki <jagan@amarulasolutions.com>,
	Andre Przywara <andre.przywara@arm.com>
Subject: Re: [PATCH 05/11] power: pmic: Add a driver for X-Powers AXP PMICs
Date: Thu, 2 Sep 2021 18:23:07 -0500	[thread overview]
Message-ID: <8330e10e-3962-8056-2777-d8ae386be8e7@sholland.org> (raw)
In-Reply-To: <af400db1-5c47-ad45-98e6-3d8e2a2bcaf6@samsung.com>

On 9/2/21 6:17 PM, Jaehoon Chung wrote:
> On 8/22/21 8:05 AM, 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.
>>
>> Signed-off-by: Samuel Holland <samuel@sholland.org>
>> ---
>>
>>  drivers/power/pmic/Kconfig  | 14 +++++++++++
>>  drivers/power/pmic/Makefile |  1 +
>>  drivers/power/pmic/axp.c    | 49 +++++++++++++++++++++++++++++++++++++
>>  3 files changed, 64 insertions(+)
>>  create mode 100644 drivers/power/pmic/axp.c
>>
>> diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
>> index 0c4da9c5536..6a3e82e1be7 100644
>> --- a/drivers/power/pmic/Kconfig
>> +++ b/drivers/power/pmic/Kconfig
>> @@ -57,6 +57,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 6e40c0971fb..4021be8e801 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_PMIC_RK8XX) += rk8xx.o
>> diff --git a/drivers/power/pmic/axp.c b/drivers/power/pmic/axp.c
>> new file mode 100644
>> index 00000000000..7720e1afd9b
>> --- /dev/null
>> +++ b/drivers/power/pmic/axp.c
>> @@ -0,0 +1,49 @@
>> +// 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 int axp_pmic_bind(struct udevice *dev)
>> +{
>> +	int ret;
>> +
>> +	ret = dm_scan_fdt_dev(dev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	return 0;
> 
> return dm_scan_fdt_dev(); ?
> 
> or { .bind = dm_scan_fdt_dev, } ?

The PMIC will eventually need to do more in this function, including
binding a sysreset device[1] and regulators, so this minimized the diff.
I do like the idea of .bind = dm_scan_fdt_dev, so I will plan to do that
for v2.

Regards,
Samuel

[1]:
https://patchwork.ozlabs.org/project/uboot/patch/20210822231807.3330-5-samuel@sholland.org/

> Best Regards,
> Jaehoon Chung
> 
>> +}
>> +
>> +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		= axp_pmic_bind,
>> +	.ops		= &axp_pmic_ops,
>> +};
>>
> 


  reply	other threads:[~2021-09-02 23:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21 23:05 [PATCH 00/11] sunxi: Migrate to DM_I2C Samuel Holland
2021-08-21 23:05 ` [PATCH 01/11] i2c: Add a DM_I2C wrapper for the sun6i_p2wi controller Samuel Holland
2021-08-22  8:38   ` Heiko Schocher
2021-08-22 17:19     ` Samuel Holland
2021-08-23  4:26       ` Heiko Schocher
2021-08-21 23:05 ` [PATCH 02/11] i2c: Add a DM_I2C wrapper for the sun8i_rsb controller Samuel Holland
2021-08-22  8:40   ` Heiko Schocher
2021-08-21 23:05 ` [PATCH 03/11] power: pmic: Consistently depend on DM_PMIC Samuel Holland
2021-09-02 23:12   ` Jaehoon Chung
2021-09-15 16:08   ` Igor Opaniuk
2021-08-21 23:05 ` [PATCH 04/11] power: pmic: Make the uclass optional in SPL Samuel Holland
2021-09-02 23:13   ` Jaehoon Chung
2021-08-21 23:05 ` [PATCH 05/11] power: pmic: Add a driver for X-Powers AXP PMICs Samuel Holland
2021-09-02 23:17   ` Jaehoon Chung
2021-09-02 23:23     ` Samuel Holland [this message]
2021-08-21 23:05 ` [PATCH 06/11] sunxi: Select SUN8I_RSB more carefully Samuel Holland
2021-10-07 16:13   ` Andre Przywara
2021-08-21 23:05 ` [PATCH 07/11] sunxi: pmic_bus: Fix Kconfig dependencies Samuel Holland
2021-09-02 23:17   ` Jaehoon Chung
2021-08-21 23:05 ` [PATCH 08/11] sunxi: pmic_bus: Clean up preprocessor conditions Samuel Holland
2021-08-21 23:05 ` [PATCH 09/11] sunxi: pmic_bus: Use the DM PMIC interface when possible Samuel Holland
2021-08-21 23:05 ` [PATCH 10/11] sunxi: video: Convert panel I2C to use DM_I2C Samuel Holland
2021-08-22  8:41   ` Heiko Schocher
2021-08-21 23:05 ` [PATCH 11/11] sunxi: Enable DM_I2C for all sunxi boards Samuel Holland
2021-08-22  8:42   ` Heiko Schocher

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=8330e10e-3962-8056-2777-d8ae386be8e7@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@siol.net \
    --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.