[PATCH v1 2/4] ehci-mx6: Update USB host driver for iMX8ULP
alice.guo at oss.nxp.com
alice.guo at oss.nxp.com
Fri Nov 28 14:16:34 CET 2025
From: Alice Guo <alice.guo at nxp.com>
iMX8ULP uses same controller and PHY as iMX7ULP, but with two instances
respectively. Update the driver to adapt for iMX8ULP.
When getting the phy register base from DTS node, change to use
fdtdec_get_addr_size_auto_noparent(). Because the cell size in soc node
is defined to 1 in dts, while fdtdec_get_addr() supposes to cell size is
2 on 64 bits platform.
Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Alice Guo <alice.guo at nxp.com>
---
drivers/usb/host/Kconfig | 2 +-
drivers/usb/host/ehci-mx6.c | 43 +++++++++++++++++++++++++++++--------------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 427b62e934b..3d93d434aca 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -202,7 +202,7 @@ config USB_EHCI_MX5
config USB_EHCI_MX6
bool "Support for i.MX6/i.MX7ULP on-chip EHCI USB controller"
- depends on ARCH_MX6 || ARCH_MX7ULP || ARCH_IMXRT
+ depends on ARCH_MX6 || ARCH_MX7ULP || ARCH_IMXRT || ARCH_IMX8ULP
select EHCI_HCD_INIT_AFTER_RESET
default y
---help---
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 0b3f1b69657..5c5aaa4e93c 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -160,25 +160,29 @@ static void __maybe_unused
usb_power_config_mx7(void *usbnc) { }
#endif
-#if defined(CONFIG_MX7ULP) && !defined(CONFIG_PHY)
+#if (defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8ULP)) && !defined(CONFIG_PHY)
static void usb_power_config_mx7ulp(struct usbphy_regs __iomem *usbphy)
{
- if (!is_mx7ulp())
+ if (!(is_mx7ulp() || is_imx8ulp()))
return;
writel(ANADIG_USB2_CHRG_DETECT_EN_B |
ANADIG_USB2_CHRG_DETECT_CHK_CHRG_B,
&usbphy->usb1_chrg_detect);
+#if IS_ENABLED(CONFIG_IMX8ULP)
+ enable_usb_pll((ulong)usbphy);
+#else
scg_enable_usb_pll(true);
+#endif
}
#else
static void __maybe_unused
usb_power_config_mx7ulp(void *usbphy) { }
#endif
-#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT)
-static const unsigned phy_bases[] = {
+#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT) || defined(CONFIG_IMX8ULP)
+static const ulong phy_bases[] = {
USB_PHY0_BASE_ADDR,
#if defined(USB_PHY1_BASE_ADDR)
USB_PHY1_BASE_ADDR,
@@ -374,6 +378,11 @@ int ehci_hcd_init(int index, enum usb_init_type init,
(struct usbphy_regs __iomem *)USB_PHY0_BASE_ADDR;
struct usbnc_regs *usbnc = (struct usbnc_regs *)(USB_BASE_ADDR +
(0x10000 * index) + USBNC_OFFSET);
+#elif defined(CONFIG_IMX8ULP)
+ u32 controller_spacing = 0x20000;
+ struct usbphy_regs __iomem *usbphy = (struct usbphy_regs __iomem *)(ulong)phy_bases[index];
+ struct usbnc_regs *usbnc = (struct usbnc_regs *)(USB_BASE_ADDR +
+ (controller_spacing * index) + USBNC_OFFSET);
#endif
struct usb_ehci *ehci = (struct usb_ehci *)(USB_BASE_ADDR +
(controller_spacing * index));
@@ -404,7 +413,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
usb_power_config_mx6(anatop, index);
#elif defined (CONFIG_MX7)
usb_power_config_mx7(usbnc);
-#elif defined (CONFIG_MX7ULP)
+#elif defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8ULP)
usb_power_config_mx7ulp(usbphy);
#endif
@@ -544,15 +553,18 @@ static int ehci_usb_phy_mode(struct udevice *dev)
* About fsl,usbphy, Refer to
* Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt.
*/
- if (is_mx6() || is_mx7ulp() || is_imxrt()) {
+ if (is_mx6() || is_mx7ulp() || is_imxrt() || is_imx8ulp()) {
phy_off = fdtdec_lookup_phandle(blob,
offset,
"fsl,usbphy");
- if (phy_off < 0)
- return -EINVAL;
+ if (phy_off < 0) {
+ phy_off = fdtdec_lookup_phandle(blob, offset, "phys");
+ if (phy_off < 0)
+ return -EINVAL;
+ }
- addr = (void __iomem *)fdtdec_get_addr(blob, phy_off,
- "reg");
+ addr = (void __iomem *)fdtdec_get_addr_size_auto_noparent(blob, phy_off,
+ "reg", 0, NULL, false);
if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
return -EINVAL;
@@ -620,13 +632,15 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
if (misc_off < 0)
return -EINVAL;
- addr = (void __iomem *)fdtdec_get_addr(blob, phy_off, "reg");
+ addr = (void __iomem *)fdtdec_get_addr_size_auto_noparent(blob, phy_off,
+ "reg", 0, NULL, false);
if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
addr = NULL;
priv->phy_addr = addr;
- addr = (void __iomem *)fdtdec_get_addr(blob, misc_off, "reg");
+ addr = (void __iomem *)fdtdec_get_addr_size_auto_noparent(blob, misc_off,
+ "reg", 0, NULL, false);
if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
return -EINVAL;
@@ -646,7 +660,8 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
if (anatop_off < 0)
return -EINVAL;
- addr = (void __iomem *)fdtdec_get_addr(blob, anatop_off, "reg");
+ addr = (void __iomem *)fdtdec_get_addr_size_auto_noparent(blob, anatop_off,
+ "reg", 0, NULL, false);
if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
return -EINVAL;
@@ -724,7 +739,7 @@ static int ehci_usb_probe(struct udevice *dev)
usb_oc_config(priv->misc_addr, priv->portnr);
-#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT)
+#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT) || defined(CONFIG_IMX8ULP)
usb_internal_phy_clock_gate(priv->phy_addr, 1);
usb_phy_enable(ehci, priv->phy_addr);
#endif
--
2.43.0
More information about the U-Boot
mailing list