summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
Commit message (Collapse)AuthorAgeFilesLines
* usb: hub: Do not include <scsi.h>Andrey Smirnov2019-03-111-1/+0
| | | | | | | No symbols found in <scsi.h> are used in this file. Drop it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2018-11-091-0/+5
|\
| * usb: Add usb_unregister_host()Sascha Hauer2018-10-261-0/+5
| | | | | | | | | | | | | | | | We have usb_register_host() which puts a new host on the list of hosts we should also have the opposite which removes the host from the list again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-2/+3
|/ | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: host: hub: Adjust device speed after every port resetAndrey Smirnov2018-08-293-20/+19
| | | | | | | | | | | | | | | | | | | | | To account for the possibility of a device coming out of second reset operating at different speed compared to first, move the code that stores device speed to be a part of hub_port_reset(). This way any speed change happening as a result of port reset could be accounted for. The above behaviour was observed on i.MX51 ZII RDU1, on USBH2 port connected to SMSC2660 USB Hub/SD card reader. For reasons unclear, first reset would put it into Full Speed mode whereas second would result in switch to High Speed. Artifically disabling second reset would result in the device operating at Full Speed. Not doing second speed adjustement on that board result would result in un-processed control transfer and failure to execute usb_set_address(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: host: hub: rename function argumentSascha Hauer2018-08-292-12/+12
| | | | | | | | Rename struct usb_device *dev function argument to usb_port_reset() to "hub" as the next patch will add another struct usb_device * argument to that function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: host: hub: Make sure to remove dangling pointersAndrey Smirnov2018-08-291-0/+1
| | | | | | | | | | | | | When the call to usb_new_device() in usb_hub_port_connect_change() fails and corresponding USB device is freed with usb_free_device(), we need to make sure that the pointer to it stored in dev->children[port] is removed as well, lest we risk usage-after-free. This issue was observed when working with a device for which usb_set_address() would fail and trying to do "usb" right afterwards. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: implement support for limiting host to full speedNikita Yushchenko2018-06-262-0/+36
| | | | | | | | | | | | | | | | | | This is needed when host is known to not work properly in high speed mode. In linux, chipidea driver supports 'maximum-speed' device tree property. When that is set to "full-speed", driver sets PFSC bit in PORTSC register, which disallows use of high speed mode. This patch implements same support for barebox. Important technical detail is that PFSC bit is cleared by port reset, thus setting it has to be done in ehci->init() callback which is called after ehci_reset(). Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make parameter functions more consistentSascha Hauer2017-04-111-8/+8
| | | | | | | | | | | | | | | | | | | | | | This patch creates a consitent set of device parameter functions. With this we have: dev_add_param_<type><access> "type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask The improvement here is that we now can exactly specify the width of the int type parameters and also correctly distinguish between signed and unsigned variables which means that a variable no longer ends up with INT_MAX when it's assigned -1. "access" can be empty for regular read/write parameter, "_ro" for readonly parameters which get their value from a variable pointer in the background or "_fixed" for parameters which are set to a fixed value (without a pointer in the background). Some more exotic types are not (yet) implemented, like dev_add_param_ip_ro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: Add usb phy to usb hostSascha Hauer2016-09-291-0/+8
| | | | | | | | Add a struct usb_phy * member to struct usb_host. Also, call usb_phy_notify_connect() / usb_phy_notify_disconnect() when there are connection changes on the root hub. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: Use standard debug macroSascha Hauer2016-09-281-27/+25
| | | | | | Use standard pr_debug instead of homebrew USB_PRINTF Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: core: return -EAGAIN on usb_* functions reentrancePeter Mamonov2015-10-141-1/+39
| | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: core: drop unnecessary le16_to_cpu() conversionAntony Pavlov2015-10-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | In drivers/usb/core/usb.c we already have le16_to_cpus() conversion just after usb_get_descriptor(): 390 /* correct le values */ 391 le16_to_cpus(&dev->descriptor->bcdUSB); 392 le16_to_cpus(&dev->descriptor->idVendor); 393 le16_to_cpus(&dev->descriptor->idProduct); 394 le16_to_cpus(&dev->descriptor->bcdDevice); so no additional idVendor/idProduct descriptor fields le16_to_cpu() conversion is needed after that. On the big-endian machines extra le16_to_cpu() conversion leads to wrong idVendor/idProduct USB device parameters values (e.g. see devinfo <usb-device> output), and to a much more serious problem: idVendor/idProduct-based USB device detection does not work. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: ehci: fix include/usb/usb.h:'struct usb_configuration' misuseAntony Pavlov2015-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | See the commit commit 245069bcef15ecc19db616a967501349b76c84d0 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Thu Jul 10 11:36:12 2014 +0200 USB: introduce usb_interface/usb_configuration structs On little endian systems like ARM the le16_to_cpus() macro is a no op, defined as: #define le16_to_cpus __le16_to_cpus #define __le16_to_cpus(x) do {} while (0) So struct usb_configuration field misuse was discovered on big-endian MIPS machine. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: increase USB_CNTL_TIMEOUT to match linuxSteffen Trumtrar2015-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | USB requests should be processed within a timeframe of 5s. The linux kernel also uses this timeout value for the control packets. For the musb the increase in timeout helps successfully probing USB devices (at least on one test hardware), but on the other hand doesn't slow down the system, if there are no devices, i.e. the timeout never hits. That means, that the USB core correctly aborts instead of timing out. Why and how the 100ms was chosen in the first place, can not be deduced from the git history, just that it seems to work fine for most boards. Change USB_CNTL_TIMEOUT to 5000ms and replace all occurences of `USB_CNTL_TIMEOUT * x` with just `USB_CNTL_TIMEOUT`, as the timeout is now large enough without it. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: abolish wait_ms() functionMasahiro Yamada2015-02-022-5/+5
| | | | | | | | This function is only used in drivers/usb/*. It is equivalent to mdelay(). Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: add usb phy header fileSascha Hauer2014-09-261-0/+1
| | | | | | | Mostly taken from the Linux Kernel to ease porting phy handling code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-host'Sascha Hauer2014-08-075-465/+566
|\ | | | | | | | | Conflicts: drivers/usb/core/Makefile
| * USB: improve error paths and tear-downSebastian Hesselbarth2014-07-283-27/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB core isn't too strict about allocation/deallocation and add/remove sequences of usb devices. Especially, error paths and device tear-down are kind of broken and cause hangs on failing usb device detect. This patch improves the situation by introducing a usb_free_device() that tears down allocated resources by usb_alloc_new_device(). usb_remove_device() now only deals with resources that have been added by usb_new_device(). Also, error handling is fixed or improved to ensure that no devices are unregistered that have not been previously registered. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: Count detected USB devices independent of dev_indexSebastian Hesselbarth2014-07-281-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Adding a usb device increases dev_index every time a new device is allocated. Removing a usb device does not decrease again, of course. As we print the number of detected usb devices after each usb bus scan based on dev_index, we cannot trust dev_index here. Keep track of the correct number of (currently) detected usb devices by introducing an independent dev_count that gets increased on detect and decreased on remove. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: Fix stale usb devices in usb_device_listSebastian Hesselbarth2014-07-281-0/+1
| | | | | | | | | | | | | | | | | | New usb devices are added to a list of usb devices, but when removing the corresponding usb_device it was not removed from that list. Fix it by deleting it properly from the usb_device_list. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: Use descriptors from ch11.hSebastian Hesselbarth2014-07-241-5/+5
| | | | | | | | | | | | | | | | | | Use the descriptors from ch11.h instead of duplicating them in usb.h. usb_hub_descriptor now contains a union .u to differentiate HS hub descriptor from SS hub descriptor. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: fix PowerPowerCtrlMask assignmentSebastian Hesselbarth2014-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | usb_hub_configure() gets the hub descriptor and copies its values over to a local descriptor. While copying PortPowerCtrlMask it erroneously overwrites DeviceRemovable due to a copy-and-paste error. Fix it up. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: drop force rescanSascha Hauer2014-07-181-27/+12
| | | | | | | | | | | | | | | | We can now detect changes in the USB device hierarchy properly, so the 'force' option to the usb command is no longer necessary. We just scan the busses each time the usb command is called. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: detect port change only once in usb_hub_configure_portSascha Hauer2014-07-181-2/+8
| | | | | | | | | | | | | | Otherwise a device may be registered/unregistered multiple times during scanning the hub ports. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: implement usb_remove_deviceSascha Hauer2014-07-183-0/+21
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: hub: only configure hub onceSascha Hauer2014-07-181-1/+8
| | | | | | | | | | | | | | | | | | | | We had a single function which configures the hub and scans the ports. Split this up and configure the hub only once and scan the ports during detect() time. This allows to plug in additional devices into a hub while continuing to use the already existing devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: factor out port configuration to separate functionSascha Hauer2014-07-181-51/+74
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: hub: Use usb_hub_power_on from U-BootSascha Hauer2014-07-181-1/+18
| | | | | | | | | | | | | | | | U-Boots power good delay function is more conservative than ours. Use it to be on the safe side. The U-Boot guys have discussed a lot about it, let's hope they got it right. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: hub: Use dev_dbgSascha Hauer2014-07-181-48/+40
| | | | | | | | | | | | | | Now that a hub is a driver use dev_dbg rather than plain printf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: fixup USB device hierarchySascha Hauer2014-07-182-2/+2
| | | | | | | | | | | | | | Make all USB devices children to the hub device they are attached to. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: hub: Turn into a driverSascha Hauer2014-07-185-415/+460
| | | | | | | | | | | | | | | | Since we have a driver model we can make the hub driver a real driver model driver. Put it into a new file to separate the hub from the USB core stuff. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * USB: host: simplify usb_new_deviceSascha Hauer2014-07-181-18/+5
| | | | | | | | | | | | | | | | | | usb_new_device tries to find the port number it is attached to by iterating over the parents children and using the loop counter index as port number. Instead, just use the portnr field in struct usb_device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: usb: add tree view capabilityAntony Pavlov2014-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds U-Boot 'usb tree' command functionality to barebox. Here is an example output: 1 ID 0000:0000 | u-boot EHCI Host Controller | +-2 ID 05e3:0606 | USB2.0 Hub | +-3 ID 10c4:ea60 | Silicon Labs CP2102 USB to UART Bridge Contr P-00-00669 | +-4 ID 05e3:0606 | | USB2.0 Hub | | | +-5 ID 05e3:0608 | | | USB2.0 Hub | | | | | +-6 ID 0d8c:000c | | C-Media USB Headphone Set | | | +-7 ID 0d8c:000c | C-Media USB Headphone Set | +-8 ID 0846:1040 NETGEAR NETGEAR FA120 Adapter The tree view is enabled with 'usb -t' Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | USB: gadget: Update to 3.15Sascha Hauer2014-07-223-0/+21
|/ | | | | | | | | This updates the USB Gadget stack to Linux-3.15. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Conflicts: drivers/usb/core/Makefile
* USB: introduce usb_interface/usb_configuration structsSascha Hauer2014-07-181-26/+26
| | | | | | | | | | | Currently we have two conflicting definitions of struct usb_config_descriptor and struct usb_interface_descriptor in the tree. This is because the USB code uses additional fields in the structs for internal housekeeping. Add struct usb_interface and struct struct usb_configuration with the housekeeping data and embed the corresponding hardware structs into them. This frees the way to use the definitions from ch9.h in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: Kconfig: introduce USB_HOST symbolSascha Hauer2014-07-181-1/+1
| | | | | | | | | This renames USB to USB_HOST since this is what the symbol really means. Introduce a USB symbol which is selected by both USB_GADGET and USB_HOST. This gives us a symbol to let common USB code depend on. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix signedness mixups in printf format specifiersLucas Stach2014-04-231-2/+2
| | | | | | | | | This most likely doesn't fix any real bugs, but it's the right thing to do and reduces the noise level with static checkers. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove redundant NULL check on freeLucas Stach2014-02-101-2/+1
| | | | | | | | free() already checks the pointer to be non NULL. No need to do it again. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* USB: i.MX: Make DT dr_mode & phy_type parameters kernel compatibleAlexander Shiyan2013-10-301-2/+2
| | | | | | | | | Since the mainline kernel now has its own dr_mode and phy_type DT-options for setting modes of USB ports, do these kernel parameters compatible by removing "barebox" prefix. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: Turn some printf into pr_*Sascha Hauer2013-09-271-3/+3
| | | | | | So that these messages can be suppressed if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: make usb devices children of the corresponding hostSascha Hauer2013-09-241-0/+2
| | | | | | To be able to find usb devices in the hardware tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: implement a usb_host_detect to scan individual USB hostsSascha Hauer2013-06-211-13/+25
| | | | | | | | Currently we can only (re)scan all USB hosts. Add a function to scan individual hosts. This is useful for implementing the detect callback in the next patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: move scanned status into coreSascha Hauer2013-06-211-1/+8
| | | | | | | A command should not be interested in the internal USB core state, so move the state handling into the core. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: rename USB devices to reflect bus structureSascha Hauer2013-06-211-3/+11
| | | | | | | | | This renames the USB devices to reflect the bus structure. The base name for a USB device is usb<devno>. For each child device we add a -<parent-port-no>. This makes it more easy to identify devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: Add devicetree helpersSascha Hauer2013-05-302-0/+92
| | | | | | Add helpers to get the dr_mode and the phy_mode. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Use dev_add_param_int_ro where possibleSascha Hauer2013-04-111-9/+10
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: add parameters info on usb deviceJean-Christophe PLAGNIOL-VILLARD2013-01-231-0/+14
| | | | | | | | | | | | | | iManufacturer = 0 iProduct = 1 iSerialNumber = 0 Manufacturer = Product = OHCI Root Hub SerialNumber = idVendor = 0000 idProduct = 0000 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-4/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>