summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2019-01-151-5/+0
|\
| * usbgadget: dfu: remove useless break in the switch statementLadislav Michl2019-01-101-5/+0
| | | | | | | | | | Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/fastboot'Sascha Hauer2019-01-151-83/+153
|\ \ | |/ |/|
| * usb: gadget: fastboot: print fastboot messages also to the logsSascha Hauer2018-12-071-2/+5
| | | | | | | | | | | | | | It's nice to also see on the barebox side what is going on with fastboot, so print the messages to the logs also. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: simplify rebootSascha Hauer2018-12-071-7/+1
| | | | | | | | | | | | | | | | Now that we end the fastboot session when shutting down barebox we can call restart_machine() directly and not in the completion callback of the answer request. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: be more informative on bootingSascha Hauer2018-12-071-9/+7
| | | | | | | | | | | | | | | | | | We used to end the fastboot session once we received the boot command. Now that we end the session during shutdown we can do better: We can end the session once we actually shutdown, or more importantly in the case of an error. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: tell host that we are going to shutdownSascha Hauer2018-12-071-0/+43
| | | | | | | | | | | | | | | | | | Some commands like booting a kernel will trigger a shutdown of barebox, but the host will never notice and timeout later. Be more friendly and tell the host we are going to shutdown and end the current fastboot session. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: remove unnecessary context settingSascha Hauer2018-12-071-1/+0
| | | | | | | | | | | | | | | | | | Instead of setting the context for in_req we have set the context for out_req twice. This didn't trigger an error because we haven't used the context. So instead of fixing it we can equally well just remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: drop unnecessary global variableSascha Hauer2018-12-071-9/+5
| | | | | | | | | | | | | | Polling for the status of a request does not require a global variable. We can poll for the status directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usb: gadget: fastboot: pass message type as enumSascha Hauer2018-12-071-58/+95
| | | | | | | | | | | | | | | | We used to pass the message type ("INFO", "FAIL", "OKAY") as strings to fastboot_tx_print(). Change this to a enum type. This allows fastboot_tx_print() to react on the message type in the next step. 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-096-137/+52
|\
| * 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-291-10/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: 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-091-2/+2
|\ \
| * | drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-2/+2
| |/ | | | | | | | | | | | | | | 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>
* | 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/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: 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: 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>
* Merge branch 'for-next/usbgadget'Sascha Hauer2017-10-193-11/+54
|\
| * usbgadget autostart: add usbgadget.fastboot_bbu to automatically export bbu ↵Sascha Hauer2017-09-271-0/+7
| | | | | | | | | | | | handlers Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: fastboot: Allow to automatically export the bbu handlersSascha Hauer2017-09-272-0/+19
| | | | | | | | | | | | | | | | | | | | We have a list of registered handlers which take a barebox update. Do the next step and allow to automatically export them via fastboot so that barebox can be updated via fastboot without manually exporting the partition. Since this may not be desirable in all cases this behaviour is configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: fastboot: Use function to find file_list entry by nameSascha Hauer2017-09-271-7/+4
| | | | | | | | | | | | | | We have file_list_entry_by_name() now, so use it rather than open coding it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: unregister when usb_composite_probe() failsSascha Hauer2017-09-271-1/+9
| | | | | | | | | | | | | | When usb_multi_register() returns an error it can't be called again as we do not unregister the driver properly. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: only set to peripheral mode when error checking is doneSascha Hauer2017-09-271-2/+2
| | | | | | | | | | | | | | Only begin to modify the hardware when the obious errors have been checked. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: do not register when no functions presentSascha Hauer2017-09-271-0/+4
| | | | | | | | | | | | | | registering a multifunction device makes only sense when there's at least one function configured. Just return otherwise. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: autostart: Handle errors in file list gracefullySascha Hauer2017-09-271-1/+9
| | | | | | | | | | | | | | | | file_list_parse() can fail and returns an error pointer. Print an error message when it fails and also set to NULL again so that usb_multi_register() does not stumble upon the error pointer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | remove checks for xzalloc() returning NULLUwe Kleine-König2017-09-261-2/+0
|/ | | | | | | xzalloc() either returns memory or panics, so checking for NULL is useless. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>