[PATCH v2 2/3] phy: sun4i-usb: Assert PHY resets in sun4i_usb_phy_probe()
Bobek Brzeczyszczykiewicz via B4 Relay
devnull+admin.roadbobek.com at kernel.org
Sun Nov 22 22:54:08 PST 2026
From: Bobek Brzeczyszczykiewicz <admin at roadbobek.com>
When a bootloader initializes USB before booting Linux without first
tearing down the controller, phy->reset may already be deasserted when
Linux probes the USB PHY driver.
Because reset_control_deassert() alone is a no-op on an already
deasserted reset line, stale USB PHY state can persist across the
bootloader-to-kernel handoff. Asserting phy->reset inside
sun4i_usb_phy_init(), however, could disrupt active PHYs on SoCs with
needs_phy2_siddq (such as the Allwinner H616), where PHY0, PHY1, and
PHY3 depend on PHY2 remaining out of reset once enabled.
Request exclusive reset controls via devm_reset_control_get_exclusive()
and assert all PHY resets in sun4i_usb_phy_probe() before registering
the PHY provider so every PHY starts from a clean reset state before
any consumer calls sun4i_usb_phy_init().
Tested on an Allwinner A33 Q8 tablet (Laser MID-786).
Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")
Signed-off-by: Bobek Brzeczyszczykiewicz <admin at roadbobek.com>
---
drivers/phy/allwinner/phy-sun4i-usb.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index f26eed0db17e..a62558124d2d 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -787,7 +787,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
continue;
snprintf(name, sizeof(name), "usb%d_reset", i);
- phy->reset = devm_reset_control_get(dev, name);
+ phy->reset = devm_reset_control_get_exclusive(dev, name);
if (IS_ERR(phy->reset)) {
if (PTR_ERR(phy->reset) == -ENOENT)
break;
@@ -855,6 +855,25 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
}
data->num_phys = i;
+ /*
+ * Assert reset on each PHY before they get deasserted in
+ * sun4i_usb_phy_init(), in case the bootloader left them active.
+ */
+ for (i = 0; i < data->num_phys; i++) {
+ struct sun4i_usb_phy *phy = data->phys + i;
+
+ if (data->cfg->missing_phys & BIT(i))
+ continue;
+
+ ret = reset_control_assert(phy->reset);
+ if (ret) {
+ dev_err(dev, "Err asserting reset on PHY: %d\n", ret);
+ return ret;
+ }
+ }
+
+ usleep_range(10, 20); /* hold PHY in reset briefly */
+
data->id_det_irq = gpiod_to_irq(data->id_det_gpio);
if (data->id_det_irq > 0) {
ret = devm_request_irq(dev, data->id_det_irq,
--
2.53.0
More information about the linux-phy
mailing list