summaryrefslogtreecommitdiffstats
path: root/drivers/usb
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-12-072-4/+2
|\
| * usb: musb: Add missing includesSascha Hauer2018-11-192-4/+2
| | | | | | | | | | | | | | | | | | phy-am335x.c and phy-am335x-control.c both implement functions that they do not include the header file providing the prototype for. Add the missing include and remove the duplicate definition of struct phy_control. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: musb: fix possible out of bounds accessOleksij Rempel2018-11-211-1/+6
| | | | | | | | | | | | | | | | Either the condition 'epnum>=((u8)16)' is redundant or the array 'musb->endpoints[16]' is accessed at index 16, which is out of bounds. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: at91_udc: remove useless NULL checkOleksij Rempel2018-11-211-2/+1
|/ | | | | | | | if _ep or ep is NULL, we would get at least in two places before this test a NULL pointer dereference. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2018-11-0910-175/+162
|\
| * usbgadget: autostart: add DFU supportLadislav Michl2018-10-293-104/+3
| | | | | | | | | | | | | | | | | | | | | | Use global variable dfu_function to autostart DFU. As similar code is used to start multifunction gadget using command, move common code to common/usbgadget.c and consolidate it. It turned out that '-s' option of usbgadget command does nothing, so remove its help text and make it function as '-a'. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: set maxpacket_limitLadislav Michl2018-10-293-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gadget update to 3.15 imported Linux patch e117e742d310 ("usb: gadget: add "maxpacket_limit" field to struct usb_ep"): This patch adds "maxpacket_limit" to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field "maxpacket" is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, "maxpacket" value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint. For this reason this patch adds new field "maxpacket_limit" which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig(). Value of "maxpacket_limit" should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both "maxpacket_limit" and "maxpacket" fields. However said update didn't bring in all driver changes. Do it now. Fixes: 2776d53d7ac8 ("USB: gadget: Update to 3.15") Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fsl_udc: pass controller instance to unregisterSascha Hauer2018-10-292-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | ci_udc_unregister() used to unregister "the controller". Since we may register multiple chipidea devices we called ci_udc_unregister() for each of them. This led to messages like: ERROR: imx-usb 53f80000.usb: gadget not registered. Fix this by returning the registered controller. This allows us to call ci_udc_unregister() only when we actually registered one before. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: imx: unregister ehci controller on device removalSascha Hauer2018-10-291-0/+5
| | | | | | | | | | | | | | | | ehci does DMA and hence must be properly quiesced before we leave barebox. Call ehci_unregister() on device removal when we previously registered a ehci controller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: host: ehci-atmel: unregister host on device removeSascha Hauer2018-10-291-1/+5
| | | | | | | | | | | | | | The ehci code does DMA and really must be properly stopped when we leave barebox, so call ehci_unregister on device removal. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: host: ehci: do not use dev->privSascha Hauer2018-10-293-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | An ehci can be registered with ehci_register which is passed a struct device_d *. In that case the priv pointer may already be used by the caller, so we must not use it in the ehci code. At least for the Atmel ehci driver this fixes a bug, here dev->priv is set two times to different values. Since we need dev->priv in the ehci code to get the controller in ehci_detect() we can no longer implement that without the help of the caller, hence we eport ehci_detect() and epect it to be called by the code which registers a ehci host. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: host: ehci: add ehci_unregister()Sascha Hauer2018-10-293-8/+36
| | | | | | | | | | | | | | | | | | ehci_register() allocates data and registers a ehci host. Add ehci_unregister() to properly halt the controller and to free the memory again.. To do so, change ehci_register() to return the ehci host rather than an error code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * 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>
| * usb: host: ehci: rename ehci_priv to ehci_hostSascha Hauer2018-10-261-21/+21
| | | | | | | | | | | | | | As we are going to export the structure as a cookie to others rename it to ehci_host. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fsl_udc: Drop using global variableSascha Hauer2018-10-261-17/+22
| | | | | | | | | | | | | | No need to use the global udc_controller variable when we are provided an usb_gadget. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-093-5/+6
|\ \
| * | drivers: Introduce dev_set_name()Andrey Smirnov2018-10-183-5/+6
| |/ | | | | | | | | | | | | | | 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>
* | Merge branch 'for-next/mtd'Sascha Hauer2018-11-091-1/+4
|\ \
| * | USB: gadget: prevent unnecessary warning messageSascha Hauer2018-10-261-1/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | The USB gadget autostart code issues a warning when no otg device exists: Cannot set parameter otg.mode: No such device This is unnecessary since there may be no otg device at all, but only a gadget device. Drop that warning by checking if there is a otg device first. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-11-091-2/+2
|\ \
| * | usb: ulpi: Make locally used functions staticSascha Hauer2018-10-231-2/+2
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: remove mach/io.hSascha Hauer2018-11-061-1/+1
| | | | | | | | | | | | | | Remove at91_sys_read() and at91_sys_write() since these are no longer used. This makes mach/io.h empty so remove that aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: Add SoC namespace to matrix definesSascha Hauer2018-11-051-6/+13
| | | | | | | | | | | | | | Add SoC namespace to matrix define so we have one source less of conflicting defines. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usb: gadget: fastboot: remove unused variableSascha Hauer2018-10-301-1/+0
|/ | | | | | ep is unused, remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2018-10-091-1/+1
|\
| * Add linux/slab.hSascha Hauer2018-10-081-1/+1
| | | | | | | | | | | | | | | | | | Move stuff we already have in include/linux/barebox-wrapper.h that really belongs to include/linux/slab.h to there. Also add kmem_cache_* functions. UBIFS uses them in there own implementation, so we have to remove it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-10-091-6/+17
|\ \
| * | usb: gadget: fastboot: fix downloading files of wMaxPacketSize bytesSascha Hauer2018-10-021-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | File transfers with sizes of exact multiples of wMaxPacketSize up to EP_BUFFER_SIZE do not work. For a typical scenario that would be files of 512, 1024 ... 3584 bytes. This happens because we unconditionally put EP_BUFFER_SIZE into the initial request length. For non wMaxPacketSize aligned lengths this works well because the transfer is completed with a short packet. For wMaxPacketSize aligned lengths there is no short packet though, so the transfer never completes. Instead we have to put the file size into the initial request length. Some controllers like the DWC3 do not work when the request length is not aligned to wMaxPacketSize, so we align up to wMaxPacketSize like done in U-Boot. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Gavin Schenk <g.schenk@eckelmann.de> Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
| * | usb: gadget: fastboot: detect device if not presentSascha Hauer2018-09-181-0/+5
| |/ | | | | | | | | | | | | | | When a device file is not present when the fastboot gadget is created then try to detect it before we fail. It may be that we want to write to a device that we haven't used before. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bbu: Add "handler" parameter to barebox_update()Andrey Smirnov2018-10-081-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Add "handler" parameter to barebox_update() and remove the code that was respondible for header lookup before. With this change finding appropriate handler is caller's responsibility, which makes it possible to implement custom handler lookup/existence check, chache it, and then re-use it without calling handler_find_by_* functions for the second time. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bbu: Expose bbu_find_handler_by_*() functionsAndrey Smirnov2018-10-081-1/+1
|/ | | | | | | | | | | | Expose bbu_find_handler_by_device() and bbu_find_handler_by_name() as public functions and convert the only user of barebox_update_handler_exists() to use the former function instead. With this done, barebox_update_handler_exists() is no longer used anywhere in the code and can be removed. 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: gadget: allow to actually enable sparse fastboot supportUwe Kleine-König2018-08-081-3/+3
| | | | | | | | | | | | | | | When sparse support was (intended to be) made optional it was effectively unconditionally disabled because IS_ENABLED(USB_GADGET_FASTBOOT_SPARSE) always evaluates to 0. To actually make use of the introduced kconfig symbol the CONFIG_ prefix must not be skipped. Fixes: f4b5d3eeb607 ("usb: gadget: fastboot: Make sparse support optional") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Gavin Schenk <g.schenk@eckelmann.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: implement support for limiting host to full speedNikita Yushchenko2018-06-263-0/+49
| | | | | | | | | | | | | | | | | | 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>
* usb: gadget: fastboot: fix barebox update without using bufferMichael Grzeschik2018-05-171-1/+1
| | | | | | | | | | | | Commit e5098495 "usb: gadget: fastboot: Add option to download to a buffer" breaks the use of temporary files for fastboot barebox_update. In the patch the ".imagefile = FASTBOOT_TMPFILE" allocation gets removed, but data.imagefile is still used. This leads to an NULL pointer dereference. We fix it by using sourcefile instead. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: Add external command execution supportSascha Hauer2018-02-092-1/+22
| | | | | | | | | | | | | | | | Custom projects may need vendor specific expansions to the fastboot command execution. Allow these to be implemented without messing in the fastboot code directly. We have a hook for all commands and also one for the "flash" command. Each hook can decide if the generic command parser is executed afterwards (return value FASTBOOT_CMD_FALLTHROUGH) or if the generic parser shall be skipped (return value 0 or negative error code). This allows board code to implement vendor specific "oem" commands or to handle the downloaded image in a special way (i.e. do signature checks on them) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: Add option to download to a bufferSascha Hauer2018-02-092-26/+88
| | | | | | | | | This adds an option to download the image data to a temporary buffer rather than to a file. While a file is generally the better option, in some special cases a buffer is better for memory usage. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: beautify fb_run_command()Sascha Hauer2018-02-091-7/+8
| | | | | | Only some refactoring, no functional change intended. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: fix typoSascha Hauer2018-02-091-1/+1
| | | | | | s/correspoinding/corresponding/ Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: Always remove temporary fileSascha Hauer2018-02-091-20/+14
| | | | | | | | We should consistently remove the temporary image file, regardless of the error code. To do so, always jump to the end of the function where the temporary file is removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: use read_file_2Sascha Hauer2018-02-091-2/+3
| | | | | | | read_file_2 gives us a proper error code and allows us to specify a maximum size which in this case we happen to know. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: pass struct f_fastboot * aroundSascha Hauer2018-02-091-30/+19
| | | | | | | | | The different fastboot commands mostly do not need the USB endpoint or the USB request, they need the context data structure struct f_fastboot * instead, so rather pass this one around between the different functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: Make sparse support optionalSascha Hauer2018-02-092-4/+20
| | | | | | Sparse support is not always desired, make it optional. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: allow data.image to be constSascha Hauer2018-01-301-3/+6
| | | | | | | | Do not directly store the dynamically allocated memory in data.image as we want to make that pointer const and then no longer can call free() on it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: gadget: fastboot: Add sparse image supportSascha Hauer2018-01-182-23/+231
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sparse images are needed for fastboot to flash images that do not fit into memory. Android fastboot is kind of a dumb protocol. It first sends you a big image and afterwards it tells you where to put this image. This of course limits fastboot to files smaller than the available memory. To bypass this issue fastboot has so called Sparse image support. This is a new image format that can contain holes in the data so a big image can be written in multiple steps with holes in other areas each step. Implementing this for UBI images is kind of tricky since ubiformat normally expects to get a single image. Preparations to ubiformat a device in multiple parts have been done in previous patches. It is however, only for the first part possible to detect if it is a UBI image. The other parts are just binary data and we cannot know if we have to pass this data raw to the flash or use ubiformat. For this reason this patch makes the 'u' flag in the partition description mandatory for proper UBI image flashing on MTD devices. fastboot passes a max_download_size variable to the host. This variable contains the image size fastboot can take in one go. We have to choose a good compromise here. On one hand we do not want to risk that we actually do not have enough memory to hold the transferred image, on the other hand we want images like bootloaders not as sparse images, but in one go instead to make atomic exchange of the bootloader possible. Right now we have chosen 8MiB which should be big enough for all bootloaders. The value is configurable via global.usbgadget.fastboot_max_download_size. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usbgadget: fastboot: select FILE_LISTLucas Stach2017-11-211-0/+1
| | | | | | | | | The file list functions are used by the fastboot gadget since a3976c3a84f2 (usbgadget: fastboot: Use function to find file_list entry by name). Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* usb: imx: implement support for "over-current-active-high" propertyUwe Kleine-König2017-10-271-0/+4
| | | | | | | | | | | | | | | This property is already documented in the bindings and supported by Linux. As on i.MX25 the HW default is active high and up to now barebox didn't force this to low (which is the default for e.g. i.MX6), add the property to barebox' imx25.dtsi to keep existing behaviour. If on a board the OC pin is active low, you need to add /delete-property/ over-current-active-high; in the board.dts. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usbgadget'Sascha Hauer2017-10-193-11/+54
|\