diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2022-07-06 16:21:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-07-11 11:21:54 +0200 |
commit | 51712f5eeb6eae358657149f9f8bb680b52311cd (patch) | |
tree | 19f4d29e49e2b5d2e792a354e9d998a4a4b07134 /drivers | |
parent | 8f665589495327f3a8c4c8cdb90f821480df74b0 (diff) | |
download | barebox-51712f5eeb6eae358657149f9f8bb680b52311cd.tar.gz barebox-51712f5eeb6eae358657149f9f8bb680b52311cd.tar.xz |
usb: chipidea: imx: call enable_clk after all resources are requested
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>
Tested-by: Johannes Zink <j.zink@pengutronix.de> # i.MX7
Link: https://lore.barebox.org/20220706142105.2266956-4-m.felsch@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/imx/chipidea-imx.c | 10 |
1 files 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); |