diff options
author | Tom Rini <trini@konsulko.com> | 2022-02-11 07:22:30 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-02-11 07:22:30 -0500 |
commit | 86752b2814091bd8df30bdbf38768924b60cccab (patch) | |
tree | 537ae5f65a981e533b79eb38f8ec09a52b158682 | |
parent | fe203a05fb663fa9bc42a9ef9ae51a6ed01a4a90 (diff) | |
parent | 1f54025d70c4c9e6ec8d82d8b69b0d66a7bbbdc1 (diff) | |
download | u-boot-86752b2814091bd8df30bdbf38768924b60cccab.tar.gz |
Merge https://source.denx.de/u-boot/custodians/u-boot-usb
-rw-r--r-- | common/usb_kbd.c | 31 | ||||
-rw-r--r-- | drivers/usb/gadget/ci_udc.c | 5 | ||||
-rw-r--r-- | drivers/usb/host/ehci-mx6.c | 23 | ||||
-rw-r--r-- | include/usb.h | 3 |
4 files changed, 50 insertions, 12 deletions
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index afad260d3d..352d86fb2e 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -17,6 +17,9 @@ #include <stdio_dev.h> #include <watchdog.h> #include <asm/byteorder.h> +#ifdef CONFIG_SANDBOX +#include <asm/state.h> +#endif #include <usb.h> @@ -118,7 +121,7 @@ struct usb_kbd_pdata { extern int __maybe_unused net_busy_flag; /* The period of time between two calls of usb_kbd_testc(). */ -static unsigned long __maybe_unused kbd_testc_tms; +static unsigned long kbd_testc_tms; /* Puts character in the queue and sets up the in and out pointer. */ static void usb_kbd_put_queue(struct usb_kbd_pdata *data, u8 c) @@ -394,21 +397,39 @@ static int usb_kbd_testc(struct stdio_dev *sdev) struct usb_device *usb_kbd_dev; struct usb_kbd_pdata *data; + /* + * Polling the keyboard for an event can take dozens of milliseconds. + * Add a delay between polls to avoid blocking activity which polls + * rapidly, like the UEFI console timer. + */ + unsigned long poll_delay = CONFIG_SYS_HZ / 50; + #ifdef CONFIG_CMD_NET /* * If net_busy_flag is 1, NET transfer is running, * then we check key-pressed every second (first check may be * less than 1 second) to improve TFTP booting performance. */ - if (net_busy_flag && (get_timer(kbd_testc_tms) < CONFIG_SYS_HZ)) - return 0; - kbd_testc_tms = get_timer(0); + if (net_busy_flag) + poll_delay = CONFIG_SYS_HZ; +#endif + +#ifdef CONFIG_SANDBOX + /* + * Skip delaying polls if a test requests it. + */ + if (state_get_skip_delays()) + poll_delay = 0; #endif + dev = stdio_get_by_name(sdev->name); usb_kbd_dev = (struct usb_device *)dev->priv; data = usb_kbd_dev->privptr; - usb_kbd_poll_for_event(usb_kbd_dev); + if (get_timer(kbd_testc_tms) >= poll_delay) { + usb_kbd_poll_for_event(usb_kbd_dev); + kbd_testc_tms = get_timer(0); + } return !(data->usb_in_pointer == data->usb_out_pointer); } 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 diff --git a/include/usb.h b/include/usb.h index f032de8af9..7e3796bd5b 100644 --- a/include/usb.h +++ b/include/usb.h @@ -163,7 +163,8 @@ struct int_queue; */ enum usb_init_type { USB_INIT_HOST, - USB_INIT_DEVICE + USB_INIT_DEVICE, + USB_INIT_UNKNOWN, }; /********************************************************************** |