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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6A010C4332F for ; Wed, 2 Nov 2022 22:14:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3113F850C4; Wed, 2 Nov 2022 23:14:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="FQJWZeUi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1EEA5850B8; Wed, 2 Nov 2022 23:14:37 +0100 (CET) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 95DE5850C6 for ; Wed, 2 Nov 2022 23:14:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jh80.chung@samsung.com Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20221102221425epoutp023c9fe7072e35076ddf9a066bbf593668~j5ENqfEx22831928319epoutp02k for ; Wed, 2 Nov 2022 22:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20221102221425epoutp023c9fe7072e35076ddf9a066bbf593668~j5ENqfEx22831928319epoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1667427265; bh=e3ut7Jp9trZF1mLWCyi5z6GULeZw+8sLuYIsR+NH6CQ=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=FQJWZeUijRASE8bjwgc4PFab3nEQ69u4B2aVWgLkYBTZlMaVk9ph2vIP0c55h8KS0 JyRXYCEYetTyUhZAqpdqcovC9QJbzviSZeI2731PFt8c7/rOMA+LMYErBp463IyUcA HutZbdYBuHIOqqAzkYo+gUrScyb7Ee0pJIDkrsEc= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20221102221424epcas1p349281ba990cf12fc125dea0f3e650925~j5ENG9oHI1914619146epcas1p3A; Wed, 2 Nov 2022 22:14:24 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.38.233]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4N2h4v3gLNz4x9Q1; Wed, 2 Nov 2022 22:14:23 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 00.D3.07691.FBBE2636; Thu, 3 Nov 2022 07:14:23 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20221102221422epcas1p47d07bd8c3d7ec80a7b356fd88fb4fb10~j5ELjBC1v2189321893epcas1p4s; Wed, 2 Nov 2022 22:14:22 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221102221422epsmtrp1f92208d585a1ea11e7bdda911591ab41~j5ELiUW0x1498414984epsmtrp1H; Wed, 2 Nov 2022 22:14:22 +0000 (GMT) X-AuditID: b6c32a38-31ffb70000021e0b-c7-6362ebbfd8d0 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 18.3C.18644.EBBE2636; Thu, 3 Nov 2022 07:14:22 +0900 (KST) Received: from jh80chung01 (unknown [10.113.111.84]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221102221422epsmtip2f7c6bd6e7b7ae8c9e0bf6634cb23fb76~j5ELX_cjt2613426134epsmtip2C; Wed, 2 Nov 2022 22:14:22 +0000 (GMT) From: "Jaehoon Chung" To: "'Jim Liu'" , , , Cc: In-Reply-To: <20221101022053.29564-1-JJLIU0@nuvoton.com> Subject: RE: [PATCH v1] power: regulator: Add support for NPCM845 Date: Thu, 3 Nov 2022 07:14:22 +0900 Message-ID: <000901d8ef08$761c1b80$62545280$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Content-Language: ko Thread-Index: AQI7y1EeMYPJAhPfzdyaxvq0o61whwHxufLJrVbqlmA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplk+LIzCtJLcpLzFFi42LZdlhTV3f/66Rkg94vYhbPG1cyWRw+8YXZ onf3WxaLt3s72S3WLNvL7MDqsXPWXXaPs3d2MHpsudTKGsAclW2TkZqYklqkkJqXnJ+SmZdu q+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA7RTSaEsMacUKBSQWFyspG9nU5RfWpKq kJFfXGKrlFqQklNgWqBXnJhbXJqXrpeXWmJlaGBgZApUmJCd0dfnXzDRuOLbij8sDYznNbsY OTkkBEwkTl68ztrFyMUhJLCDUeLd/h4o5xOjxPq7E5ghnM+MEp8v/mCEaek7f4gFIrGLUWLx zL9MEM5LRon7T64ygVSxCehJ/F+0kBnEFhHIkNh7cgIbiM0sICXRdHIX2CROAQuJnTOPgNUI CzhKNB7cBGazCKhITNg3jRXE5hWwlOj5upcJwhaUODnzCQvEHHmJ7W/nMENcpCCx+9NRVoi4 iMTszjagOAfQXiuJdydtQG6TEPjJLvHt0h8WiHoXiSnze6BsYYl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wwxxp4LE7k9HWSHiIhKzO9uYQcpFBKwk3p20mcAoPAvJoFkIg2YhGTQLSfMCRpZVjJKp BcW56bnFhgVGeanlesWJucWleel6yfm5mxjBEaKltYNxz6oPeocYmTgYDzFKcDArifDWn41O FuJNSaysSi3Kjy8qzUktPsQozcGiJM57oetkvJBAemJJanZqakFqEUyWiYNTqoHJ9/El8S8S V3l/tUqJ1idfuJBpviFI+bXhyTn1AVNu7H3mdXpOUP8KmZzNmgxvZKe+fLNbkT3CPeHrPYbZ esobVzKpTno0Z3tJW8WNFe53ZzwzzW279Cjw6qrcJYt2v0/l5LDiv8bfxP+k/tbrZas3be9K OjxB9NrLsIQFRyKrdHVPP/r+Q0ruVvbSpGW76/4fSpj3s35mV9TdhVsjguwMD63Vt0rPvXjz dHhx6Ra5Zfqbp+x7/1lBgZdprVaJtLvjS9Yvmvoul8/Mn6ch5LDNS7Eg4+AipZeXllzp+vaE +79z9mGuJWqlBzqWvTkf23PZ64WC8bfSjITN+2SYPC9VlTe7P2bg6D/VOb8x/OhPSyWW4oxE Qy3mouJEAPF4L73/AgAA X-CMS-MailID: 20221102221422epcas1p47d07bd8c3d7ec80a7b356fd88fb4fb10 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221101022123epcas1p485615cc42d3862609631b5787935fedb References: <20221101022053.29564-1-JJLIU0@nuvoton.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Hi, > -----Original Message----- > From: Jim Liu [mailto:jim.t90615@gmail.com] > Sent: Tuesday, November 1, 2022 11:21 AM > To: jim.t90615@gmail.com; JJLIU0@nuvoton.com; YSCHU@nuvoton.com; KWLIU@nuvoton.com; > jh80.chung@samsung.com > Cc: u-boot@lists.denx.de > Subject: [PATCH v1] power: regulator: Add support for NPCM845 > > Add support for setting NPCM845 voltage supply > > regulator-force-microvolt is npcm proprietary property to > set the voltage level. What is regulator-force-microvolt. I didn't find this property in u-boot / kernel side. If I missed something, could you explain it? And Is there no pmic for this regulator? > > Signed-off-by: Jim Liu > --- > drivers/power/regulator/Kconfig | 8 ++ > drivers/power/regulator/Makefile | 1 + > drivers/power/regulator/npcm8xx_regulator.c | 133 ++++++++++++++++++++ > 3 files changed, 142 insertions(+) > create mode 100644 drivers/power/regulator/npcm8xx_regulator.c > > diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig > index c519e066ef..e5f06874de 100644 > --- a/drivers/power/regulator/Kconfig > +++ b/drivers/power/regulator/Kconfig > @@ -128,6 +128,14 @@ config DM_REGULATOR_MAX77686 > features for REGULATOR MAX77686. The driver implements get/set api for: > value, enable and mode. > > +config DM_REGULATOR_NPCM8XX > + bool "Enable driver for NPCM8xx voltage supply" "Enable Driver Model for ...." > + depends on DM_REGULATOR && ARCH_NPCM8XX > + help > + Enable support for configuring voltage supply on NPCM8XX SoC. The > + voltage supplies support two voltage levels and the driver implements > + get/set api for setting the value. > + > config DM_REGULATOR_FAN53555 > bool "Enable Driver Model for REGULATOR FAN53555" > depends on DM_PMIC_FAN53555 > diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile > index bc736068bc..68e4c0f9dd 100644 > --- a/drivers/power/regulator/Makefile > +++ b/drivers/power/regulator/Makefile > @@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o > obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o > obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o > obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o > +obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o > obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o > obj-$(CONFIG_$(SPL_)DM_REGULATOR_BD71837) += bd71837.o > obj-$(CONFIG_$(SPL_)DM_REGULATOR_PCA9450) += pca9450.o > diff --git a/drivers/power/regulator/npcm8xx_regulator.c > b/drivers/power/regulator/npcm8xx_regulator.c > new file mode 100644 > index 0000000000..7903287132 > --- /dev/null > +++ b/drivers/power/regulator/npcm8xx_regulator.c > @@ -0,0 +1,133 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (c) 2022 Nuvoton Technology Corp. > + */ > + > +#include > +#include > +#include > +#include > +#include > + > +#define REG_VSRCR 0xf08000e8 /* Voltage Supply Control Register */ > + > +/* Supported voltage levels (uV) */ > +static const u32 volts_type1[] = { 3300000, 1800000 }; > +static const u32 volts_type2[] = { 1000000, 1800000 }; > +#define VOLT_LEV0 0 > +#define VOLT_LEV1 1 > + > +struct volt_supply { > + char *name; > + const u32 *volts; > + u32 reg_shift; /* Register bit offset for setting voltage */ > +}; > + > +static const struct volt_supply npcm8xx_volt_supps[] = { > + {"v1", volts_type1, 0}, > + {"v2", volts_type1, 1}, > + {"v3", volts_type1, 2}, > + {"v4", volts_type1, 3}, > + {"v5", volts_type1, 4}, > + {"v6", volts_type1, 5}, > + {"v7", volts_type1, 6}, > + {"v8", volts_type1, 7}, > + {"v9", volts_type1, 8}, > + {"v10", volts_type1, 9}, > + {"v11", volts_type2, 10}, > + {"v12", volts_type1, 11}, > + {"v13", volts_type1, 12}, > + {"v14", volts_type2, 13}, > + {"vsif", volts_type1, 14}, > + {"vr2", volts_type1, 30}, > +}; > + > +static const struct volt_supply *npcm8xx_volt_supply_get(const char *name) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(npcm8xx_volt_supps); i++) { > + if (!strcmp(npcm8xx_volt_supps[i].name, name)) > + return &npcm8xx_volt_supps[i]; > + } > + > + return NULL; > +} > + > +static int npcm8xx_regulator_set_value(struct udevice *dev, int uV) > +{ > + struct dm_regulator_uclass_plat *uc_pdata; > + const struct volt_supply *supp; > + u32 val, level; > + > + uc_pdata = dev_get_uclass_plat(dev); > + if (!uc_pdata) > + return -ENXIO; > + > + dev_dbg(dev, "%s set_value: %d\n", uc_pdata->name, uV); > + supp = npcm8xx_volt_supply_get(uc_pdata->name); > + if (!supp) > + return -ENOENT; > + > + if (uV == supp->volts[VOLT_LEV0]) > + level = VOLT_LEV0; > + else if (uV == supp->volts[VOLT_LEV1]) > + level = VOLT_LEV1; > + else > + return -EINVAL; > + > + /* Set voltage level */ > + val = readl(REG_VSRCR); > + val &= ~BIT(supp->reg_shift); > + val |= level << supp->reg_shift; > + writel(val, REG_VSRCR); > + > + return 0; > +} > + > +static int npcm8xx_regulator_get_value(struct udevice *dev) > +{ > + struct dm_regulator_uclass_plat *uc_pdata; > + const struct volt_supply *supp; > + u32 val; > + > + uc_pdata = dev_get_uclass_plat(dev); > + if (!uc_pdata) > + return -ENXIO; > + > + supp = npcm8xx_volt_supply_get(uc_pdata->name); > + if (!supp) > + return -ENOENT; > + > + val = readl(REG_VSRCR) & BIT(supp->reg_shift); To Readable, add the one line. > + dev_dbg(dev, "%s get_value: %d\n", uc_pdata->name, > + val ? supp->volts[VOLT_LEV1] : supp->volts[VOLT_LEV0]); > + if (val) > + return supp->volts[VOLT_LEV1]; > + else > + return supp->volts[VOLT_LEV0]; Return val ? supp->volts[VOLT_LEV1] : ...; > +} > + > +static int npcm8xx_regulator_set_enable(struct udevice *dev, bool enable) > +{ > + /* Always on */ > + return 0; > +} > + > +static const struct dm_regulator_ops npcm8xx_regulator_ops = { > + .set_value = npcm8xx_regulator_set_value, > + .get_value = npcm8xx_regulator_get_value, > + .set_enable = npcm8xx_regulator_set_enable, > +}; > + > +static const struct udevice_id npcm8xx_regulator_ids[] = { > + { .compatible = "regulator-npcm845" }, > + { }, > +}; > + > +U_BOOT_DRIVER(regulator_npcm8xx) = { > + .name = "regulator_npcm845", > + .id = UCLASS_REGULATOR, > + .ops = &npcm8xx_regulator_ops, > + .of_match = npcm8xx_regulator_ids, > +}; > -- > 2.17.1