mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] usb: chipidea: imx: call enable_clk after all resources are requested
Date: Wed,  6 Jul 2022 16:21:04 +0200	[thread overview]
Message-ID: <20220706142105.2266956-4-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20220706142105.2266956-1-m.felsch@pengutronix.de>

Currently we enable the clock immediately after requesting it and leave
it on the whole time. Afterwards if the phy request is failing we leave
the usb-controller <-> usb-phy connection in a partly initialized state.
At least on i.MX8M SoCs this can cause strange system hangs during boot.

The (more) correct way would be to have the whole power-domain framework
and the blk-ctrl driver support within barebox. So we can leave the
power-domain in a known good state for linux. Since this is not the case
we can move the clk_enable() call so it gets called after we know that
all ressources are available. So the probability to leave the system in
a partly initialized state is lesser.

Drop the !IS_ERR() since NULL and errors are handled in clk_enable() as
well.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/usb/imx/chipidea-imx.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index bf8b6f1eb8..f71cf80b7d 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -260,8 +260,6 @@ static int imx_chipidea_probe(struct device_d *dev)
 	 * devices which have only one.
 	 */
 	ci->clk = clk_get(dev, NULL);
-	if (!IS_ERR(ci->clk))
-		clk_enable(ci->clk);
 
 	/* Device trees are using both "phys" and "fsl,usbphy".  Prefer the
 	 * more modern former one but fall back to the old one.
@@ -302,6 +300,14 @@ static int imx_chipidea_probe(struct device_d *dev)
 	ci->data.drvdata = ci;
 	ci->data.usbphy = ci->usbphy;
 
+	/*
+	 * Enable the clock after we ensured that all resources are available.
+	 * This is crucial since the phy can be missing which and so the
+	 * usb-controller <-> usb-phy communication is only partly initialized.
+	 * This can trigger strange system hangs at least on i.MX8M SoCs.
+	 */
+	clk_enable(ci->clk);
+
 	if ((ci->flags & MXC_EHCI_PORTSC_MASK) == MXC_EHCI_MODE_HSIC)
 		imx_chipidea_port_init(ci);
 
-- 
2.30.2




  parent reply	other threads:[~2022-07-06 14:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 14:21 [PATCH 0/4] MX8MN-EVK DDR4 Support Marco Felsch
2022-07-06 14:21 ` [PATCH 1/4] phy: fix deep probe support Marco Felsch
2022-07-07 14:39   ` Johannes Zink
2022-07-06 14:21 ` [PATCH 2/4] phy: propagate error in of_phy_get_by_phandle Marco Felsch
2022-07-07 14:39   ` Johannes Zink
2022-07-06 14:21 ` Marco Felsch [this message]
2022-07-07 14:40   ` [PATCH 3/4] usb: chipidea: imx: call enable_clk after all resources are requested Johannes Zink
2022-07-06 14:21 ` [PATCH 4/4] ARM: i.MX8MN: pass along correct DT depending on variant Marco Felsch
2022-07-11  9:22 ` [PATCH 0/4] MX8MN-EVK DDR4 Support 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=20220706142105.2266956-4-m.felsch@pengutronix.de \
    --to=m.felsch@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