[PATCH] usb: dwc2: Change ordering of phy_init and phy_power_on
From: Jules Maselbas <hidden>
Date: 2021-01-12 17:02:38
Subsystem:
designware usb2 drd ip driver, the rest, usb subsystem · Maintainers:
Minas Harutyunyan, Linus Torvalds, Greg Kroah-Hartman
Call phy_init before phy_power_on as this is the intended way of using
the generic phy api.
Signed-off-by: Jules Maselbas <redacted>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Minas Harutyunyan <hminas@synopsys.com>
Cc: Kishon Vijay Abraham I <redacted>
---
I have quickly looked at usb-phy if this change could break something or
not. The following cmd list the compatible strings for usb-phy used by dwc2:
git grep 'snps,dwc2' -- arch/ | sed 's/:.*$//' | { while read file; do \
phyname=$(git grep -A10 'snps,dwc2' -- "$file" | \
sed -n '/phys/{s/.*<&\([^ >]*\).*/\1/p}'); \
[ "$phyname" ] && { \
git grep -A10 "${phyname}: " -- "$file" | \
grep -m1 'compatible'; \
}; done };
From this output I took a look at:
- brcm,kona-usb2-phy
- samsung,exynos3250-usb2-phy
- rockchip,rk3288-usb
- amlogic,meson-gxbb-usb2-phy
- amlogic,meson-gxl-usb2-phy
- img,pistachio-usb-phy
Most of these phys only defines .power_on and .power_off;
brcm,kona-usb2-phy also defines .init; and amlogic,meson-gxl-usb2-phy defines
.init .exit and .reset
From what I've seen it seems to be OK for these two phy to call
init/exit first and then power_on/power_off.
---
drivers/usb/dwc2/platform.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index b58ce996add7..a07dff088a26 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c@@ -142,9 +142,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) } else if (hsotg->plat && hsotg->plat->phy_init) { ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } else { - ret = phy_power_on(hsotg->phy); + ret = phy_init(hsotg->phy); if (ret == 0) - ret = phy_init(hsotg->phy); + ret = phy_power_on(hsotg->phy); } return ret;
@@ -176,9 +176,9 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg) } else if (hsotg->plat && hsotg->plat->phy_exit) { ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } else { - ret = phy_exit(hsotg->phy); + ret = phy_power_off(hsotg->phy); if (ret == 0) - ret = phy_power_off(hsotg->phy); + ret = phy_exit(hsotg->phy); } if (ret) return ret;
--
2.17.1