mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: mgr@pengutronix.de
Subject: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Date: Mon, 21 Dec 2020 01:32:50 +0100	[thread overview]
Message-ID: <20201221003251.83042-2-ahmad@a3f.at> (raw)
In-Reply-To: <20201221003251.83042-1-ahmad@a3f.at>

Linux doesn't seem to enforce a fixed order between phy_init and
phy_power_on. The Linux dwc2 driver does power_on and then phy_init,
which is the inverse of what barebox is currently doing.

The PHYs normally used with dwc2 are written with this in mind.
For example, our stm32-usbphyc driver fails to disable:

  ERROR: stm32-usbphyc 5a006000.usbphyc@5a006000.of: PLL not reset
  ERROR: phy1: phy exit failed --> -5

Because Linux does exit -> power_off, but barebox does power_off ->
exit.

Issue was raised upstream:
https://lore.kernel.org/lkml/6cd01e79-fdc0-3bd4-32b5-a85142533f8a@pengutronix.de/T/#t

Until this is settled, swap the order to follow what Linux does.
This is suboptimal, because it means controller drivers have different
order of the operations and that you can't combine arbitrary PHYs and
controllers, but it seems unlikely we will support combinations that
aren't supported by Linux in the first place anyway.

Cc: Jules Maselbas <jmaselbas@kalray.eu>
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/usb/dwc2/dwc2.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 65b92b542efc..8f7440471c31 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -78,12 +78,13 @@ static int dwc2_probe(struct device_d *dev)
 		goto clk_disable;
 	}
 
-	ret = phy_init(dwc2->phy);
+	ret = phy_power_on(dwc2->phy);
 	if (ret)
 		goto clk_disable;
-	ret = phy_power_on(dwc2->phy);
+
+	ret = phy_init(dwc2->phy);
 	if (ret)
-		goto err_phy_power;
+		goto phy_power_off;
 
 	ret = dwc2_check_core_version(dwc2);
 	if (ret)
@@ -119,9 +120,9 @@ static int dwc2_probe(struct device_d *dev)
 
 	return 0;
 error:
-	phy_power_off(dwc2->phy);
-err_phy_power:
 	phy_exit(dwc2->phy);
+phy_power_off:
+	phy_power_off(dwc2->phy);
 clk_disable:
 	clk_disable(dwc2->clk);
 clk_put:
@@ -139,8 +140,8 @@ static void dwc2_remove(struct device_d *dev)
 	dwc2_host_uninit(dwc2);
 	dwc2_gadget_uninit(dwc2);
 
-	phy_power_off(dwc2->phy);
 	phy_exit(dwc2->phy);
+	phy_power_off(dwc2->phy);
 }
 
 static const struct of_device_id dwc2_platform_dt_ids[] = {
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-12-21  0:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21  0:32 [PATCH 0/2] usb: dwc2: gadget: fix stm32mp1 hang on barebox shutdown Ahmad Fatoum
2020-12-21  0:32 ` Ahmad Fatoum [this message]
2021-01-06 10:05   ` [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy Sascha Hauer
2022-03-21 22:17     ` Michael Grzeschik
2022-03-22  5:35       ` Ahmad Fatoum
2022-03-22  8:19         ` Michael Grzeschik
2022-03-22  8:25           ` Ahmad Fatoum
2022-03-22  8:29             ` Michael Grzeschik
2022-03-22  9:23               ` Jules Maselbas
2020-12-21  0:32 ` [PATCH 2/2] regulator: stm32-pwr: don't propagate regulator turn-off to supply Ahmad Fatoum

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=20201221003251.83042-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    --cc=mgr@pengutronix.de \
    /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