While a separate usbmisc driver could be added, no such driver currently exists, and it would not necessarily be part of the PHY subsystem. Rather than making the misc setup conditional on CONFIG_PHY, make it depend on the existence of a fsl,usbmisc property. This will allow enabling CONFIG_PHY on the i.MX7D for the NOP PHY driver's power domain support.
Also update the code that reads the usbmisc address to use the modern ofnode API and fix the portnr to be determined from the usbmisc phandle arg instead of the alias seqno. Signed-off-by: Nora Schiffer <[email protected]> --- drivers/usb/host/ehci-mx6.c | 65 +++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 25907f22612..16a45b82399 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -141,23 +141,21 @@ static void __maybe_unused usb_power_config_mx6(void *anatop, int anatop_bits_index) { } #endif -#if defined(CONFIG_MX7) && !defined(CONFIG_PHY) -static void usb_power_config_mx7(struct usbnc_regs *usbnc) +#if defined(CONFIG_MX7) +static void usb_misc_config_mx7(struct usbnc_regs *usbnc) { - void __iomem *phy_cfg2 = (void __iomem *)(&usbnc->phy_cfg2); - - if (!is_mx7()) + if (!is_mx7() || !usbnc) return; /* * Clear the ACAENB to enable usb_otg_id detection, * otherwise it is the ACA detection enabled. */ - clrbits_le32(phy_cfg2, USBNC_PHYCFG2_ACAENB); + clrbits_le32(&usbnc->phy_cfg2, USBNC_PHYCFG2_ACAENB); } #else static void __maybe_unused -usb_power_config_mx7(void *usbnc) { } +usb_misc_config_mx7(void *usbnc) { } #endif #if defined(CONFIG_MX7ULP) && !defined(CONFIG_PHY) @@ -380,7 +378,7 @@ int ehci_hcd_init(int index, enum usb_init_type init, #if defined(CONFIG_MX6) || defined(CONFIG_IMXRT) usb_power_config_mx6(anatop, index); #elif defined (CONFIG_MX7) - usb_power_config_mx7(usbnc); + usb_misc_config_mx7(usbnc); #elif defined (CONFIG_MX7ULP) usb_power_config_mx7ulp(usbphy); #endif @@ -431,10 +429,10 @@ struct ehci_mx6_priv_data { struct phy phy; enum usb_init_type init_type; enum usb_phy_interface phy_type; -#if !defined(CONFIG_PHY) + void __iomem *misc_addr; int portnr; +#if !defined(CONFIG_PHY) void __iomem *phy_addr; - void __iomem *misc_addr; void __iomem *anatop_addr; #endif }; @@ -465,7 +463,6 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) #if !defined(CONFIG_PHY) usb_power_config_mx6(priv->anatop_addr, priv->portnr); - usb_power_config_mx7(priv->misc_addr); usb_power_config_mx7ulp(priv->phy_addr); usb_oc_config(priv->misc_addr, priv->portnr); @@ -476,6 +473,8 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) #endif #endif + usb_misc_config_mx7(priv->misc_addr); + #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { int ret; @@ -576,12 +575,29 @@ static int ehci_usb_of_to_plat(struct udevice *dev) static int mx6_parse_dt_addrs(struct udevice *dev) { -#if !defined(CONFIG_PHY) struct ehci_mx6_priv_data *priv = dev_get_priv(dev); - int phy_off, misc_off; + struct ofnode_phandle_args misc_args; + void *__iomem addr; + int ret; + + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), "fsl,usbmisc", "#index-cells", 0, 0, + &misc_args); + if (ret == 0) { + if (misc_args.args_count != 1) + return -EINVAL; + + addr = (void __iomem *)ofnode_get_addr(misc_args.node); + if ((fdt_addr_t)addr == FDT_ADDR_T_NONE) + return -EINVAL; + + priv->misc_addr = addr; + priv->portnr = misc_args.args[0]; + } + +#if !defined(CONFIG_PHY) const void *blob = gd->fdt_blob; int offset = dev_of_offset(dev); - void *__iomem addr; + int phy_off; phy_off = fdtdec_lookup_phandle(blob, offset, "fsl,usbphy"); if (phy_off < 0) { @@ -590,30 +606,14 @@ static int mx6_parse_dt_addrs(struct udevice *dev) return -EINVAL; } - misc_off = fdtdec_lookup_phandle(blob, offset, "fsl,usbmisc"); - if (misc_off < 0) - return -EINVAL; - addr = (void __iomem *)fdtdec_get_addr(blob, phy_off, "reg"); 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"); - if ((fdt_addr_t)addr == FDT_ADDR_T_NONE) - return -EINVAL; - - priv->misc_addr = addr; - #if defined(CONFIG_MX6) - int anatop_off, ret, devnump; - - ret = fdtdec_get_alias_seq(blob, dev->uclass->uc_drv->name, - phy_off, &devnump); - if (ret < 0) - return ret; - priv->portnr = devnump; + int anatop_off; /* Resolve ANATOP offset through USB PHY node */ anatop_off = fdtdec_lookup_phandle(blob, phy_off, "fsl,anatop"); @@ -693,7 +693,6 @@ static int ehci_usb_probe(struct udevice *dev) #if !defined(CONFIG_PHY) usb_power_config_mx6(priv->anatop_addr, priv->portnr); - usb_power_config_mx7(priv->misc_addr); usb_power_config_mx7ulp(priv->phy_addr); usb_oc_config(priv->misc_addr, priv->portnr); @@ -708,6 +707,8 @@ static int ehci_usb_probe(struct udevice *dev) goto err_regulator; #endif + usb_misc_config_mx7(priv->misc_addr); + if (priv->init_type == USB_INIT_HOST) { setbits_le32(&ehci->usbmode, CM_HOST); writel(mx6_portsc(priv->phy_type), &ehci->portsc); -- 2.55.0
