Commit Graph

49764 Commits

Author SHA1 Message Date
Patrick Delaunay ba6d0aabab UPSTREAM: usb: dwc2: allow peripheral mode for OTG configuration
Allow device mode in DWC2 driver when device tree select the dr_mode
"peripheral" or "otg".

The device mode is not allowed when dr_mode = "host" in device tree.

Change-Id: Iede854cdf940f5e1ef14a7e394087ac97998213a
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 7c654683464dc4cd89f9a8198e26336263390b57)
2020-01-07 17:24:58 +08:00
Patrick Delaunay aea37ef60f UPSTREAM: usb: dwc2: correctly handle binding for g-tx-fifo-size
Manage g-tx-fifo-size as a array as specify in the binding.

Change-Id: Ie2f0fa8eda62d762fe79072db377c1b00b23ee4c
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 7350a75b517b6162c8f832a9ead09b9e26e8068f)
2020-01-07 17:24:58 +08:00
Yinbo Zhu 7472a52faf UPSTREAM: usb: ehci: adopt 32 bit address for CONFIG_PPC
adopt 32 bit addr in fsl_esdhc for CONFIG_PPC.
So  adopt 32 bit address for CONFIG_PPC.

Change-Id: Ibb69849ed19fa18f494807020f9a6a911692b1aa
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit ad9f2be3348c088e7839fd3598db3b352060bff1)
2020-01-07 17:24:58 +08:00
Adam Ford 0620c8ad4c UPSTREAM: usb: ohci: ohci-da8xx: Cleanup Error handling and fix flags
Per feedback from Marek, he suggested better handling and
to enable DM_FLAG_OS_PREPARE, this patch re-orders some of
the error checking, and errors returns the error code right
away and also sets DM_FLAG_OS_PREPARE.

Change-Id: I639a5e4f6d5c89a18e722db2601cf18acb96cbb3
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 3a90b50a32b6b8a2d66dc10c19e3c15d5bd1a092)
2020-01-07 17:24:58 +08:00
Neil Armstrong 518b4f5b8d UPSTREAM: usb: dwc3: Add Meson G12A USB Glue
Adds support for Amlogic G12A USB Control Glue HW.

The Amlogic G12A SoC Family embeds 2 USB Controllers :
- a DWC3 IP configured as Host for USB2 and USB3
- a DWC2 IP configured as Peripheral USB2 Only

A glue connects these both controllers to 2 USB2 PHYs, and optionnally
to an USB3+PCIE Combo PHY shared with the PCIE controller.

The Glue configures the UTMI 8bit interfaces for the USB2 PHYs, including
routing of the OTG PHY between the DWC3 and DWC2 controllers, and
setups the on-chip OTG mode selection for this PHY.

This driver sets the OTG capable port as Host mode by default,
the switch to Device mode is to be done in a separate patch.

Change-Id: I099bb5fbda0fdd52c4d78e32f879f8324bda4c59
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit adb049abf7a209629c7b5e4bc673a0d802c616c2)
2020-01-07 17:24:58 +08:00
Adam Ford dff9f0f7f0 UPSTREAM: usb: ohci: ohci-da8xx: Enable da850-ohci driver with DM support
This patch reuses some former code for the hawkboard, combines it
with some some similar DM_USB compatible code for the OHCI driver,
and enables the use of the da850's OHCI controller with DM_USB
compatibility.

Change-Id: I86a1fdf6bf2163deae6b6f8c09fcb0ea53b73067
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 9da5474389c784474274d8e1d1d04fab924d3c39)
2020-01-07 17:24:58 +08:00
Adam Ford 200d235e49 UPSTREAM: usb: ohci: Re-enable commented out delay
There is a delay function that was commented out.  This patch
re-enables it, because it will be needed for da850 ohci support.

Change-Id: Ibfbe2844807ac13501cc17a297c724791e1eac52
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit e0b0af666a81f166397e3aebd26e9401ae48c97d)
2020-01-07 17:24:58 +08:00
Lukasz Majewski 0163d8d8bf UPSTREAM: USB: DM: Convert i.MX5 ehci code to driver model
This commit converts i.MX5's EHCI USB host driver to driver model (DM_USB).
It is a straightforward conversion (to reuse as much code as possible),
based on ehci-mx6.c code.

Change-Id: I14727c670f5ecf78f2caaab56f04d8be578a91fb
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 22988766da6fe200b6947b8181ddbde663643248)
2020-01-07 17:24:57 +08:00
Fabrice Gasnier 24b360da41 UPSTREAM: usb: dwc2: fix gadget disconnect
This fixes a disconnect issue detected with fastboot command, when using
dwc2 driver.
- On u-boot side:
uboot>$ fastboot 0
- On USB host PC side, few seconds after
PC>$ fastboot reboot # Get stuck, uboot target never reboots

By enabling DEBUG_ISR logs, the bus suspend interrupt is seen before the
PC command has been issued. When the USB bus suspend occurs, there's a HACK
that disables the fastboot (composite driver). Here is the call stack
upon USB bus suspend:
- dwc2_handle_usb_suspend_intr()
  - dev->driver->disconnect()
    - composite_disconnect()
      - reset_config()
        - f->disable()
          - fastboot_disable()
            - usb_ep_disable(f_fb->out_ep);
            - usb_ep_disable(f_fb->in_ep);
            .. other disable calls.

When the resume interrupt happens, everything has been disabled, then
nothing happens. fastboot command gets stuck on HOST side.

Remove original HACK, that disconnects the composite driver upon
USB bus suspend. Implement disconnect detection instead:
- check GINTSTS OTG interrupt
- read GOTGINT register
- check GOTGINT, SesEndDet bit (e.g. session end)
This is inspired by what is implemented currently in Linux dwc2 driver.

Change-Id: I061bf19a7be2c85fdde3490ef792f18612de9c56
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 7fd9f31c6bd13609da61b985cf8f5f65ebebd913)
2020-01-07 17:24:57 +08:00
Patrick Delaunay db704406b3 UPSTREAM: stm32mp1: add stusb1600 support for DK1 and DK2 board
The DK1 and DK2 boards use the USB Type-C controller STUSB1600.
This patch updates:
- the device tree to add the I2C node in the DT
- the board stm32mp1 to probe this I2C device and use this controller
  to check cable detection.
- the DWC2 driver to support a new dt property
  "u-boot,force-b-session-valid" which forces B session and
  device mode; it is a workaround because the VBUS sensing and
  ID detection isn't available with stusb1600.

Conflicts:
	arch/arm/dts/stm32mp157-pinctrl.dtsi
	arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
	arch/arm/dts/stm32mp157a-dk1.dts
	board/st/stm32mp1/stm32mp1.c

Change-Id: I73b62dce9c3e0661e6d2463b87389229cd3559a7
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
(cherry picked from commit 6fe7dd3327d552bacf4266d7f1ed074bf98ffb92)
2020-01-07 17:24:57 +08:00
Patrick Delaunay acd7aca8c0 UPSTREAM: usb: dwc2: add support for STM32MP1
Add compatible "st,stm32mp1-hsotg" and associated driver data to manage
the usb33d-supply and the ST specific register for VBus sensing.

Change-Id: If60971ebf415cb708b04af38c7b61d5321a13181
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 931e9d7aa7228867eec7e33fd45718e6018cc96d)
2020-01-07 17:24:57 +08:00
Patrice Chotard 6187c34651 UPSTREAM: usb: dwc2_udc_otg: Add tx_fifo_sz array support
All TX fifo size can be different, add tx_fifo_sz_array[]
into dwc2_plat_otg_data to be able to set them.

tx_fifo_sz_array[] is 17 Bytes long and can contains max 16
tx fifo size (synopsys IP supports max 16 IN endpoints).
First entry of tx_fifo_sz_array[] is the number of valid
fifo size the array contains.

In case of tx_fifo_sz_array[] doesn't contains the same
number of element than max hardware endpoint, display
a warning message.

Compatibility with board which doesn't use tx_fifo_sz_array[]
(Rockchip rk322x/rk3128/rv1108/rk3288/rk3036) is kept.

Change-Id: If32954770f9571a1bb18376239ef9cff9a721178
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 763bb106f66c147b7d0c3046dbba66a07d7a9dd2)
2020-01-07 17:24:57 +08:00
Patrick Delaunay 38b0d5741a UPSTREAM: usb: dwc2_udc_otg: Read MAX_HW_ENDPOINT from HWCFG4 register
Some DWC2 ip variant doesn't use 16 hardware endpoint as hardcoded
in the driver. Bits INEps [29:26] of HWCFG4 register allows to get
this information.

Change-Id: I22f88ef7ee2749cce3c93f5c8a455a1de165b9dd
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 5bd97e80730bdda59656ca927d67d62fb2a4ecb6)
2020-01-07 17:24:57 +08:00
Patrick Delaunay 3015f8bebd UPSTREAM: usb: dwc2: Add function for session B check
Add a new function to check the session B validity, to be use to check
cable connection.

Change-Id: I914d7353e926df26787261c99f07e5c58dbf24ff
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 2d76160f049c42087011cfa0e6e878aa2ed6b406)
2020-01-07 17:24:57 +08:00
Patrick Delaunay 5c4beedb87 UPSTREAM: usb: dwc2: Add force-b-session-valid support
Handle "force-b-session-valid" property from DT.

Change-Id: I5a0bf871506257b449897cb67732fef430704134
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 0fdd0bc621f060fcf60fd4ba48a2a32f338ffeac)
2020-01-07 17:24:57 +08:00
Patrick Delaunay b486dd9ec4 UPSTREAM: usb: dwc2: force reset assert before to probe the driver
Reset the hardware to be sure of the device state.

Change-Id: Ia86b8b929d6f5316820464a8dbfadbadd7e9d3dc
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit c2c74f97afff9351077f2236ab6fa5638de9bd86)
2020-01-07 17:24:57 +08:00
Patrick Delaunay 1b9a1ae680 UPSTREAM: usb: dwc2: convert driver to DM_USB_GADGET
Minimal conversion to driver model by using the uclass
UCLASS_USB_GADGET_GENERIC based on:
- reset uclass
- clock uclass
- generic uclass.

Change-Id: Id366ea00cb1126d14cb8cef2a9e86b86df6cd612
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit c791c8431c34da803fdac4a308999879a6a33834)
2020-01-07 17:24:56 +08:00
Patrick Delaunay a0c39c0746 UPSTREAM: usb: dwc2: remove unused variable regs_otg
Remove the global regs_otg variable.

Change-Id: Iea128368e3b6593cf15d2e2bd31dfe03c445ad32
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit a812d77617749eeaddfa8b9796b9a2eece1ad2f5)
2020-01-07 17:24:56 +08:00
Marcel Ziswiler 2522005341 UPSTREAM: configs: move CONFIG_USB_EHCI_VF to Kconfig
Move CONFIG_USB_EHCI_VF to drivers/usb/host/Kconfig and update the one
and only user thereof being colibri_vf.

Change-Id: I69228893cb776f077e68a80ee236aeed6e7c2d26
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 20df4b570d164675da17bf23998e51271f5a79a3)
2020-01-07 17:24:56 +08:00
Adam Ford 0457b2cd59 UPSTREAM: usb: ehci-mx6: Use common code to extract dr_mode
There exists code in drivers/common/common.c to read the dr_mode
from the device tree.  This patch converts this driver to use that
function to initialize the driver.

Change-Id: Id4cc8e5a61f63bef9813e83b4183253caccedd1a
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 69535b33bc1fce43dcc10b646cf44db81cffa131)
2020-01-07 17:24:56 +08:00
Ismael Luceno Cortes 79e8eddfb9 UPSTREAM: usb: host: Print device name when scanning
Drop the counter, it has no meaning other than being the order in which
the interface is found; the name assigned to the USB host controller
interface is a better indicator.

Example of the original output:
> USB0:   USB EHCI 1.10
> scanning bus 0 for devices... 2 USB Device(s) found
>        scanning usb for storage devices... 1 Storage Device(s) found

Patched output:
> Bus usb@ee080100: USB EHCI 1.10
> scanning bus usb@ee080100 for devices... 2 USB Device(s) found
>        scanning usb for storage devices... 1 Storage Device(s) found

Change-Id: I4d009cd00a03018c4fec2f9ba573e35010f6328f
Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 89aea23abb971fa89b7a96c02024b63d0b918a78)
2020-01-07 17:24:56 +08:00
Jean-Jacques Hiblot 95dc2be99c UPSTREAM: usb: udc-uclass: Fixed problem when no alias is defined in DT
commit 801f1fa442 "dm: usb: udc: Use SEQ_ALIAS to index the USB gadget
ports" changed the way the udevice if found. It uses the alias to find
a udevice for a given USB port number. In the commit log it was stated
that if no alias is provided, the bind order will be used instead. However
it doesn't work. Fixing this by adding a call to uclass_get_device() if
uclass_get_device_by_seq() fails.

Change-Id: Ib2304c5ecd5d46089c3273ca3ecaa3f9eb5399f8
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Tested-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit e81d9de531fb4c7f14344736bd7568c954e64e14)
2020-01-07 17:24:56 +08:00
Abel Vesa 8a4a81a148 UPSTREAM: usb: ehci-mx6: Make regulator DM_REGULATOR dependent
Do the regulator related work only if the build has the DM_REGULATOR.

Change-Id: If11178f890f6084633565fd6d36bfb6f3834293c
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 921208ebca6f109990359b3089b5f416b269b07b)
2020-01-07 17:24:56 +08:00
Jean-Jacques Hiblot b1c323b178 UPSTREAM: usb: ether: call _usb_eth_halt() if initialization fails
If the host does not respond in time, the initialization fails. However
the usb ether driver will still be registered. This will make
usb_gadget_probe_driver() fail the next time the initialization is
attempted because it cannot find an available UDC.

Fixing this by calling _usb_eth_halt() when the init fails.

Change-Id: Id61795e444e12265657a8a070f48b35d4a9ca280
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 1c1464c2b19f1b96885040b8adc9cf5ba3c7b32d)
2020-01-07 17:24:56 +08:00
Andrew F. Davis 09b32b41f2 UPSTREAM: spl: Kconfig: Drop the _SUPPORT postfix from SPL_DFU
The symbol CONFIG_SPL_DFU_SUPPORT in SPL build has the same
meaning as CONFIG_DFU in regular U-Boot. Drop the _SUPPORT
to allow for cleaner use in code.

Conflicts:
	arch/arm/mach-zynqmp/spl.c
	common/Makefile
	common/spl/Kconfig
	common/spl/spl_ram.c

Change-Id: I93f09d5953284d511df135e6e71c03c0552719a2
Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
(cherry picked from commit 6536ca4d6676bf38e50784298e713edc30b9cde9)
2020-01-07 17:24:56 +08:00
Jagan Teki 6baf2cc3b2 UPSTREAM: usb: host: Drop [e-o]hci-sunxi drivers
Now Allwinner platform is all set to use Generic USB
controller drivers, so remove the legacy sunxi drivers.

Conflicts:
	drivers/usb/host/ehci-sunxi.c
	drivers/usb/host/ohci-sunxi.c
	scripts/config_whitelist.txt

Change-Id: I68dec1660d92dce8833d5a05584694d7b7c4ab36
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
(cherry picked from commit 543049ab590620a91b37fa0296edd3bcddd0eba2)
2020-01-07 17:24:56 +08:00
Jean-Jacques Hiblot 9e4d054014 UPSTREAM: dm: usb: gadget: Fix boot breakage on sunxi platforms
Fixes commit 013116243950 ("dm: usb: create a new UCLASS ID for USB gadget
devices")

The UCLASS_DRIVER for id UCLASS_USB_GADGET_GENERIC needs to be declared
even for platforms that do not enable DM_USB_GADGET. Otherwise the driver
for their usb peripheral controller fails to bind.

Change-Id: Ide6104f24be321d05d399b03a9fc38663f44a2d1
Reported-by: Priit Laes <plaes@plaes.org>
Reported-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Tested-by: Priit Laes <plaes@plaes.org>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit b3c518a88278619b1e109de114c450237d03e032)
2020-01-07 17:24:55 +08:00
Jean-Jacques Hiblot eccca8a35d UPSTREAM: Kconfig: rename CONFIG_SPL_USB_GADGET as CONFIG_SPL_USB_GADGET
The SPL option for USB gadget should be named after the option for u-boot
(CONFIG_USB_GADGET)

Conflicts:
	arch/arm/mach-imx/mx6/Kconfig
	arch/arm/mach-imx/spl.c
	configs/am335x_boneblack_vboot_defconfig
	configs/am335x_evm_usbspl_defconfig
	configs/am43xx_evm_defconfig
	configs/am43xx_hs_evm_defconfig
	configs/imx6q_logic_defconfig
	configs/mx6memcal_defconfig
	configs/mx6sabresd_defconfig
	configs/pico-hobbit-imx6ul_defconfig
	configs/pico-hobbit-imx7d_defconfig
	configs/pico-imx6ul_defconfig
	configs/pico-imx7d_defconfig
	configs/pico-pi-imx6ul_defconfig
	configs/pico-pi-imx7d_defconfig
	drivers/Makefile

Change-Id: I51305422f13cb7d743274f82c531000c0f93c144
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit f811e9763f4b6f6f5e3fe9c2fa30d2b6c62d289e)
2020-01-07 17:24:55 +08:00
Jean-Jacques Hiblot 152ba5092a UPSTREAM: dm: usb: udc: Use SEQ_ALIAS to index the USB gadget ports
dfu, fastbot and other usb gadget commands take the USB port index as a
parameter. Currently this index is assigned in the order of the driver
bindings.
Changing this behavior using the SEQ_ALIAS feature. This option assign to
the device a SEQ number based on its alias (if it exists)

To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the existing
naming convention: use "usb" for the name of the gadget UCLASS_DRIVER
(same as for the UCLASS_USB).

If no alias is provided, then the index falls back to the order in which
the bindings took place.

Change-Id: I3bd5d0ef6871f69d2e4b2667817a0a81e0cee83e
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reported-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 801f1fa44275e274e33bdfc7fb76535cc6118d61)
2020-01-07 17:24:55 +08:00
Ye Li 3403786c68 UPSTREAM: usb: xhci-mem: Fix scratchpad array issue
After updating the value of dev_context_ptrs[0], we should flush this
from cache to memory. Otherwise the xhci controller won't use it.

Change-Id: I1328e8ddfcf84a46975897b5eb46f4f887e81464
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 8c6cc71b40357dad4e3f21e9f1bd84db76a3d994)
2020-01-07 17:24:55 +08:00
Siva Durga Prasad Paladugu 204f137983 UPSTREAM: usb: composite: Fix max packet size for USB3.0
For USB3.0, the max packetsize for GET_DESCRIPTOR should be
sent as exponent value for 2. This means for 512, max packet
size should be filled with 9(2^9=512). Also, fill the USB
version field with 3.0 if speed is negotiated to Superspeed.
This fixes the issue of DFU gadget download failure with
superspeed. Without this patch, the max packet size is
overflowed to zero as the bMaxPacketsize is of u8 and hence
host is not able to detect this device.

Conflicts:
	drivers/usb/gadget/composite.c

Change-Id: I6aff8e97637d788f309273f0c0afb49dbb71001d
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
(cherry picked from commit 771e76515ed5abe7eff73a54ccb0c9ae55f34388)
2020-01-07 17:24:55 +08:00
Jean-Jacques Hiblot f7334c8176 UPSTREAM: dwc3-generic: Add support for the am437x
Change-Id: Ifbb1d31cfa83384e60c2d20af4e1b37085ee4232
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 1ce5f1f933b6b3e0994b4b7d198afe0198442888)
2020-01-07 17:24:55 +08:00
Jean-Jacques Hiblot 5277273c32 UPSTREAM: usb: host: replace xhci-keystone driver by the generic dwc3 driver
The keystone platforms can use the generic DC3 driver. Removing the
keystone-spcecific xchi driver and add the configuration options to enable
the generic DWC3 driver on all K2 platforms.

Conflicts:
	configs/k2e_evm_defconfig
	configs/k2e_hs_evm_defconfig
	configs/k2g_evm_defconfig
	configs/k2g_hs_evm_defconfig
	configs/k2hk_evm_defconfig
	configs/k2hk_hs_evm_defconfig
	configs/k2l_evm_defconfig
	configs/k2l_hs_evm_defconfig
	drivers/usb/host/xhci-keystone.c

Change-Id: I0d708152a220704d24b86c528ee7ace2b0b05a4a
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
(cherry picked from commit 4dd76d0f96ab18a2bda622ec4dac822e908dd069)
2020-01-07 17:24:55 +08:00
Jean-Jacques Hiblot 4323bebbd5 UPSTREAM: usb: dwc3-generic: make it compatible with "ti, keystone-dwc3"
Change-Id: Ibb728efe79707ce2d5b4cc7910428b4821719b28
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 1c03ade328dd08603fa717076c5888557f1a9fa7)
2020-01-07 17:24:55 +08:00
Martyn Welch 0a04ddb5ea UPSTREAM: usb: Don't enable CONFIG_SPL_DM_USB for non-DM SPL
When CONFIG_SPL_DM_USB was added, it was added defaulted on without
protection to ensure it didn't get set for non-DM SPL builds.

This leads to unexpected and confusing failures when building a DM based
U-Boot but with a non-DM SPL, as the defconfig is unlikely to have
CONFIG_SPL_DM_USB actively disabled.

Tweak the Kconfig to not enable this setting unless CONFIG_SPL_DM is set.

Change-Id: I11e59ec852e9621f01e526e21805a922ba1feb44
Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 16ecb295b3834d8017d922ae46eedbbf6fd6c99b)
2020-01-07 17:24:55 +08:00
Lukasz Majewski 57521aaaf8 UPSTREAM: usb: composite: Move bitmap related operations to ./include/linux/bitmap.h
The BITMAP related operations can now be moved to ./include/linux/bitmap.h
file to mimic the Linux kernel directory tree.

This change also allows to remove the lin_gadget_compat.h header file
(which is a legacy code only for composite U-boot layer).
It was also possible to remove #includes from several USB gadget drivers.

Conflicts:
	include/usb/lin_gadget_compat.h

Change-Id: Id61d6f9cef89ca238f082f430f6d01ac1009aa07
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
(cherry picked from commit 916fa097997a5e1b70768ce944de28e038d4bebf)
2020-01-07 17:24:55 +08:00
Petr Štetiar 8379698a1f UPSTREAM: usb: gadget: f_sdp: Provide filesize env variable for downloaded images
Currently it's not possible to get filesize of downloaded images and
it's impossible to automate some tasks in scripts. So this patch adds
`filesize` environment variable with size (as hex number in bytes) of
the last successfully downloaded file via `sdp` command.

Change-Id: I1daec88c46cc51c510880ebf052e3b455ef9ead6
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan.agner@toradex.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit bb00a015d624f683c66c9e30341f93b678d03d2e)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot bb24d586ab UPSTREAM: dwc3-generic: Add support for the TI DWC3 glue
Change-Id: Id225a6f88c94a187f3d19f1bef90dd66a9399a95
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit d66e54ac8084f892bf9a43f3242b5e2bf9a686ed)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot dc627159e2 UPSTREAM: usb: dwc3: Fix a compilation error with the edison defconfig
The error is:
In file included from include/part.h:10:0,
                 from include/usb.h:18,
                 from include/linux/usb/gadget.h:22,
                 from drivers/usb/dwc3/ep0.c:20:
include/ide.h:62:14: error: unknown type name ‘uchar’
 void ide_led(uchar led, uchar status);

Fixing it by including common.h that defines the uchar type.

Change-Id: I97a5eabe32e03709a7e2800cd6ee8adf186daa76
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 4d3825c1915e1649c4be0320e74be158e4698655)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot c08fbf4621 UPSTREAM: dwc3-generic: Add select_dr_mode operation
The select_dr_mode operation is executed when the glue driver is probed.
The role of this optional function is to configure the operating mode
of the controller at the glue level.

Change-Id: I613fc4e985d9400ae9f27b6becff9d6c8d105e98
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 93991cf1969077108ae36e90acb3cd25a6a449ac)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot bb4f93a7de UPSTREAM: dwc3-generic: Handle the PHYs, the clocks and the reset lines
This make the driver more generic. At this point this driver can replace
the dwc3-of-simple implementation.
Make the description in the Kconfig more generic too.

Change-Id: Icf52db944e2559492cee912e14357f79713ba797
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 446e3a205b871943736e22565092771fac98a9a4)
2020-01-07 17:24:54 +08:00
Frank Wang ad761bde9c configs: rk3328: enable dwc3 core
Change-Id: I2a3b7e0afaadb36db46d36e84bdf03ca712aa84c
Fixes: d648a50c0a27 ("dwc3: move phy operation to core.c")
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot 72d48a52ff UPSTREAM: dwc3: move phy operation to core.c
Those operations can be used for peripheral operation as well as host
operation.

Change-Id: Ifa3b83bd690cd11f6750fd893e6ac36b2a0214b3
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit d648a50c0a27452a5439e7982b23b97c64820430)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot 20828bbaa7 UPSTREAM: dm: usb: create a new UCLASS ID for USB gadget devices
UCLASS_USB_DEV_GENERIC was meant for USB devices connected to host
controllers, not gadget devices.
Adding a new UCLASS for gadget devices alone.

Also move the generic DM code for USB gadgets in a separate file for
clarity.

Conflicts:
	board/sunxi/board.c

Change-Id: I9bd01ad0814b81f7718927660a8ece4080c5f988
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 0131162439508801b9f8a330fa731f04273c9337)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot 7273610712 UPSTREAM: dwc3_generic: do not probe the USB device driver when it's bound
The driver will be probed when usb_gadget_initialize() is called.

Change-Id: I3783059179b8b4f21592227ea948f809a6b7c438
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 20bebd866690bb09dd1c1cb8ac674c3b17b63c6d)
2020-01-07 17:24:54 +08:00
Jean-Jacques Hiblot 256dc48f87 UPSTREAM: usb: udc: implement DM versions of usb_gadget_initialize()/_release()/_handle_interrupt()
When DM_USB_GADGET the platform code for the USB device must be replaced by
calls to a USB device driver.

usb_gadget_initialize() probes the USB device driver.
usb_gadget_release() removes the USB device driver.

Change-Id: I759a0d192d4baafeb188cfad4b3a08b5d2d05c23
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit ff8d75583487eb69bcb6f036088d979c76db3753)
2020-01-07 17:24:53 +08:00
Jean-Jacques Hiblot 717f5765d9 UPSTREAM: usb: introduce a separate config option for DM USB device
Using CONFIG_DM_USB for this purpose prevents using DM_USB for host and not
for device.

Conflicts:
	arch/arm/Kconfig

Change-Id: I075c887a77e2243463a580eac59d842b620af2f5
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 687ab54560809e01a10652ef82dbac6ae72deb91)
2020-01-07 17:24:53 +08:00
Jean-Jacques Hiblot b95d44460f UPSTREAM: usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers
Add 2 functions to wrap the calls to board_usb_init() and
board_usb_cleanup().
This is a preparatory work for DM support for UDC drivers (DM_USB_GADGET).

Conflicts:
	cmd/fastboot.c
	cmd/rockusb.c
	cmd/usb_mass_storage.c

Change-Id: I2b3a567d9dff75a03176d76d9fd9775cd8a0792e
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit a06955ae1ef2a942f18025d4fefceea2c638a76f)
2020-01-07 17:24:53 +08:00
Alexander Graf 3da53cbff9 UPSTREAM: usb: Do not compile USB_STORAGE with BLK && !DM_USB
The USB storage driver does not compile when CONFIG_BLK is set,
but DM_USB is not set, as we're missing the DM device links for
CONFIG_BLK enabled code paths.

So far it looks like nobody fell into this trap, because no board
enabled CONFIG_BLK and CONFIG_USB_STORAGE while not enabling
CONFIG_DM_USB, but we should still reflect that dependency properly
in Kconfig so that implicit enabling of CONFIG_USB_STORAGE works.

Change-Id: I5f87b577eb94e0ee33036b7162fcece7e04841aa
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit dc03b704f4364da6df6a86aafccc3828ade8ed43)
2020-01-07 17:24:53 +08:00
Sven Schwermer 3739bf7e20 UPSTREAM: usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/
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.

Conflicts:
	drivers/usb/host/ehci-atmel.c
	drivers/usb/host/xhci-fsl.c

Change-Id: If6c980c620cf97c1dd131f60953c305e34dba505
Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit fd09c205fc57b90a782cac33449ef172575d0a8c)
2020-01-07 17:24:53 +08:00