mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/2] pmdomain: imx: gpc2: ignore missing regulators
Date: Wed, 13 Mar 2024 15:41:36 +0100	[thread overview]
Message-ID: <20240313144136.2157496-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240313144136.2157496-1-a.fatoum@pengutronix.de>

The GPV2 driver supports controlling voltage rails associated with
domains via adding a power-supply binding to the power domain's
device tree node. This is only done for the i.MX8MQ's GPU, VPU and MIPI
domains. All boards supported upstream that do this reference a
regulator of the pfuze100 as power supply.

While we have a pfuze100 driver, it only does one-time init and doesn't
implement a regulator API. This means these boards will fail with probe
deferrals:

  imx-pgc imx-pgc-domain5: error Requested probe deferral: Failed to get domain's regulator
  imx-pgc imx-pgc-domain6: error Requested probe deferral: Failed to get domain's regulator
  ERROR: imx-pgc-domain6: probe permanently deferred (Failed to get domain's regulator)
  ERROR: imx-pgc-domain5: probe permanently deferred (Failed to get domain's regulator)

As we don't use MIPI, GPU or VPU in barebox and we want to move boards
over to deep probe (where every EPROBE_DEFER is permanent), let's stop
propagating EPROBE_DEFER and just write an info message and continue
probing as usual and delay the error message until the regulator is
actually used.

Fixes: eb487a8d39e2 ("soc: imx: gpcv2: extend for i.MX8M Mini/Nano/Plus support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pmdomain/imx/gpcv2.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/pmdomain/imx/gpcv2.c b/drivers/pmdomain/imx/gpcv2.c
index b967947478b9..fc2fbdaf140b 100644
--- a/drivers/pmdomain/imx/gpcv2.c
+++ b/drivers/pmdomain/imx/gpcv2.c
@@ -326,12 +326,16 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
 	u32 reg_val, pgc;
 	int ret;
 
-	if (!IS_ERR(domain->regulator)) {
+	if (!IS_ERR(domain->regulator))
 		ret = regulator_enable(domain->regulator);
-		if (ret) {
-			dev_err(domain->dev, "failed to enable regulator\n");
-			return ret;
-		}
+	else if (PTR_ERR(domain->regulator) == -ENOENT)
+		ret = -ENOENT;
+	else
+		ret = 0;
+
+	if (ret) {
+		dev_err(domain->dev, "failed to enable regulator\n");
+		return ret;
 	}
 
 	/* Enable reset clocks for all devices in the domain */
@@ -1145,9 +1149,21 @@ static int imx_pgc_domain_probe(struct device *dev)
 
 	domain->regulator = regulator_get(domain->dev, "power");
 	if (IS_ERR(domain->regulator)) {
-		if (PTR_ERR(domain->regulator) != -ENODEV)
+		/* On i.MX8M, we usually set up PMIC in early board code once
+		 * and don't do dynamic voltage regulation in barebox.
+		 * This means, even with deferred probe we will never succeed.
+		 * Instead, let's just print an info message and continue
+		 *
+		 * If you actually require access to a regulator here that has
+		 * a driver, enable deep probe for your board.
+		 */
+		if (PTR_ERR(domain->regulator) == -EPROBE_DEFER) {
+			dev_info(domain->dev, "Failed to get domain's regulator (ignored)\n");
+			domain->regulator = ERR_PTR(-ENOENT);
+		} else if (PTR_ERR(domain->regulator) != -ENODEV) {
 			return dev_err_probe(domain->dev, PTR_ERR(domain->regulator),
 					     "Failed to get domain's regulator\n");
+		}
 	} else if (domain->voltage) {
 		regulator_set_voltage(domain->regulator,
 				      domain->voltage, domain->voltage);
-- 
2.39.2




  reply	other threads:[~2024-03-13 14:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 14:41 [PATCH master 1/2] ARM: i.MX8MQ: fix early boot hang Ahmad Fatoum
2024-03-13 14:41 ` Ahmad Fatoum [this message]
2024-03-15  7:09 ` Sascha Hauer

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=20240313144136.2157496-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox