summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/dwc2.c
Commit message (Collapse)AuthorAgeFilesLines
* common: Move ARM cache operations out of common.hSimon Glass2019-12-021-0/+1
| | | | | | | | | These functions are CPU-related and do not use driver model. Move them to cpu_func.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* dwc2: use the nonblock argument in submit_int_msgMichal Suchanek2019-09-111-1/+1
| | | | | | | | | | | An USB 1.1 keyboard connected to dwc2 through a high-speed hub does not report status until it changes. With this patch you can enable keyboard by pressing a key while USB devices are probed. Without a keypress no state is reported and the probe times out. We don't want to wait for a keypress or timeout while polling for keypresses so implement an int_msg nonblock variant that exits early on error. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* usb: Add nonblock argument to submit_int_msgMichal Suchanek2019-09-111-5/+8
| | | | | | | This will be used to implement non-blocking keyboard polling in case of errors. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/Sven Schwermer2018-11-261-6/+6
| | | | | | | | This allows to disable the USB driver model in SPL because it checks the CONFIG_SPL_DM_USB variable for SPL builds. Nothing changes for regular non-SPL builds. Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
* usb: dwc2: Add reset ctrl to driverLey Foon Tan2018-08-291-0/+37
| | | | | | | | | | | Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present. If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset. Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
* usb: dwc2: Add brcm,bcm2708-usb compatibleEmmanuel Vadot2018-07-051-0/+1
| | | | | | | | | When using CONFIG_OF_BOARD on rpi to use the dtb provided by the RaspberryPi Fundation, the compatible string isn't the same, resulting in not-functional usb from u-boot. Signed-off-by: Oleksandr Tymoshenko <gonzo@FreeBSD.org> Signed-off-by: Emmanuel Vadot <manu@freebsd.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini2018-04-271-2/+0
| | | | | | | | We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
* usb: dwc2: Replace printf, pr_err by dev_info, dev_errPatrice Chotard2018-03-171-9/+11
| | | | | | Replace printf() call by dev_info() and pr_err() by dev_err() Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
* usb: dwc2: increase timeout in wait_for_chhltdChristophe Kerello2018-03-171-1/+1
| | | | | | | | | | This patch increases timeout to 2s. It was seen on 2 USB devices (Verbatim STORE N GO 070B4AED0FB22358 and USB DISK 2.0 9000729BA41DDF40) that the request sense command takes between 1.3s and and 1.5s. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
* usb: dwc2: disable external vbus supply when the device is removedChristophe Kerello2018-03-171-3/+35
| | | | | | | | This patch adds an interface to disable the power in dwc2 driver. This new interface is called when the device is removed. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
* usb: dwc2: Allow selection of data buffer sizeAlexey Brodkin2018-03-171-1/+1
| | | | | | | | | | | | | | | | | | If we use hardware with very small RAM (let's consider just a couple of hundreds of kB but not megabytes) it is not super convenient to lose 64kB for statically allocated bufer which most probably won't be used as big as it is. Typically we'll have much shorter data packages to excahnge and in the worst case longer packets will be split on separate transactions. For those corner-cases user will be able to set his buffer size of choice via USB_DWC2_BUFFER_SIZE option in menuconfig. By default we'll use 64 kB as it was hard-coeded before so existing users shouldn't be affected at all. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Marek Vasut <marex@denx.de>
* usb: dwc2: Rename CONFIG_DWC2_UTMI_PHY_WIDTH to CONFIG_DWC2_UTMI_WIDTHAlexey Brodkin2018-02-151-1/+1
| | | | | | | | | | | | | | | For some reason from day one we used to have both CONFIG_DWC2_UTMI_WIDTH mentioned in dwc2.h and in scripts/config_whitelist.txt but never really used and CONFIG_DWC2_UTMI_PHY_WIDTH used in real code in dwc2.c (but never defined). Moreover even though CONFIG_DWC2_UTMI_WIDTH might be either 8 or 16 depending on hardware (and the same is said in a comment for it in dwc2.h) but then 8 is hardcoded in the header leaving no ability to override this value in board's configuration. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Marek Vasut <marex@denx.de>
* wait_bit: use wait_for_bit_le32 and remove wait_for_bitÁlvaro Fernández Rojas2018-01-241-12/+12
| | | | | | | | wait_for_bit callers use the 32 bit LE version Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* treewide: replace with error() with pr_err()Masahiro Yamada2017-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | U-Boot widely uses error() as a bit noisier variant of printf(). This macro causes name conflict with the following line in include/linux/compiler-gcc.h: # define __compiletime_error(message) __attribute__((error(message))) This prevents us from using __compiletime_error(), and makes it difficult to fully sync BUILD_BUG macros with Linux. (Notice Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().) Let's convert error() into now treewide-available pr_err(). Done with the help of Coccinelle, excluing tools/ directory. The semantic patch I used is as follows: // <smpl> @@@@ -error +pr_err (...) // </smpl> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Re-run Coccinelle] Signed-off-by: Tom Rini <trini@konsulko.com>
* usb: dwc2: convert to livetreePhilipp Tomsich2017-09-271-1/+1
| | | | | | Update the DWC2 USB driver to support a live tree. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* usb: dwc2: use dev_read_bool() instead of fdt_getprop()Meng Dongyang2017-07-111-10/+6
| | | | | | | | | | Use dev_read_bool() instead of fdt_getprop() to get the property from DTS. And add a comment for "hnp-srp-disable" property to fully describe its effect. Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* usb: dwc2: force to host mode if not support HNP/SRPMeng Dongyang2017-06-171-3/+16
| | | | | | | | | In current code, after running the command of "usb start", the controller will keep in otg mode and can't switch to host mode if not support SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS to config the contrller work in force mode of host. Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
* dm: Rename dev_addr..() functionsSimon Glass2017-06-011-1/+1
| | | | | | | | | | | | | | | | | | | These support the flat device tree. We want to use the dev_read_..() prefix for functions that support both flat tree and live tree. So rename the existing functions to avoid confusion. In the end we will have: 1. dev_read_addr...() - works on devices, supports flat/live tree 2. devfdt_get_addr...() - current functions, flat tree only 3. of_get_address() etc. - new functions, live tree only All drivers will be written to use 1. That function will in turn call either 2 or 3 depending on whether the flat or live tree is in use. Note this involves changing some dead code - the imx_lpi2c.c file. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: dwc2: invalidate the dcache before starting the DMAEddie Cai2017-04-141-6/+13
| | | | | | | | | | | We should invalidate the dcache before starting the DMA. In case there are any dirty lines from the DMA buffer in the cache, subsequent cache-line replacements may corrupt the buffer in memory while the DMA is still going on. Cache-line replacement can happen if the CPU tries to bring some other memory locations into the cache while the DMA is going on. Signed-off-by: Eddie Cai <eddie.cai.linux@gmail.com> Reviewed-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* usb: dwc2: add support for external vbus supplyKever Yang2017-04-141-5/+38
| | | | | | | | | Some board do not use the dwc2 internal VBUS_DRV signal, but use a gpio pin to enable the 5.0V VBUS power, add interface to enable the power in dwc2 driver. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Replace of_offset with accessorSimon Glass2017-02-081-2/+2
| | | | | | | | | At present devices use a simple integer offset to record the device tree node associated with the device. In preparation for supporting a live device tree, which uses a node pointer instead, refactor existing code to access this field through an inline function. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: dwc2: Add delay to fix the USB detection problem on SoCFPGAStefan Roese2016-05-061-0/+9
| | | | | | | | | | | | | | | | | | With patch c998da0d (usb: Change power-on / scanning timeout handling), the USB scanning is started earlier and with a smaller timeout. This resulted on SoCFPGA (using the DWC2 driver) in some USB sticks not getting detected any more. This patch now adds a 1 second delay (in the host mode only) to the DWC2 driver before the scanning is started. With this delay, now all problematic USB keys are detected successfully again. And there is no need any more to change the delay / timeout in the common USB code (usb_hub.c). Signed-off-by: Stefan Roese <sr@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@opensource.altera.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Marek Vasut <marex@denx.de>
* usb: dwc2: Init desc_before_addrMarek Vasut2016-05-031-0/+3
| | | | | | | | | | | Initialize desc_before_addr, otherwise the USB core won't send the first 64B Get Device Descriptor request in common/usb.c function usb_setup_descriptor() . There are some USB devices which expect this sequence and otherwise can misbehave. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Dinh Nguyen <dinguyen@opensource.altera.com> Cc: Tom Rini <trini@konsulko.com>
* usb: dwc2: Make OC protection configurableMarek Vasut2016-05-031-3/+14
| | | | | | | | | | Introduce a new flag in the controller private data, which allows selectively disabling the OC protection. Use the standard 'disable-over-current' OF prop to set this flag. This OC protection must be disabled on EBV SoCrates rev 1. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Dinh Nguyen <dinguyen@kernel.org>
* usb: dwc2: Pull Ext VBUS macro from dwc_otg_core_init()Marek Vasut2016-05-031-7/+14
| | | | | | | | | | | Introduce a boolean flag in the dwc2 controller private data and set it according to the macro (for now) instead of having this macro directly in the dwc_otg_core_init(). This will let us configure the flag from DT or such later on, if needed. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Dinh Nguyen <dinguyen@kernel.org>
* usb: dwc2: Pass private data into dwc_otg_core_init()Marek Vasut2016-05-031-2/+3
| | | | | | | | | | Pass the whole bulk of private data instead of just the regs, since the private data will soon contain important configuration flags. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Dinh Nguyen <dinguyen@kernel.org>
* usb: dwc2: disable erroneous overcurrent conditionDinh Nguyen2016-03-051-1/+3
| | | | | | | | | | | For the case where an external VBUS is used, we should enable the external VBUS comparator in the driver. This would prevent an unnecessary overcurrent error which would then disable the host port. The overcurrent condition was happening on the SoCFPGA Cyclone5 devkit, thus USB was not working on the devkit. This patch fixes that problem. Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
* Merge branch 'master' of git://git.denx.de/u-boot-usbTom Rini2016-01-251-100/+201
|\
| * usb: dwc2: Do not mix data toggle for IN and OUT endpoints, check boundsStefan Brüns2016-01-231-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | USB protocol allows for 16 IN and 16 OUT endpoints (USB 2.0 Spec, 8.3.2.2 Endpoint Field). A function may have an EP 1 for both IN and OUT, so these two should be kept separate. As EPs are either BULK or INTERRUPT (or ISO), it is fine to have one array per direction for all transfer types (also see e236519b7365ef75c5da6a5623f0b03d9c00cfae). USB device address is 7 bits, so a bus may have more than 16 devices. Check the device number, as the DWC2 driver only supports BULK/ISO for the first 16 devices. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: Add SPLIT INTERRUPT transaction supportStefan Brüns2016-01-231-5/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | CSPLITs for INTERRUPT transactions have to be scheduled in each microframe following the SSPLIT. INTERRUPT transfers are executed in the next even/ odd microframe depending on the HCCHAR_ODDFRM flag. As there are no handshakes for INTERRUPT SSPLITs the SSPLIT may have failed (transport error) without the error being detected by the host driver. If the last CSPLIT is not received within 4 microframes after the SSPLIT there was a transaction error and the complete transaction has to be restarted. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: Implement SPLIT transaction supportStefan Brüns2016-01-231-15/+66
| | | | | | | | | | | | | | | | | | In contrast to non-SPLIT transfers each transaction has to be submitted as an individual chunk. The transaction state machine proceeds from SSPLIT to CSPLIT if the ACK flag is set. CSPLIT has to be repeated while NYET is set. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: add helper function for setting SPLIT HC registersStefan Brüns2016-01-231-1/+14
| | | | | | | | | | | | | | The split register setting is used for both SSPLIT and CSPLIT transactions, the bit for CSPLIT has to be set seperately. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: split transfer core from outer loopStefan Brüns2016-01-231-48/+64
| | | | | | | | | | | | | | | | Split the movement of data between CPU and Host Controller from the status handling and tracking of transfer progress. This will also simplify adding of SPLIT transaction support. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: Simplify wait_for_chhltd(), remove ignore_ackStefan Brüns2016-01-231-23/+17
| | | | | | | | | | | | | | | | | | | | | | | | A transfer is completed if the XFERCOMP flag is set, irrespective of the ACK flag. BULK OUT transfers to some HS devices complete without having the ACK flag set, which signal the devices has responded with an NYET to the transfer (PING protocol). The new behaviour matches the Linux kernel minus any PING protocol. Also see 5966defabdcc (usb: dwc2: fix bulk transfers) Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
| * usb: dwc2: Fix out-of-bounds access, fix chunk sizeStefan Brüns2016-01-231-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix two errors in transfer len calculation, move loop invariant code out of loop. If xfer_len is equal to CONFIG_DWC2_MAX_TRANSFER_SIZE (or slightly smaller), the xfer_len will be to large, e.g.: xfer_len = MAX_TRANSFER_SIZE = 65535 max packet size = 512 => num_packets = 128 => IN xfer_len = 65536 For OUT transactions larger than (65536 - mps) bytes, the xfer_len determination is quite awkward, it is only correct due to: - max_packet_size for control/bulk/interrupt is required to be power-of-two. - (CONFIG_DWC2_MAX_TRANSFER_SIZE + 1) % max-packet-size is zero for all allowed (2^3 ... 2^9) packet sizes As the max xfer len is loop invariant, it can be moved out of the loop. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
* | usb: dwc2: Use shared wait_for_bitMateusz Kulikowski2016-01-251-28/+13
|/ | | | | | Use existing library function to poll bit(s). Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
* usb: dwc2: avoid out of bounds accessStefan Brüns2015-12-311-3/+4
| | | | | | | | | | flush_dcache_range may access data after priv->aligned_buffer end if len > DWC2_DATA_BUF_SIZE. memcpy may access data after buffer end if done > 0 Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Acked-by: Marek Vasut <marex@denx.de> Acked-by: Stephen Warren <swarren@wwwdotorg.org>
* Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass2015-09-111-0/+1
| | | | | | | Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: dwc2: Rename to dwc2_usbMarek Vasut2015-08-191-1/+1
| | | | | | | This driver is not used only on exynos, but also on Altera SoCFPGA, HiSilicon SoCs, RPi etc, so rename it accordingly to prevent confusion. Signed-off-by: Marek Vasut <marex@denx.de>
* usb: dwc2: Add original Synopsys compat stringMarek Vasut2015-08-191-0/+1
| | | | | | Add the Synopsys compatible string. This is used in SoCFPGA DT files. Signed-off-by: Marek Vasut <marex@denx.de>
* dwc2: Add dcache supportAlexander Stein2015-08-121-7/+17
| | | | | | | | | | | This adds dcache support for dwc2. The DMA buffers must be DMA aligned and is flushed for outgoing transactions before starting transfer. For ingoing transactions it is invalidated after the transfer has finished. Signed-off-by: Alexander Stein <alexanders83@web.de> Acked-by: Stephen Warren <swarren@wwwdotorg.org> [trini: Update to apply again on top of DM patches] Signed-off-by: Tom Rini <trini@konsulko.com>
* dm: usb: Add driver-model support to dwc2Simon Glass2015-08-061-0/+97
| | | | | | | Add driver model support to this driver so it can be used with the new USB stack. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: usb: Prepare dwc2 driver for driver-model conversionSimon Glass2015-08-061-54/+104
| | | | | | | Put all global data in a structure and move (what will be) common code into common functions. This will make the driver-model conversion much easier. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: dwc2: Call board_usb_init() from usb_lowlevel_init()Peter Griffin2015-08-051-0/+4
| | | | | | | | | | This patch makes the dwc2 controller like ehci / ohci / xhci controllers by calling the board_usb_init() function from usb_lowlevel_init. This can then be implemented by specific platforms to initialise their USB hardware (phys / clocks etc). Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
* usb: dwc2: Add support for v3 snpsid valuePeter Griffin2015-05-291-1/+2
| | | | | | | | This has been tested to the extent that I can enumerate a asix usb networking adapter and boot a kernel over usb on the 96boards hikey u-boot port I'm currently doing. Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
* usb: dwc2: retry NAK'd interrupt transfersStephen Warren2015-04-141-6/+19
| | | | | | | | | | | | | | | | | IIUC, interrupt transfers are NAK'd by devices until they wish to trigger an interrupt, and e.g. EHCI controllers retry these in HW until they are ACK'd. However, DWC2 doesn't seem to retry, so we need to do this in SW. In practice, I've seen DWC2_HCINT_FRMOVRUN happen too. I'm not quite sure what this error implies; perhaps it's related to how near the end of a USB frame we're at when the interrupt transfer is initiated? Anyway, retrying this temporary error seems to be necessary too. With all these commits applied, both my USB keyboards (one LS Lenovo and one FS Dell) work correctly when there is no USB hub between the SoC and the keyboard; We still need split transactions to be implemented for hubs to work. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* usb: dwc2: implement interrupt transfersStephen Warren2015-04-141-3/+2
| | | | | | | | | | | | | | | | | | | | | | As best I can tell, there's no difference between bulk and interrupt transfers in terms of how the HW should be programmed, at least given that we're executing one transaction at a time rather than scheduling them into frames for maximum throughput. This patch ends up sharing the toggle bit state between bulk and interrupt transfers on a particular EP. However I believe this is fine; AFAIK a given EP either uses bulk or interrupt transfers and doesn't mix them. This patch doesn't do anything with the "interval" parameter for interrupt transfers, but then most other USB controller drivers in U-Boot don't either. It turns out that one of my keyboards is happy to work using control transfers but the other only gives non-zero "HID reports" via interrupt transfers. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* usb: dwc2: correctly program hcchar for LS devicesStephen Warren2015-04-141-9/+12
| | | | | | | | A bit must be set in HCCHAR when communicating with low-speed devices. I have no idea why there's no corresponding bit to distinguish between full-speed and high-speed devices, but no matter; they all work now! Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* usb: dwc2: detect device speed correctlyStephen Warren2015-04-141-1/+5
| | | | | | | This doesn't make my LS keyboard work any better, but it does at least report the correct speed in "usb tree". Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>