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=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 36E75C47082 for ; Wed, 26 May 2021 22:18:18 +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 3FF7F613CA for ; Wed, 26 May 2021 22:18:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FF7F613CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F15DE82D68; Thu, 27 May 2021 00:18:14 +0200 (CEST) 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="d8Yig/lm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6CA1E82E23; Thu, 27 May 2021 00:18:13 +0200 (CEST) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 DB55D82E23 for ; Thu, 27 May 2021 00:18:05 +0200 (CEST) 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 epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210526221802epoutp0494be5563919d2a4daa070414227968f4~CvcgSjym23242432424epoutp04N for ; Wed, 26 May 2021 22:18:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210526221802epoutp0494be5563919d2a4daa070414227968f4~CvcgSjym23242432424epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1622067482; bh=nr/klSpsvY8qt62iIruf+64G6t2YQzkNaZXXhaEwStw=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=d8Yig/lmu+odAMOiFktBRAjDvtMCBFNlSQLIEvezDSchTV/hwEatCDdgd13M9uvni 6vEZq6TA8k3KC3hEwrWTgbLcpOBQQNFVqWUVV3xwxA1wqQEk38sKMimwgwWafOTrYL 5bj1BxLvymdyFGQ6+moybiV2a5SaVgAHEpIWIBeQ= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20210526221801epcas1p30e1732c12a29494e771dae79f5dcbdbc~CvcfOwL-31836318363epcas1p3B; Wed, 26 May 2021 22:18:01 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.156]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Fr51M0RNDz4x9Pt; Wed, 26 May 2021 22:17:59 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 2B.D3.09578.619CEA06; Thu, 27 May 2021 07:17:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210526221758epcas1p1e978e180e4039300c73b1094eebe5157~Cvcb7qBkj1533615336epcas1p1P; Wed, 26 May 2021 22:17:58 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210526221758epsmtrp2a0b0eea90a5c3069ba1e2a58085ee54d~Cvcb62CXm2366623666epsmtrp2Y; Wed, 26 May 2021 22:17:58 +0000 (GMT) X-AuditID: b6c32a35-fb9ff7000000256a-51-60aec9166944 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 83.73.08163.519CEA06; Thu, 27 May 2021 07:17:58 +0900 (KST) Received: from [10.113.113.235] (unknown [10.113.113.235]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210526221757epsmtip1e3c12aae0bcf299e61b6e23e6b1dd123~CvcbtZSDO1742717427epsmtip1k; Wed, 26 May 2021 22:17:57 +0000 (GMT) Subject: Re: [PATCH v5 1/6] dm: regulator: support regulator more state To: Elaine@denx.de, Zhang@denx.de, sjg@chromium.org, philipp.tomsich@theobroma-systems.com, kever.yang@rock-chips.com, lukma@denx.de Cc: zhangqing@rock-chips.com, u-boot@lists.denx.de, chenjh@rock-chips.com From: Jaehoon Chung Message-ID: <1f854e8e-d4fa-89b9-ea2d-80a6fd499edc@samsung.com> Date: Thu, 27 May 2021 07:18:52 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210526084626.9709-5-zhangqing@rock-chips.com> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCJsWRmVeSWpSXmKPExsWy7bCmga7YyXUJBqu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c2vie 1UH0YqDnBjcGlWjRnpXTki7eXSP/W4mlOCPRUIu5qDgRAAUaStwVAwAA X-CMS-MailID: 20210526221758epcas1p1e978e180e4039300c73b1094eebe5157 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: 20210526112318epcas1p17f5bf6f4d38b9c0d9c09479123bab3e9 References: <20210526084626.9709-1-zhangqing@rock-chips.com> <20210526084626.9709-5-zhangqing@rock-chips.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean Hi, On 5/26/21 5:46 PM, Elaine@denx.de wrote: > From: Joseph Chen Is it right patch? This patch had been already applied. Best Regards, Jaehoon Chung > > support parse regulator standard property: > regulator-off-in-suspend; > regulator-init-microvolt; > regulator-suspend-microvolt: > regulator_get_suspend_enable > regulator_set_suspend_enable > regulator_get_suspend_value > regulator_set_suspend_value > > Signed-off-by: Joseph Chen > Signed-off-by: Elaine Zhang > Reviewed-by: Kever Yang > --- > doc/device-tree-bindings/regulator/regulator.txt | 27 +++++++++ > drivers/power/regulator/regulator-uclass.c | 70 ++++++++++++++++++++++++ > include/power/regulator.h | 64 ++++++++++++++++++++++ > test/dm/regulator.c | 57 +++++++++++++++++++ > 4 files changed, 218 insertions(+) > > diff --git a/doc/device-tree-bindings/regulator/regulator.txt b/doc/device-tree-bindings/regulator/regulator.txt > index 4ba642b7c77f..6c9a02120fde 100644 > --- a/doc/device-tree-bindings/regulator/regulator.txt > +++ b/doc/device-tree-bindings/regulator/regulator.txt > @@ -36,6 +36,28 @@ Optional properties: > - regulator-always-on: regulator should never be disabled > - regulator-boot-on: enabled by bootloader/firmware > - regulator-ramp-delay: ramp delay for regulator (in uV/us) > +- regulator-init-microvolt: a init allowed Voltage value > +- regulator-state-(standby|mem|disk) > + type: object > + description: > + sub-nodes for regulator state in Standby, Suspend-to-RAM, and > + Suspend-to-DISK modes. Equivalent with standby, mem, and disk Linux > + sleep states. > + > + properties: > + regulator-on-in-suspend: > + description: regulator should be on in suspend state. > + type: boolean > + > + regulator-off-in-suspend: > + description: regulator should be off in suspend state. > + type: boolean > + > + regulator-suspend-microvolt: > + description: the default voltage which regulator would be set in > + suspend. This property is now deprecated, instead setting voltage > + for suspend mode via the API which regulator driver provides is > + recommended. > > Note > The "regulator-name" constraint is used for setting the device's uclass > @@ -59,7 +81,12 @@ ldo0 { > regulator-max-microvolt = <1800000>; > regulator-min-microamp = <100000>; > regulator-max-microamp = <100000>; > + regulator-init-microvolt = <1800000>; > regulator-always-on; > regulator-boot-on; > regulator-ramp-delay = <12000>; > + regulator-state-mem { > + regulator-on-in-suspend; > + regulator-suspend-microvolt = <1800000>; > + }; > }; > diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c > index 76be95bcd159..4986c87e7ba6 100644 > --- a/drivers/power/regulator/regulator-uclass.c > +++ b/drivers/power/regulator/regulator-uclass.c > @@ -77,6 +77,33 @@ int regulator_set_value(struct udevice *dev, int uV) > return ret; > } > > +int regulator_set_suspend_value(struct udevice *dev, int uV) > +{ > + const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); > + struct dm_regulator_uclass_platdata *uc_pdata; > + > + uc_pdata = dev_get_uclass_platdata(dev); > + if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV) > + return -EINVAL; > + if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV) > + return -EINVAL; > + > + if (!ops->set_suspend_value) > + return -ENOSYS; > + > + return ops->set_suspend_value(dev, uV); > +} > + > +int regulator_get_suspend_value(struct udevice *dev) > +{ > + const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); > + > + if (!ops->get_suspend_value) > + return -ENOSYS; > + > + return ops->get_suspend_value(dev); > +} > + > /* > * To be called with at most caution as there is no check > * before setting the actual voltage value. > @@ -170,6 +197,26 @@ int regulator_set_enable_if_allowed(struct udevice *dev, bool enable) > return ret; > } > > +int regulator_set_suspend_enable(struct udevice *dev, bool enable) > +{ > + const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); > + > + if (!ops->set_suspend_enable) > + return -ENOSYS; > + > + return ops->set_suspend_enable(dev, enable); > +} > + > +int regulator_get_suspend_enable(struct udevice *dev) > +{ > + const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); > + > + if (!ops->get_suspend_enable) > + return -ENOSYS; > + > + return ops->get_suspend_enable(dev); > +} > + > int regulator_get_mode(struct udevice *dev) > { > const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); > @@ -235,6 +282,14 @@ int regulator_autoset(struct udevice *dev) > int ret = 0; > > uc_pdata = dev_get_uclass_platdata(dev); > + > + ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on); > + if (!ret && uc_pdata->suspend_on) { > + ret = regulator_set_suspend_value(dev, uc_pdata->suspend_uV); > + if (!ret) > + return ret; > + } > + > if (!uc_pdata->always_on && !uc_pdata->boot_on) > return -EMEDIUMTYPE; > > @@ -243,6 +298,8 @@ int regulator_autoset(struct udevice *dev) > > if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UV) > ret = regulator_set_value(dev, uc_pdata->min_uV); > + if (uc_pdata->init_uV > 0) > + ret = regulator_set_value(dev, uc_pdata->init_uV); > if (!ret && (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UA)) > ret = regulator_set_current(dev, uc_pdata->min_uA); > > @@ -363,6 +420,7 @@ static int regulator_post_bind(struct udevice *dev) > static int regulator_pre_probe(struct udevice *dev) > { > struct dm_regulator_uclass_platdata *uc_pdata; > + ofnode node; > > uc_pdata = dev_get_uclass_platdata(dev); > if (!uc_pdata) > @@ -373,6 +431,8 @@ static int regulator_pre_probe(struct udevice *dev) > -ENODATA); > uc_pdata->max_uV = dev_read_u32_default(dev, "regulator-max-microvolt", > -ENODATA); > + uc_pdata->init_uV = dev_read_u32_default(dev, "regulator-init-microvolt", > + -ENODATA); > uc_pdata->min_uA = dev_read_u32_default(dev, "regulator-min-microamp", > -ENODATA); > uc_pdata->max_uA = dev_read_u32_default(dev, "regulator-max-microamp", > @@ -382,6 +442,16 @@ static int regulator_pre_probe(struct udevice *dev) > uc_pdata->ramp_delay = dev_read_u32_default(dev, "regulator-ramp-delay", > 0); > > + node = dev_read_subnode(dev, "regulator-state-mem"); > + if (ofnode_valid(node)) { > + uc_pdata->suspend_on = !ofnode_read_bool(node, "regulator-off-in-suspend"); > + if (ofnode_read_u32(node, "regulator-suspend-microvolt", &uc_pdata->suspend_uV)) > + uc_pdata->suspend_uV = uc_pdata->max_uV; > + } else { > + uc_pdata->suspend_on = true; > + uc_pdata->suspend_uV = uc_pdata->max_uV; > + } > + > /* Those values are optional (-ENODATA if unset) */ > if ((uc_pdata->min_uV != -ENODATA) && > (uc_pdata->max_uV != -ENODATA) && > diff --git a/include/power/regulator.h b/include/power/regulator.h > index 6c6e2cd4f996..dd61eb4ccbde 100644 > --- a/include/power/regulator.h > +++ b/include/power/regulator.h > @@ -168,6 +168,7 @@ struct dm_regulator_uclass_platdata { > int mode_count; > int min_uV; > int max_uV; > + int init_uV; > int min_uA; > int max_uA; > unsigned int ramp_delay; > @@ -177,6 +178,8 @@ struct dm_regulator_uclass_platdata { > int flags; > u8 ctrl_reg; > u8 volt_reg; > + bool suspend_on; > + u32 suspend_uV; > }; > > /* Regulator device operations */ > @@ -194,6 +197,19 @@ struct dm_regulator_ops { > int (*set_value)(struct udevice *dev, int uV); > > /** > + * The regulator suspend output value function calls operates > + * on a micro Volts. > + * > + * get/set_suspen_value - get/set suspend mode output value > + * @dev - regulator device > + * Sets: > + * @uV - set the suspend output value [micro Volts] > + * @return output value [uV] on success or negative errno if fail. > + */ > + int (*set_suspend_value)(struct udevice *dev, int uV); > + int (*get_suspend_value)(struct udevice *dev); > + > + /** > * The regulator output current function calls operates on a micro Amps. > * > * get/set_current - get/set output current of the given output number > @@ -218,6 +234,19 @@ struct dm_regulator_ops { > int (*set_enable)(struct udevice *dev, bool enable); > > /** > + * The most basic feature of the regulator output is its enable state > + * in suspend mode. > + * > + * get/set_suspend_enable - get/set enable state of the suspend output > + * @dev - regulator device > + * Sets: > + * @enable - set true - enable or false - disable > + * @return true/false for get or -errno if fail; 0 / -errno for set. > + */ > + int (*set_suspend_enable)(struct udevice *dev, bool enable); > + int (*get_suspend_enable)(struct udevice *dev); > + > + /** > * The 'get/set_mode()' function calls should operate on a driver- > * specific mode id definitions, which should be found in: > * field 'id' of struct dm_regulator_mode. > @@ -262,6 +291,23 @@ int regulator_get_value(struct udevice *dev); > int regulator_set_value(struct udevice *dev, int uV); > > /** > + * regulator_set_suspend_value: set the suspend microvoltage value of a given regulator. > + * > + * @dev - pointer to the regulator device > + * @uV - the output suspend value to set [micro Volts] > + * @return - 0 on success or -errno val if fails > + */ > +int regulator_set_suspend_value(struct udevice *dev, int uV); > + > +/** > + * regulator_get_suspend_value: get the suspend microvoltage value of a given regulator. > + * > + * @dev - pointer to the regulator device > + * @return - positive output value [uV] on success or negative errno if fail. > + */ > +int regulator_get_suspend_value(struct udevice *dev); > + > +/** > * regulator_set_value_force: set the microvoltage value of a given regulator > * without any min-,max condition check > * > @@ -317,6 +363,24 @@ int regulator_set_enable(struct udevice *dev, bool enable); > int regulator_set_enable_if_allowed(struct udevice *dev, bool enable); > > /** > + * regulator_set_suspend_enable: set regulator suspend enable state > + * > + * @dev - pointer to the regulator device > + * @enable - set true or false > + * @return - 0 on success or -errno val if fails > + */ > +int regulator_set_suspend_enable(struct udevice *dev, bool enable); > + > + > +/** > + * regulator_get_suspend_enable: get regulator suspend enable state > + * > + * @dev - pointer to the regulator device > + * @return - true/false of enable state or -errno val if fails > + */ > +int regulator_get_suspend_enable(struct udevice *dev); > + > +/** > * regulator_get_mode: get active operation mode id of a given regulator > * > * @dev - pointer to the regulator device > diff --git a/test/dm/regulator.c b/test/dm/regulator.c > index e510539542b6..b967902493dd 100644 > --- a/test/dm/regulator.c > +++ b/test/dm/regulator.c > @@ -215,6 +215,63 @@ static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts) > } > DM_TEST(dm_test_power_regulator_set_get_mode, DM_TESTF_SCAN_FDT); > > +/* Test regulator set and get suspend Voltage method */ > +static int dm_test_power_regulator_set_get_suspend_voltage(struct unit_test_state *uts) > +{ > + struct dm_regulator_uclass_platdata *uc_pdata; > + const struct dm_regulator_ops *ops; > + struct udevice *dev; > + const char *platname; > + int val_set, val_get; > + > + /* Set and get Voltage of BUCK1 - set to 'min' constraint */ > + platname = regulator_names[BUCK1][PLATNAME]; > + ut_assertok(regulator_get_by_platname(platname, &dev)); > + > + uc_pdata = dev_get_uclass_platdata(dev); > + ut_assert(uc_pdata); > + > + ops = dev_get_driver_ops(dev); > + > + if (ops->set_suspend_value && ops->get_suspend_value) { > + val_set = uc_pdata->suspend_uV; > + ut_assertok(regulator_set_suspend_value(dev, val_set)); > + val_get = regulator_get_suspend_value(dev); > + ut_assert(val_get >= 0); > + > + ut_asserteq(val_set, val_get); > + } > + return 0; > +} > +DM_TEST(dm_test_power_regulator_set_get_suspend_voltage, DM_TESTF_SCAN_FDT); > + > +/* Test regulator set and get suspend Enable method */ > +static int dm_test_power_regulator_set_get_suspend_enable(struct unit_test_state *uts) > +{ > + const struct dm_regulator_ops *ops; > + const char *platname; > + struct udevice *dev; > + bool val_set = true; > + > + /* Set the Enable of LDO1 - default is disabled */ > + platname = regulator_names[LDO1][PLATNAME]; > + ut_assertok(regulator_get_by_platname(platname, &dev)); > + > + ops = dev_get_driver_ops(dev); > + > + if (ops->set_suspend_enable && ops->get_suspend_enable) { > + ut_assertok(regulator_set_suspend_enable(dev, val_set)); > + > + /* > + * Get the Enable state of LDO1 and > + * compare it with the requested one > + */ > + ut_asserteq(regulator_get_suspend_enable(dev), val_set); > + } > + return 0; > +} > +DM_TEST(dm_test_power_regulator_set_get_suspend_enable, DM_TESTF_SCAN_FDT); > + > /* Test regulator autoset method */ > static int dm_test_power_regulator_autoset(struct unit_test_state *uts) > { >