summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-02-11 15:22:30 +0300
committerTom Rini <trini@konsulko.com>2022-02-11 15:22:30 +0300
commit86752b2814091bd8df30bdbf38768924b60cccab (patch)
tree537ae5f65a981e533b79eb38f8ec09a52b158682 /drivers
parentfe203a05fb663fa9bc42a9ef9ae51a6ed01a4a90 (diff)
parent1f54025d70c4c9e6ec8d82d8b69b0d66a7bbbdc1 (diff)
downloadu-boot-86752b2814091bd8df30bdbf38768924b60cccab.tar.xz
Merge https://source.denx.de/u-boot/custodians/u-boot-usb
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/ci_udc.c5
-rw-r--r--drivers/usb/host/ehci-mx6.c23
2 files changed, 22 insertions, 6 deletions
diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index 226a9e6d67..542684c1c3 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -402,6 +402,9 @@ align:
flush:
hwaddr = (unsigned long)ci_req->hw_buf;
+ if (!hwaddr)
+ return 0;
+
aligned_used_len = roundup(req->length, ARCH_DMA_MINALIGN);
flush_dcache_range(hwaddr, hwaddr + aligned_used_len);
@@ -415,7 +418,7 @@ static void ci_debounce(struct ci_req *ci_req, int in)
unsigned long hwaddr = (unsigned long)ci_req->hw_buf;
uint32_t aligned_used_len;
- if (in)
+ if (in || !hwaddr)
return;
aligned_used_len = roundup(req->actual, ARCH_DMA_MINALIGN);
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 1bd6147c76..060b02accc 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -543,7 +543,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
plat->init_type = USB_INIT_DEVICE;
else
plat->init_type = USB_INIT_HOST;
- } else if (is_mx7()) {
+ } else if (is_mx7() || is_imx8mm() || is_imx8mn()) {
phy_status = (void __iomem *)(addr +
USBNC_PHY_STATUS_OFFSET);
val = readl(phy_status);
@@ -573,9 +573,8 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
case USB_DR_MODE_PERIPHERAL:
plat->init_type = USB_INIT_DEVICE;
break;
- case USB_DR_MODE_OTG:
- case USB_DR_MODE_UNKNOWN:
- return ehci_usb_phy_mode(dev);
+ default:
+ plat->init_type = USB_INIT_UNKNOWN;
};
return 0;
@@ -677,6 +676,20 @@ static int ehci_usb_probe(struct udevice *dev)
mdelay(1);
#endif
+ /*
+ * If the device tree didn't specify host or device,
+ * the default is USB_INIT_UNKNOWN, so we need to check
+ * the register. For imx8mm and imx8mn, the clocks need to be
+ * running first, so we defer the check until they are.
+ */
+ if (priv->init_type == USB_INIT_UNKNOWN) {
+ ret = ehci_usb_phy_mode(dev);
+ if (ret)
+ goto err_clk;
+ else
+ priv->init_type = plat->init_type;
+ }
+
#if CONFIG_IS_ENABLED(DM_REGULATOR)
ret = device_get_supply_regulator(dev, "vbus-supply",
&priv->vbus_supply);
@@ -741,8 +754,8 @@ err_regulator:
#if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply)
regulator_set_enable(priv->vbus_supply, false);
-err_clk:
#endif
+err_clk:
#if CONFIG_IS_ENABLED(CLK)
clk_disable(&priv->clk);
#else