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 52D16CF9C71 for ; Wed, 25 Sep 2024 02:53:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2BFC87BF4; Wed, 25 Sep 2024 04:53:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1727232786; bh=31l/5NinKpv9uXl5fGCvMEzdE64rcvZAPQzUoU1+UkM=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Z15ltk9DgD0DuKBjS1yxbOzsWrg7dkte/GFrlOUsmxIhl7F74qx0me3kTOdmcgqga fgcuYtxhpfN0AbfdewyDdVrE+0T6B7YfipGNXo22kQXH5n0ccyh46atrDTZ47nWPnM FD4NQ/RZMb+jmASrMY/jzERP+jkV7c041OjBsXoNxQgIvISWsjWxn7mn+8lTjIBXmR oQ+D5ny2QIvztPnhfGYAXYhGRfh9wILnsIm4+qQoR6GJ2BI5183U8fF+lYceCssL0L QrGYG21JYI/lgZVRuAQvx7Rc0OBoiHwOMXCQ0PXQO+Rjg34iIgWMi/L0wnQaKABFCV FaOoKGjqLXLvQ== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2ED1E82BA7; Wed, 25 Sep 2024 04:23:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1727231040; bh=31l/5NinKpv9uXl5fGCvMEzdE64rcvZAPQzUoU1+UkM=; h=From:To:Cc:Subject:Date:From; b=Eb2tw3LysuEJ95t2/cnlsi2Lp0UTXHmy+qlg694Heh+2wrwgzcWik9+tqH48ID2yI /KVcvCS8SLHp0M5ZV6SSsOMu1CL9zR/ywj+XHJR9PopP+Do7SxLisNhNKH6JGJlWqp KZTbL+uuIMMwFELbM7mV+H0k1sC1W4nkKhSkZG5tzVSfHjHJjPurxA/PIB0hKeUe2G FH5iJJ/MVoOAhSgji76OumrH59EnTkQ7xlorGM7WUhQfh8VApPhULoo6CCsu3YodH7 4gcTpGns5D+mQzDh/9378/v1oCegKDJtrIu9orezNCSjDhFTsFAHdAb31IcpIufKYu +zQmNxXj53x+g== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ben Wolsieffer , Caleb Connolly , Chris Morgan , Dragan Simic , Eugen Hristev , Francesco Dolcini , Heinrich Schuchardt , Jaehoon Chung , Jagan Teki , Jonas Karlman , Kever Yang , Kostya Porotchkin , Matteo Lisi , Mattijs Korpershoek , Max Krummenacher , Neil Armstrong , Patrice Chotard , Patrick Delaunay , Philipp Tomsich , Quentin Schulz , Sam Day , Simon Glass , Sumit Garg , Svyatoslav Ryhel , Thierry Reding , Tom Rini , Volodymyr Babchuk , u-boot-amlogic@groups.io, u-boot-qcom@groups.io, u-boot@dh-electronics.com, uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 1/5] power: regulator: Trigger probe of regulators which are always-on or boot-on Date: Wed, 25 Sep 2024 04:21:52 +0200 Message-ID: <20240925022314.714285-1-marex@denx.de> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 25 Sep 2024 04:53:05 +0200 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.8 at phobos.denx.de X-Virus-Status: Clean In case a regulator DT node contains regulator-always-on or regulator-boot-on property, make sure the regulator gets correctly configured by U-Boot on start up. Unconditionally probe such regulator drivers. This is a preparatory patch for introduction of .regulator_post_probe() which would trigger the regulator configuration. Parsing of regulator-always-on and regulator-boot-on DT property has been moved to regulator_post_bind() as the information is required early, the rest of the DT parsing has been kept in regulator_pre_probe() to avoid slowing down the boot process. Signed-off-by: Marek Vasut --- Cc: Ben Wolsieffer Cc: Caleb Connolly Cc: Chris Morgan Cc: Dragan Simic Cc: Eugen Hristev Cc: Francesco Dolcini Cc: Heinrich Schuchardt Cc: Jaehoon Chung Cc: Jagan Teki Cc: Jonas Karlman Cc: Kever Yang Cc: Kostya Porotchkin Cc: Matteo Lisi Cc: Mattijs Korpershoek Cc: Max Krummenacher Cc: Neil Armstrong Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Philipp Tomsich Cc: Quentin Schulz Cc: Sam Day Cc: Simon Glass Cc: Sumit Garg Cc: Svyatoslav Ryhel Cc: Thierry Reding Cc: Tom Rini Cc: Volodymyr Babchuk Cc: u-boot-amlogic@groups.io Cc: u-boot-qcom@groups.io Cc: u-boot@dh-electronics.com Cc: u-boot@lists.denx.de Cc: uboot-stm32@st-md-mailman.stormreply.com --- V2: - Rebase on current u-boot/next - Update test cases to handle already started regulators correctly --- drivers/power/regulator/regulator-uclass.c | 22 +++++++++++++++------- test/dm/panel.c | 2 +- test/dm/regulator.c | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 88a8525b3c4..e2f703702e3 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -433,6 +433,8 @@ static int regulator_post_bind(struct udevice *dev) const char *property = "regulator-name"; uc_pdata = dev_get_uclass_plat(dev); + uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on"); + uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on"); /* Regulator's mandatory constraint */ uc_pdata->name = dev_read_string(dev, property); @@ -444,13 +446,21 @@ static int regulator_post_bind(struct udevice *dev) return -EINVAL; } - if (regulator_name_is_unique(dev, uc_pdata->name)) - return 0; + if (!regulator_name_is_unique(dev, uc_pdata->name)) { + debug("'%s' of dev: '%s', has nonunique value: '%s\n", + property, dev->name, uc_pdata->name); + return -EINVAL; + } - debug("'%s' of dev: '%s', has nonunique value: '%s\n", - property, dev->name, uc_pdata->name); + /* + * In case the regulator has regulator-always-on or + * regulator-boot-on DT property, trigger probe() to + * configure its default state during startup. + */ + if (uc_pdata->always_on && uc_pdata->boot_on) + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); - return -EINVAL; + return 0; } static int regulator_pre_probe(struct udevice *dev) @@ -473,8 +483,6 @@ static int regulator_pre_probe(struct udevice *dev) -ENODATA); uc_pdata->max_uA = dev_read_u32_default(dev, "regulator-max-microamp", -ENODATA); - uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on"); - uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on"); uc_pdata->ramp_delay = dev_read_u32_default(dev, "regulator-ramp-delay", 0); uc_pdata->force_off = dev_read_bool(dev, "regulator-force-boot-off"); diff --git a/test/dm/panel.c b/test/dm/panel.c index ce835c96ed0..ec85a9b1e6e 100644 --- a/test/dm/panel.c +++ b/test/dm/panel.c @@ -33,7 +33,7 @@ static int dm_test_panel(struct unit_test_state *uts) ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns, &enable, &polarity)); ut_asserteq(false, enable); - ut_asserteq(false, regulator_get_enable(reg)); + ut_asserteq(true, regulator_get_enable(reg)); ut_assertok(panel_enable_backlight(dev)); ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns, diff --git a/test/dm/regulator.c b/test/dm/regulator.c index 532bbd82376..449748ad52f 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -186,7 +186,7 @@ int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts) /* Get BUCK1 - always on regulator */ platname = regulator_names[BUCK1][PLATNAME]; - ut_assertok(regulator_autoset_by_name(platname, &dev_autoset)); + ut_asserteq(-EALREADY, regulator_autoset_by_name(platname, &dev_autoset)); ut_assertok(regulator_get_by_platname(platname, &dev)); /* Try disabling always-on regulator */ @@ -288,7 +288,7 @@ static int dm_test_power_regulator_autoset(struct unit_test_state *uts) * Expected output state: uV=1200000; uA=200000; output enabled */ platname = regulator_names[BUCK1][PLATNAME]; - ut_assertok(regulator_autoset_by_name(platname, &dev_autoset)); + ut_asserteq(-EALREADY, regulator_autoset_by_name(platname, &dev_autoset)); /* Check, that the returned device is proper */ ut_assertok(regulator_get_by_platname(platname, &dev)); -- 2.45.2