summaryrefslogtreecommitdiffstats
path: root/drivers/usb
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/usb'Sascha Hauer2021-03-236-109/+181
|\
| * usb: dwc2: Rework wait for host mode during core resetJules Maselbas2021-03-151-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | Replace the unconditional delay of 100ms during core_reset by a call to dwc2_wait_for_mode() when iddig filter is enabled, as done in Linux. The uses of mdelay comes from the porting of u-boot's driver. Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: dwc2: Move wait_for_mode and iddig_filter_enabled to coreJules Maselbas2021-03-153-53/+56
| | | | | | | | | | | | | | | | | | Move functions dwc2_wait_for_mode() and dwc2_iddig_filter_enabled() into core.c so they can be used during dwc2_core_init(). Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: dwc2: Rework dwc2_wait_for_mode to use wait_on_timeoutJules Maselbas2021-03-151-4/+3
| | | | | | | | | | | | Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: dwc2: Replace pr_info with dev_warnJules Maselbas2021-03-151-3/+4
| | | | | | | | | | | | | | | | There is no reason to not use dev_warn (as done in Linux), this might have been unwanted changes made when porting the driver to barebox. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: dwc2: Make dwc2_wait_bit_set wait all bits in maskJules Maselbas2021-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The dwc2_wait_bit_set() wasn't waiting for all bits in the mask to be set but was waiting for only one bit set a mask. This is not the expected behavior as stated in the function's comment. The function dwc2_wait_bit_set() is always called with a mask of only one bit. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: dfu: Simplify state handleJules Maselbas2021-03-011-4/+3
| | | | | | | | | | | | | | | | Simplify the state handle, the idle state will only be entered from do_close. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: dfu: call do_close also when not in safe modeJules Maselbas2021-03-011-1/+5
| | | | | | | | | | | | | | When not in mode "safe", do_close was never called. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: storage: add support for drivers larger than 2TiBAhmad Fatoum2021-03-011-14/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Consumer USB disks usually have emulated 512 byte sectors at the USB/SCSI level, which means SCSI Read/Write/Capacity 10 can only handle up to 2TiB USB disks. Add support for the optional 16 byte command variants to handle disks larger than that. Disks smaller than 2 TiB should not be affected. Tested with 2 different 4TiB disks as well as one 2TiB disk. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: storage: refactor usb 32-bit capacity readAhmad Fatoum2021-03-011-29/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usb_stor_read_capacity uses SCSI Read Capacity 10, which assumes capacity never exceeds 32-bit, which equals 2TiB max capacity at 512 byte sector size. In preparation for porting support for SCSI Read Capacity 16 from Linux, move over all Read Capacity 10 related code into a single function. Some more refactoring is done to make the function look more like the Linux implementation. This also makes it easier to spot the differences in retry/timeout handling, which we might want to adopt in future. No functional change intended. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: dwc2: fix mismatching argument to printf format specifierAhmad Fatoum2021-03-012-2/+2
|/ | | | | | | | | | | %pad prints a DMA address out of a pointer to dma_addr_t. Casting the dma_addr_t itself to void *, will lead to printf dereferencing it and printing the first sizeof(dma_addr_t). The dwc2 driver is the only one using %pad. Fix it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2021-02-228-60/+25
|\
| * usb: imx: add overcurrent polarity handling on i.MX6Michael Grzeschik2021-02-041-1/+8
| | | | | | | | | | Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: imx: fix overcurrent polarity handling on i.MX7Michael Grzeschik2021-02-041-3/+3
| | | | | | | | | | | | | | | | The reference manual says the overcurrent polarity is changed to low with the bit set. We fix that according to the description. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: host: ehci: remove duplicated usb_host_detect() callsAhmad Fatoum2021-02-016-56/+0
| | | | | | | | | | | | | | | | With the last patch adding a fallback detect, we no longer need the duplication in the host controller drivers. Drop them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: add fallback ->detect method for USB host driversAhmad Fatoum2021-02-011-0/+14
| | | | | | | | | | | | | | | | | | | | We already maintain a list of USB host controllers, so we can use that to implement a generic detect callback. Currently, all drivers define their own, which uses driver-specific means to arrive at the struct usb_host and then call usb_host_detect(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-02-221-20/+43
|\ \
| * | usb: otg: Add support to register more than one otg devJules Maselbas2021-02-181-20/+43
| |/ | | | | | | | | | | | | | | | | This allow each otg controller to register one otg device for host/peripheral mode switch. The first otg device registered "otg0" will also be aliased by "otg" for compatibility. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ext4'Sascha Hauer2021-02-221-12/+13
|\ \
| * | usb: storage: support USB disks up to 2TiB of sizeAhmad Fatoum2021-02-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SCSI Read Capacity (10) only supports up to 0xFFFF_FFFF sectors at most, which at 512 bytes per sector equals a disk size of 2 TiB. Due to barebox block layer limits, however, the barebox mass storage driver doesn't address sectors that need more than 31 bits to describe. These block layer limits were removed in a previous commit, so make the USB driver use the full 32 bit to support 512-byte sector USB disks up to 2 TiB of size. Disks that are larger than that must either implement SCSI Read Capacity (16) to support up to 16 Exabytes or increase the sector size beyond 512 bytes. This commit doesn't do that as I don't have the suitable hardware to test. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | block: use 64-bit types for sector offset and count on all platformsAhmad Fatoum2021-02-181-9/+9
| |/ | | | | | | | | | | | | | | | | | | | | barebox' use of int for the sector offset puts an upper bound of 1TB on the size of supported block devices, which is already exceeded by common place USB mass storage. Increasing the sizes involved to 64 bit like Linux does won't magically add missing driver support, but it gives us at least a fighting chance. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: dfu: Wrap fs operation in workqueueJules Maselbas2021-02-161-129/+246
| | | | | | | | | | | | | | File system operation shouldn't be executed in a poller. Use a workqueue to delay filesystem operation to command context. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: dfu: Rework print messagesJules Maselbas2021-02-161-5/+6
| | | | | | | | | | | | | | Replace printf with pr_err and debug with pr_debug. Defines "dfu :" as a prefix for formatted prints. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: dfu: Use func_to_dfuJules Maselbas2021-02-101-2/+2
|/ | | | | | | Replace the uses of container_of with func_to_dfu when available. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: swap order of phy_init and phy_power_on to what Linux doesAhmad Fatoum2021-01-061-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux doesn't seem to enforce a fixed order between phy_init and phy_power_on. The Linux dwc2 driver does power_on and then phy_init, which is the inverse of what barebox is currently doing. The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable: ERROR: stm32-usbphyc 5a006000.usbphyc@5a006000.of: PLL not reset ERROR: phy1: phy exit failed --> -5 Because Linux does exit -> power_off, but barebox does power_off -> exit. Issue was raised upstream: https://lore.kernel.org/lkml/6cd01e79-fdc0-3bd4-32b5-a85142533f8a@pengutronix.de/T/#t Until this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway. Cc: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: add support to force gadget modeMichael Grzeschik2021-01-061-0/+144
| | | | | | | | | | | In case the driver is to be run in peripheral mode rather than otg, it needs to be forced in hardware to the selected mode. This patch adds support to set and clear that hardware override. The functions are mostly copied from linux. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: update the dr_mode on set_mode callbackMichael Grzeschik2021-01-061-0/+6
| | | | | | | | | | The dwc2 dr_mode can be configured with otg.mode in otg mode. Currently the mode will not be set with the users decision. This patch fixes this by overwriting the mode with the one set by set_mode callback. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: add reset controller dependency for probe via oftreeMichael Grzeschik2021-01-061-0/+5
| | | | | | | | | | The dwc2 controller is connected to one reset controller which needs to be triggered before it is able to operate. This patch adds the referenced reset controller in the devicetree to be used. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: add clk dependency for probe via oftreeMichael Grzeschik2021-01-062-2/+18
| | | | | | | | | | The dwc2 controller at least needs one core clock which needs to be enabled before it is able to address the core registers. This patch adds the referenced clock in the devicetree to be used. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: cleanup on error for deferred probingMichael Grzeschik2021-01-061-3/+4
| | | | | | | | | The driver needs to cleanup the resources if an error occurred. Otherwise, on deferred probing, it will fail to take the resources for a second time. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_versionJules Maselbas2020-12-163-5/+3
| | | | | | | | The name dwc2_check_core_version is the one used on Linux, make it this way. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: Fix dr_mode check in dwc2_get_dr_modeJules Maselbas2020-12-162-8/+8
| | | | | | | | | | In Linux, configs CONFIG_USB_DWC2_HOST and CONFIG_USB_DWC2_GADGET are respectively for host only and gadget only support, they are mutually exclusive. However this is not the case in barebox, they are independent options. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: Remove unnecessary functions declarationJules Maselbas2020-12-162-8/+4
| | | | | | | Theses functions are only used in dwc2/core.c make them static. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: dwc2: Add support for optional usb phyJules Maselbas2020-12-163-0/+28
| | | | | Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-12-112-14/+36
|\
| * usb: host: ehci: fix mismatch in format stringAhmad Fatoum2020-12-071-1/+1
| | | | | | | | | | | | | | | | sz is of type size_t. Use the appropriate format string specifier for printing it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: fastboot: Fix error pathSascha Hauer2020-11-171-13/+35
| | | | | | | | | | | | | | fastboot_bind() can fail in multiple ways. Roll back things already done in the error path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2020-12-112-0/+8
|\ \
| * | usb: imx: get power pin polarity from DTLucas Stach2020-11-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | There is a documented DT property to set the power pin polarity, parse it. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usb: imx: add support for setting power pin polarity on i.MX6/7Lucas Stach2020-11-241-0/+5
| |/ | | | | | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / usb: gadget: fastboot: fix no longer accurate help textAhmad Fatoum2020-11-231-1/+1
|/ | | | | | | | Since 38d7ba55da26 ("fastboot: rename usbgadget.fastboot_* variables to fastboot.*"), the variables are named differently. Amend the help text. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: Fix initial max packet sizeSascha Hauer2020-10-271-3/+5
| | | | | | | | | In case the USB device is a full speed device we have to set dev->epmaxpacketin[0] and dev->epmaxpacketout[0] before doing a get_descriptor_len() because otherwise it's unset during that call. Fixes: 6d1d95a386 ("usb: factor out a usb_setup_descriptor() function") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/percent_pe' into masterSascha Hauer2020-10-142-4/+3
|\
| * treewide: replace strerror(-PTR_ERR(errno)) with %pe format specifierAhmad Fatoum2020-09-291-3/+2
| | | | | | | | | | | | | | | | | | Using %pe instead of PTR_ERR has the benefit of being less verbose and less error-prone (no negation necessary) while potentially reducing code size. Make use of it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * vsprintf: retire strerrorp in favor of %peAhmad Fatoum2020-09-291-1/+1
| | | | | | | | | | | | | | | | | | strerrorp() is only used along with printf. We now have a format specifier for printing error pointers directly, so use that and remove strerrorp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc' into masterSascha Hauer2020-10-145-16/+27
|\ \
| * | usb: dwc2: Uninitialize host and device on removeJules Maselbas2020-10-094-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | Device gadget must be properly uninitialized on poweroff however host system might not detect barebox's usb gadget has beeing disconnected. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | USB: musb: host: fix mismatched format specifier in dev_dbg()Ahmad Fatoum2020-09-281-2/+2
| |/ | | | | | | | | | | | | | | Unadorned 0 is an int, but is printed used %zu. As it's just an interger literal, just hardcode it into the string. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/driver-macro' into masterSascha Hauer2020-10-143-17/+3
|\ \
| * | treewide: Use driver macroSascha Hauer2020-09-293-17/+3
| |/ | | | | | | | | | | | | We have several macros for a oneline driver registration. Add some missing and use them consistently where possible througout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>