From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1B07C433F5 for ; Thu, 2 Sep 2021 23:23:21 +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 306D660F21 for ; Thu, 2 Sep 2021 23:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 306D660F21 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org 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 A269C834C0; Fri, 3 Sep 2021 01:23:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="s6FZJ8YP"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="jZeikwhi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 742FC8348D; Fri, 3 Sep 2021 01:23:17 +0200 (CEST) Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1BC1B834C0 for ; Fri, 3 Sep 2021 01:23:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id C6C3F580DA6; Thu, 2 Sep 2021 19:23:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 02 Sep 2021 19:23:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=t SUrpK9DigumMpEHaVLPw79zfSmrdJHmhdllPgU6y3Q=; b=s6FZJ8YPxtK4mGeKQ 2mcRWFcxf6ggHy0010Ukja/tin+7mDmsijoVgvONUeRmSpktfv0g4mh87ke69/Qf uAJdasCa8TSUWj8D2duLejxtQgQTl3WZLshJS6sg6DJZmWRm7ytSd6jKE6zQD9pz HO9zGhtYZKKitFUs2EH7A62cuNssO+aIGWBZA4mHIn8yl9fVAIKNaOgLDm07XUuO b+opu9hUCsPv2OFHOyx5vy6jfCukTFtDaxlny5K9LPXJXysJepOHn8zge8mgvK5r e2JbW79gMjeZGvNIiBBnD4BRvpVjz32uEK/nMGezfa65Zm8DHO7OAkMxzPDldJJT LSLGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=tSUrpK9DigumMpEHaVLPw79zfSmrdJHmhdllPgU6y 3Q=; b=jZeikwhi3P9DYG5vEa06/6MCbo4b2nelJgZ71jPfTNqm8vGWdeRi2m0BG s1fDnTgyIDsEzZO0sNgz7kx+RA/2qQrQLdVEVbYqjDhgJEn8nJXYJyVkXo4MBx/T WUL03F2oQy187jYEfkqqduKPyeppXfZ5NZw17SZoN1X96k0XhszqQbqGNJXwMHDz 5aCQKKOMTYSVjxxbfWvtnpfJRnTIzzPMcTQ9t3YYhU4eQqCikpKqJyd0Yxld+yg6 yjj3vjzseV5e/8QdZukdDenckkpALoPt+s6fBw85OCeRhwCMQS14izKeNyDO7Dfw eHe61Cyi1PdOc/YTrNgJiMjuO+XaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddviedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgeetieffteevkeefvefghfetkeetudetjeffhfdvgeejvdegffdu vedvkeejleelnecuffhomhgrihhnpehoiihlrggsshdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgr nhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 Sep 2021 19:23:07 -0400 (EDT) Subject: Re: [PATCH 05/11] power: pmic: Add a driver for X-Powers AXP PMICs To: Jaehoon Chung Cc: Heiko Schocher , Anatolij Gustschin , Arnaud Ferraris , Bharat Gooty , Igor Opaniuk , Jernej Skrabec , Minkyu Kang , Rayagonda Kokatanur , Simon Glass , Stephan Gerhold , Tim Harvey , Tom Rini , u-boot@lists.denx.de, Jagan Teki , Andre Przywara References: <20210821230520.10051-1-samuel@sholland.org> <20210821230520.10051-6-samuel@sholland.org> From: Samuel Holland Message-ID: <8330e10e-3962-8056-2777-d8ae386be8e7@sholland.org> Date: Thu, 2 Sep 2021 18:23:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux ppc64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US 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 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 >> --- >> >> 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 >> +#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 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, >> +}; >> >