diff mbox series

[5/7] usb: ehci-mx6: fix controller index for imx8m and imx8

Message ID 20200629021350.21262-5-peng.fan@nxp.com
State New
Headers show
Series [1/7] usb: ehci-mx6: Add powerup_fixup implementation | expand

Commit Message

Peng Fan June 29, 2020, 2:13 a.m. UTC
From: Ye Li <ye.li at nxp.com>

The bind codes calculate the address offset for controller index, but
it is wrong for imx8m and imx8. It causes secondary controller fails to
work. So fix this problem, and also change all seq to req_seq.

There is another issue here for imx8, the codes use runtime CPU type check.
One iMX8, this check depends on IPC communication with SCFW, and need
MU driver been probed. But the usbotg is configured with "u-boot,dm_spl"
property for SDP download in SPL, so it will bind in early DM in u-boot
while the MU is not bound at same time, so the CPU type check will hang.
Fix it to use static check.

Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/usb/host/ehci-mx6.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Marek Vasut June 29, 2020, 2:34 a.m. UTC | #1
On 6/29/20 4:13 AM, Peng Fan wrote:
[...]

> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index 046c6ab283..8090cb27fe 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -687,7 +687,11 @@ static int ehci_usb_bind(struct udevice *dev)
>  	 * With these changes in place, the ad-hoc indexing goes away and
>  	 * the driver is fully converted to DT probing.
>  	 */
> -	u32 controller_spacing = is_mx7() ? 0x10000 : 0x200;
> +	u32 controller_spacing;
> +	if (IS_ENABLED(CONFIG_MX6))
> +		controller_spacing = 0x200;
> +	else
> +		controller_spacing = 0x10000;

This looks related to this problem:
501547cec1 ("usb: ehci-mx6: Fix bus enumeration for DM case")
Maybe instead of adding to the problem, it would make sense to convert
the driver to DM fully and then this problem with figuring out offsets
would go away ?
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 046c6ab283..8090cb27fe 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -687,7 +687,11 @@  static int ehci_usb_bind(struct udevice *dev)
 	 * With these changes in place, the ad-hoc indexing goes away and
 	 * the driver is fully converted to DT probing.
 	 */
-	u32 controller_spacing = is_mx7() ? 0x10000 : 0x200;
+	u32 controller_spacing;
+	if (IS_ENABLED(CONFIG_MX6))
+		controller_spacing = 0x200;
+	else
+		controller_spacing = 0x10000;
 	fdt_addr_t addr = devfdt_get_addr_index(dev, 0);
 
 	dev->req_seq = (addr - USB_BASE_ADDR) / controller_spacing;
@@ -714,7 +718,7 @@  static int ehci_usb_probe(struct udevice *dev)
 	}
 
 	priv->ehci = ehci;
-	priv->portnr = dev->seq;
+	priv->portnr = dev->req_seq;
 	priv->init_type = type;
 
 	ret = board_usb_init(priv->portnr, priv->init_type);
@@ -766,7 +770,7 @@  int ehci_usb_remove(struct udevice *dev)
 
 	ehci_deregister(dev);
 
-	return board_usb_cleanup(dev->seq, priv->init_type);
+	return board_usb_cleanup(dev->req_seq, priv->init_type);
 }
 
 static const struct udevice_id mx6_usb_ids[] = {