From: alice.guo@oss.nxp.com
To: u-boot@lists.denx.de, "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Cc: Marek Vasut <marex@denx.de>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Tom Rini <trini@konsulko.com>, Ye Li <ye.li@nxp.com>,
Fabio Estevam <festevam@gmail.com>,
Tim Harvey <tharvey@gateworks.com>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Stefano Babic <sbabic@nabladev.com>, Peng Fan <peng.fan@nxp.com>,
Lukasz Majewski <lukma@denx.de>, Simon Glass <sjg@chromium.org>,
David Zang <davidzangcs@gmail.com>,
Alice Guo <alice.guo@nxp.com>
Subject: [PATCH v1 1/4] ehci-mx6: Add powerup_fixup implementation
Date: Fri, 28 Nov 2025 21:16:33 +0800 [thread overview]
Message-ID: <20251128-usb2-v1-1-25ec5ac127ff@nxp.com> (raw)
In-Reply-To: <20251128-usb2-v1-0-25ec5ac127ff@nxp.com>
From: Ye Li <ye.li@nxp.com>
When doing port reset, the PR bit of PORTSC1 will be automatically
cleared by our IP, but standard EHCI needs explicit clear by software.
The EHCI-HCD driver follow the EHCI specification, so after 50ms wait,
it clear the PR bit by writting to the PORTSC1 register with value
loaded before setting PR.
This sequence is ok for our IP when the delay time is exact. But when
the timer is slower, some bits like PE, PSPD have been set by controller
automatically after the PR is automatically cleared. So the writing to
the PORTSC1 will overwrite these bits set by controller. And eventually
the driver gets wrong status.
We implement the powerup_fixup operation which delays 50ms and will
check the PR until it is cleared by controller. And will update the reg
value which is written to PORTSC register by EHCI-HCD driver. This is
much safer than depending on the delay time to be accurate and aligining
with controller's behaiver.
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Alice Guo <alice.guo@nxp.com>
---
drivers/usb/host/ehci-mx6.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 25907f22612..0b3f1b69657 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -265,6 +265,25 @@ int usb_phy_mode(int port)
}
#endif
+static void ehci_mx6_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg,
+ uint32_t *reg)
+{
+ u32 result;
+ int usec = 2000;
+
+ mdelay(50);
+
+ do {
+ result = ehci_readl(status_reg);
+ udelay(5);
+ if (!(result & EHCI_PS_PR))
+ break;
+ usec--;
+ } while (usec > 0);
+
+ *reg = ehci_readl(status_reg);
+}
+
#if !defined(CONFIG_PHY)
/* Should be done in the MXS PHY driver */
static void usb_oc_config(struct usbnc_regs *usbnc, int index)
@@ -331,6 +350,10 @@ int __weak board_ehci_power(int port, int on)
return 0;
}
+static const struct ehci_ops mx6_ehci_ops = {
+ .powerup_fixup = ehci_mx6_powerup_fixup,
+};
+
int ehci_hcd_init(int index, enum usb_init_type init,
struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{
@@ -394,6 +417,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,
}
#endif
+ ehci_set_controller_priv(index, NULL, &mx6_ehci_ops);
+
type = board_usb_phy_mode(index);
if (hccr && hcor) {
@@ -502,7 +527,8 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev)
}
static const struct ehci_ops mx6_ehci_ops = {
- .init_after_reset = mx6_init_after_reset
+ .powerup_fixup = ehci_mx6_powerup_fixup,
+ .init_after_reset = mx6_init_after_reset,
};
static int ehci_usb_phy_mode(struct udevice *dev)
--
2.43.0
next prev parent reply other threads:[~2025-11-28 13:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 13:16 [PATCH 0/4] Enable USB on i.MX8ULP EVK alice.guo
2025-11-28 13:16 ` alice.guo [this message]
2025-11-30 1:05 ` [PATCH v1 1/4] ehci-mx6: Add powerup_fixup implementation Marek Vasut
2025-12-01 11:07 ` 回复: " Alice Guo (OSS)
2025-12-01 17:47 ` Marek Vasut
2025-11-28 13:16 ` [PATCH v1 2/4] ehci-mx6: Update USB host driver for iMX8ULP alice.guo
2025-11-30 1:06 ` Marek Vasut
2025-11-28 13:16 ` [PATCH v1 3/4] imx8ulp: clock: Drop CONFIG_USB_MAX_CONTROLLER_COUNT dependency alice.guo
2025-11-28 13:16 ` [PATCH v1 4/4] imx8ulp: dst: Enable USB controller at 0x29920000 in host mode alice.guo
2025-11-28 13:28 ` Fabio Estevam
2025-11-30 0:06 ` Fabio Estevam
2025-12-01 11:05 ` 回复: " Alice Guo (OSS)
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=20251128-usb2-v1-1-25ec5ac127ff@nxp.com \
--to=alice.guo@oss.nxp.com \
--cc=alice.guo@nxp.com \
--cc=davidzangcs@gmail.com \
--cc=festevam@gmail.com \
--cc=lukma@denx.de \
--cc=marek.vasut+renesas@mailbox.org \
--cc=marex@denx.de \
--cc=mkorpershoek@kernel.org \
--cc=patrice.chotard@foss.st.com \
--cc=peng.fan@nxp.com \
--cc=sbabic@nabladev.com \
--cc=sjg@chromium.org \
--cc=tharvey@gateworks.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
--cc=ye.li@nxp.com \
/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