From: Bobek Brzeczyszczykiewicz via B4 Relay <devnull+admin.roadbobek.com@kernel.org>
To: Bin Liu <b-liu@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Vinod Koul <vkoul@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Hans de Goede <hansg@kernel.org>, Felipe Balbi <balbi@ti.com>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Maxime Ripard <mripard@kernel.org>,
Andre Przywara <andre.przywara@arm.com>
Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-phy@lists.infradead.org,
Bobek Brzeczyszczykiewicz <admin@roadbobek.com>
Subject: [PATCH v2 2/3] phy: sun4i-usb: Assert PHY resets in sun4i_usb_phy_probe()
Date: Mon, 23 Nov 2026 06:54:08 +0000 [thread overview]
Message-ID: <20261123-usb-sunxi-reset-fix-v2-2-4e51d3a64964@roadbobek.com> (raw)
In-Reply-To: <20261123-usb-sunxi-reset-fix-v2-0-4e51d3a64964@roadbobek.com>
From: Bobek Brzeczyszczykiewicz <admin@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@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
next prev parent reply other threads:[~2026-11-23 6:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 6:54 [PATCH v2 0/3] usb/phy: sunxi: Assert reset before deasserting on init Bobek Brzeczyszczykiewicz via B4 Relay
2026-11-23 6:54 ` [PATCH v2 1/3] usb: musb: " Bobek Brzeczyszczykiewicz via B4 Relay
2026-11-23 6:54 ` Bobek Brzeczyszczykiewicz via B4 Relay [this message]
2026-11-23 6:54 ` [PATCH v2 3/3] phy: sun4i-usb: Fix phy2->clk2 reference imbalance in sun4i_usb_phy_init() Bobek Brzeczyszczykiewicz via B4 Relay
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=20261123-usb-sunxi-reset-fix-v2-2-4e51d3a64964@roadbobek.com \
--to=devnull+admin.roadbobek.com@kernel.org \
--cc=admin@roadbobek.com \
--cc=andre.przywara@arm.com \
--cc=b-liu@ti.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=kishon@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-usb@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=samuel@sholland.org \
--cc=vkoul@kernel.org \
--cc=wens@kernel.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
all inboxes | Powered by JetHome®