summaryrefslogtreecommitdiffstats
path: root/drivers/usb
Commit message (Collapse)AuthorAgeFilesLines
* usb: storage: Increase retries for usb_stor_transport()Robert Karszniewicz2019-11-041-3/+4
| | | | | | | | | | This should make writing and reading more reliable. Also: - change loop condition to make "retries" semantically correct - add a debug message in case of fatal failure Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2019-10-171-25/+159
|\
| * usb: Change power-on / scanning timeout handlingPrimoz Fiser2019-10-021-19/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change USB port scanning procedure and timeout handling in the following ways: 1) The power-on delay in usb_hub_power_on() is now reduced to a value of max(100ms, "hub->desc.bPwrOn2PwrGood * 2"). The code does not wait using mdelay, instead usb_hub_power_on() will wait before querying the device in the scanning loop later. The total connection timeout for this hub, which is (1 second + hub->desc.bPwrOn2PwrGood * 2) is calculated and will be used in the following per-port scanning loop as the timeout to detect active USB devices on this hub. 2) Don't delay the minimum delay (for power to stabilize) in usb_hub_power_on(). Instead skip querying these devices in the scanning loop usb_scan_port() until the delay time is reached. 3) The ports are now scanned in a quasi parallel way. The current code did wait for each (unconnected) port to reach its timeout and only then continue with the next port. This patch now changes this to scan all ports of all USB hubs quasi simultaneously. For this, all ports are added to a scanning list in usb_hub_configure_ports(). The list is later scanned in usb_device_list_scan() until all ports are ready by either a) reaching the connection timeout (calculated earlier), or by b) detecting a USB device. This results in a faster USB scan time as the recursive scanning of USB hubs connected to the hub that's currently being scanned will start earlier. 4) Ports with overcurrent detection will get scanned multiple times if OC condition is detected (PORT_OVERCURRENT_MAX_SCAN_COUNT). Without patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 10344ms With patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 4529ms Delta: ~6 seconds Signed-off-by: Primoz Fiser <primoz.fiser@norik.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: usb_hub_port_connect_change(): Remove unnecessary delaysPrimoz Fiser2019-10-021-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove two mdelay(200) calls from usb_hub_port_connect_change() before and after calling hub_port_reset(). These delays don't seem to be necessary since hub_port_reset() already incorporates delays on its own. Without patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 16355ms With patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 10344ms Delta: ~6 seconds Signed-off-by: Primoz Fiser <primoz.fiser@norik.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: hub_port_reset(): Speedup hub reset handlingPrimoz Fiser2019-10-021-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Start with a short USB hub reset delay of 20ms. This can be enough for some configurations. Switch to longer reset delay only if the short delay hasn't been long enough. This USB hub reset handling strategy is also used in the Linux kernel USB hub driver, function hub_port_reset(). Without patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 21750ms With patch: $ time usb usb: USB: scanning bus for devices... usb: 17 USB Device(s) found time: 16355ms Delta: ~5.5 seconds Signed-off-by: Primoz Fiser <primoz.fiser@norik.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2019-10-171-2/+2
|\ \
| * | USB: gadget: ACM: don't announce V.25ter supportAhmad Fatoum2019-10-141-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox currently announces support for ITU V.25ter AT commands, but doesn't handle them specially when they arrive. Instead they are passed as is to the sole barebox input console, where it may interfere with valid user input. This is especially annoying as ModemManager probes ttyACM devices that announce their AT command support. So even when not using the ttyACM device at all, the other UART ports are affected. Fix this by ceasing to announce USB_CDC_ACM_PROTO_AT_V25TER as function protocol. After applying this patch, I can't see any spurious AT or ~x~ symbols on the console anymore. Cc: <bst@pengutronix.de> Cc: <jlu@pengutronix.de> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/layerscape'Sascha Hauer2019-10-1710-23/+5149
|\ \
| * | usb: gadget: composite: conditionally dequeue setup requestsSascha Hauer2019-09-171-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is an adoption of Kernel commit a7c12eaf2 ("usb: gadget: composite: conditionally dequeue os_desc and setup requests"). Basically we only want to dequeue ep0 requests when they are actually queued. Drivers like dwc3 warn when unqueued requests are being tried to unqueued. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: dwc3: add support for gadget modeSteffen Trumtrar2019-09-178-20/+5094
| | | | | | | | | | | | | | | | | | | | | | | | Expand the DWC3 usb core with gadget support. Patches imported and adopted from Linux v5.2. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: gadget: add usb_gadget_udc_reset functionSteffen Trumtrar2019-09-171-0/+15
| |/ | | | | | | | | | | | | Add a function to notify the udc core, that a bus reset occured. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/bfin'Sascha Hauer2019-10-176-284/+2
|\ \
| * | USB: remove blackfin supportSascha Hauer2019-09-126-284/+2
| |/ | | | | | | | | | | | | The blackfin architecture has been removed from barebox. Remove the blackfin specifics in the USB drivers as well. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: at91_udc: don't depend on !ARCH_SAMA5D4Ahmad Fatoum2019-10-141-1/+0
| | | | | | | | | | | | | | | | | | | | The negative depends rules out using UDC for some targets of a multi-image barebox while still supporting SAMA5D4. We don't (yet) have such a configuration, but seeing as there is little to gain by restricting the selection, drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: delete no-longer needed #ifdef guardsAhmad Fatoum2019-10-141-6/+0
|/ | | | | | | | | c16bcbc644 ("ARM: at91: remove unused defines") removed conflicting definitions from the headers, so we can include the headers and code that uses them unconditionally now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fsl_udc: remove always-true null pointer checksAhmad Fatoum2019-08-301-8/+1
| | | | | | | | struct fsl_ep's name member can never be NULL because it is a character array. Remove these superfluous null pointer checks. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-07-122-8/+4
|\
| * f_fastboot: remove only image from bootm variablesRouven Czerwinski2019-07-041-1/+1
| | | | | | | | | | | | | | Remove only the bootm.image variable which will be set by fastboot. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: usb251xb: fix optional reset gpio requestMarco Felsch2019-06-171-5/+1
| | | | | | | | | | | | | | | | | | | | | | Linux requests the reset gpio optional by using devm_gpiod_get_optional(). We need to do this here too because the reset can be a global shared reset line e.g. board por. We haven't such a helper so just drop the final else path. Fixes: 937fa50d9c ("usb: Port Microchip USB251x USB hub driver from Linux") Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: remove stale mentions of CONFIG_OF in commentsAhmad Fatoum2019-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | barebox doesn't define a CONFIG_OF kconfig option, but CONFIG_OFTREE for the device tree handling and CONFIG_OFDEVICE for probing devices out of the device tree. Replace comment mentions of CONFIG_OF with mentions of either as appropriate. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: imx-usb-phy: select syscon driverSascha Hauer2019-07-111-0/+1
|/ | | | | | | | | Since b904eca92f we depend on syscon once the "fsl,anatop" property is found. select MFD_SYSCON to make sure it is available. Fixes: b904eca92f ("usb: imx-usb-phy: Disable charger detect during initialization") Cc: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-phy'Sascha Hauer2019-06-112-26/+62
|\
| * usb: imx-usb-phy: Disable charger detect during initializationAndrey Smirnov2019-05-271-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I can't find any erratas this is in refernce to, but apparently external changer detector needs to be disabled to prevent poor USB data signal quality. The problem manifest itself as a intermittent USB transfer corruption that happens to some device under and only under specific circumstances. In my case the failure was observed with Transcent SD/micro-SD card reader (05e3:0745 Genesys Logic, Inc. Logilink CR0012) when connected directly to front panel USB of ZII RDU2 board (the problem would go away if device was conntecte via a hub/USB-analyzer/male-female type A extender cable). Note that this fix is present in Linux kernel as well as some abandoned Barebox code removed in the next patch. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: imx-usb-phy: Use stmp_reset_block() to reset PHYAndrey Smirnov2019-05-272-10/+6
| | | | | | | | | | | | | | | | | | Upstream kernel driver uses stmp_reset_block() to reset the PHY, so convert the code to do so as well to save some code and sync both drivers. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: imx-usb-phy: Wrap lines to silence checkpatchAndrey Smirnov2019-05-211-2/+4
| | | | | | | | | | | | | | | | Those two line are the only thing that checkpatch is complaining about. Wrap them to slince it. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: imx-usb-phy: Import register definitions from Linux driverAndrey Smirnov2019-05-211-17/+18
| | | | | | | | | | | | | | | | Import register definitions from Linux driver to simplify comparing/sharing code a bit. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/usb-ehci'Sascha Hauer2019-06-112-187/+242
|\ \
| * | usb: host: ehci: Allocate only NUM_QH queue heads for qh_listAndrey Smirnov2019-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | Use NUM_QH, not NUM_TD to specify allocation size. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ush: host: ehci: Simplify QH initialization in ehci_submit_async()Andrey Smirnov2019-05-231-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use a fixed circular list for asynchronous schedule that never changes, so if we drop an explicit memset() that zeros out an entire struct and replace it with code initializine all of the fields explicitly, we can set QH list once in ehci_init() and never touch it again. While at it move qt_altnext initialization to ehci_init() as well since we never change that field either. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Treat ehci->qh_list as an arrayAndrey Smirnov2019-05-231-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since ehci->qh_list is an array, convert the code to use ehci->qh_list[0] to access its first element to make things a bit more clear. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Drop explicit memset() in ehci_init()Andrey Smirnov2019-05-231-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memory allocated by dma_alloc_coherent() is already zeroed out, ehci->qh_list[0] never changes during the operation of the driver and ehci->qh_list[1] will be explicitly initialized by ehci_submit_async() so this additional memset() shouldn't be necessary. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Replace explicit printf() with dev_err()Andrey Smirnov2019-05-231-3/+7
| | | | | | | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Add a comment explaing IOC setting for dataAndrey Smirnov2019-05-231-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Add a comment explaining the rationale behinde QT_TOKEN_IOC(req == NULL). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Use bool to simplify ehci_submit_async()Andrey Smirnov2019-05-231-3/+3
| | | | | | | | | | | | | | | | | | | | | Change the type of 'c' to bool and drop the trigrah. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Drop needless assignments in ehci_submit_async()Andrey Smirnov2019-05-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Neither of those is necessary, since both will be overwritten further down in the code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Simplify ehci_submit_async()'s epilogueAndrey Smirnov2019-05-231-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-organize the epilogue of ehci_submit_async() to bail out early if token is still marked as "active" and drop no longer necessary check for "dev->status != USB_ST_NOT_PROC". While at it return -EIO instead of -1 in the case of error. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Initialize qTDs explicitlyAndrey Smirnov2019-05-231-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Convert the code to initialize only used qTDs as well as initializing all of the fields explicitly without doing a wholesale memset() first. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Simplify ehci_td_buffer()Andrey Smirnov2019-05-231-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework the code of ehci_td_buffer() with following trivial changes: * Switch to using dma_addr_t for 'delta' and 'next' * Convert while to for loop * Replace explicit magic number with dedicated contants derived via ARRAY_SIZE * Use ALIGN_DOWN to calculate 'next' * Return -ENOMEM instead of -1 when we ran out of buffers Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Simplify qTD buffer synchronizationAndrey Smirnov2019-05-232-43/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only two buffers ever need to be sychronized and DMA direction of it is always known based on the type of request we are processing. Simplify the code by moving synchronization to be a part of ehci_prepare_qtd(). While at it convert the code to use dma_map_single() API. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Introduce ehci_prepare_qtd()Andrey Smirnov2019-05-231-31/+35
| | | | | | | | | | | | | | | | | | | | | | | | Move shared struct qTD initialization code into a subroutine and convert the rest of the code to use it. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Drop unnecessary cleanup codeAndrey Smirnov2019-05-231-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This looks like a leftover from U-Boot. Analogous code there would walk all qTDs and call ehci_free() on each one of them, but since we don't have anything of the sort it seems the whole loop can be dropped. Note that U-Boot dropped that code in de98e8b22a10676fd226318c92a9be7f519208ca Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Replace magic number with macrosAndrey Smirnov2019-05-232-49/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | Import a number of missing macros from U-Boot and convert ehci-hcd to use them instead of explicitly specifying magic shifts. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Use to USBSTS to wait for transfer completionAndrey Smirnov2019-05-232-14/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we already set up our last qTD to have IOC flag set we may as well take advange of that and poll USBSTS to wait for transfer completion. Doesn't change much, but allows us to drop a custom polling loop and re-use handshake() instead. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Share code to enable/disable async scheduleAndrey Smirnov2019-05-231-19/+20
| | | | | | | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: host: ehci: Do not zero out DMA coherent memoryAndrey Smirnov2019-05-231-2/+0
| |/ | | | | | | | | | | | | | | Memory returned by dma_alloc_coherent() should already be zeroed out, so there's no need to do this explicitly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2019-06-112-2/+3
|\ \
| * | usb: storage: Fix TEST_UNIT_READY command sizeAndrey Smirnov2019-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | TEST_UNIT_READY is 6 bytes long instead of 12. Fix it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: storage: Default to a single LUNAndrey Smirnov2019-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For loop below is: for (lun=0; lun<=us->max_lun; lun++) ... so we need to set max_lun to 0 in order to default to having only one LUN. Otherwise, we end up assuming the device has 2 valid LUNs. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: storage: Zero CDB out before sending itAndrey Smirnov2019-05-231-0/+1
| |/ | | | | | | | | | | | | | | | | | | Since cbw.Length can be less that sizeof(cbw.CDB), add code to zero the whole struct out to avoid sending random stack data as a part of payload. There's no known case where this causes a problem, but it's a reasonable thing to do anyway. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/dma'Sascha Hauer2019-06-113-7/+3
|\ \