[PATCH next v7 05/10] usb: add MediaTek USB3 DRD driver

Bin Meng bmeng.cn at gmail.com
Tue Oct 13 16:26:25 CEST 2020


On Fri, Sep 18, 2020 at 5:12 PM Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:
>
> This patch adds support for the MediaTek USB3 DRD controller,
> its host side is based on xHCI, this driver supports device mode
> and host mode.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>

I can only comment some generic stuff, since I have no access to the
controller datasheet.

> ---
> v7:
>     1. use xhci quirk flag XHCI_MTK_HOST
>
> v6: no changes
>
> v5:
>     1. change condition of readl_poll_timeout() when check clocks
>
> v4:
>     1. remove unused member @busy and @wedged, use their flags instead
>     2. support force_vbus mode
>     3. add a glue driver using UCLASS_NOP
>     4. add host driver, and rebuild host flow
>
> v3 changes
>     1. add ->udc_set_speed()
>     2. simplify some code flow
>
> v2: simplify QMU operations
> ---
>  Makefile                           |   1 +
>  drivers/usb/Kconfig                |   2 +
>  drivers/usb/mtu3/Kconfig           |  45 ++
>  drivers/usb/mtu3/Makefile          |  11 +
>  drivers/usb/mtu3/mtu3.h            | 423 +++++++++++++++++
>  drivers/usb/mtu3/mtu3_core.c       | 838 +++++++++++++++++++++++++++++++++
>  drivers/usb/mtu3/mtu3_dr.h         |  52 +++
>  drivers/usb/mtu3/mtu3_gadget.c     | 686 +++++++++++++++++++++++++++
>  drivers/usb/mtu3/mtu3_gadget_ep0.c | 933 +++++++++++++++++++++++++++++++++++++
>  drivers/usb/mtu3/mtu3_host.c       | 141 ++++++
>  drivers/usb/mtu3/mtu3_hw_regs.h    | 515 ++++++++++++++++++++
>  drivers/usb/mtu3/mtu3_plat.c       | 368 +++++++++++++++
>  drivers/usb/mtu3/mtu3_qmu.c        | 504 ++++++++++++++++++++
>  drivers/usb/mtu3/mtu3_qmu.h        |  37 ++
>  14 files changed, 4556 insertions(+)
>  create mode 100644 drivers/usb/mtu3/Kconfig
>  create mode 100644 drivers/usb/mtu3/Makefile
>  create mode 100644 drivers/usb/mtu3/mtu3.h
>  create mode 100644 drivers/usb/mtu3/mtu3_core.c
>  create mode 100644 drivers/usb/mtu3/mtu3_dr.h
>  create mode 100644 drivers/usb/mtu3/mtu3_gadget.c
>  create mode 100644 drivers/usb/mtu3/mtu3_gadget_ep0.c
>  create mode 100644 drivers/usb/mtu3/mtu3_host.c
>  create mode 100644 drivers/usb/mtu3/mtu3_hw_regs.h
>  create mode 100644 drivers/usb/mtu3/mtu3_plat.c
>  create mode 100644 drivers/usb/mtu3/mtu3_qmu.c
>  create mode 100644 drivers/usb/mtu3/mtu3_qmu.h
>
> diff --git a/Makefile b/Makefile
> index 7a05fc7..2dcc41a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -795,6 +795,7 @@ libs-y += drivers/usb/eth/
>  libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/
>  libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/udc/
>  libs-y += drivers/usb/host/
> +libs-y += drivers/usb/mtu3/
>  libs-y += drivers/usb/musb/
>  libs-y += drivers/usb/musb-new/
>  libs-y += drivers/usb/phy/
> diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
> index 34881a1..fedc013 100644
> --- a/drivers/usb/Kconfig
> +++ b/drivers/usb/Kconfig
> @@ -72,6 +72,8 @@ source "drivers/usb/cdns3/Kconfig"
>
>  source "drivers/usb/dwc3/Kconfig"
>
> +source "drivers/usb/mtu3/Kconfig"
> +
>  source "drivers/usb/musb/Kconfig"
>
>  source "drivers/usb/musb-new/Kconfig"
> diff --git a/drivers/usb/mtu3/Kconfig b/drivers/usb/mtu3/Kconfig
> new file mode 100644
> index 0000000..66651ad
> --- /dev/null
> +++ b/drivers/usb/mtu3/Kconfig
> @@ -0,0 +1,45 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# For MTK USB3.0 IP
> +
> +config USB_MTU3
> +       bool "MediaTek USB3 Dual Role controller"
> +       depends on USB || USB_GADGET
> +       depends on ARCH_MEDIATEK
> +       help
> +         Say Y here if your system runs on MediaTek SoCs with
> +         Dual Role SuperSpeed USB controller. You can select usb
> +         mode as peripheral role or host role.
> +
> +         If you don't know what this is, please say N.
> +
> +if USB_MTU3
> +choice
> +       bool "MTU3 Mode Selection"
> +       default USB_MTU3_GADGET if USB_GADGET
> +       default USB_MTU3_HOST if (USB && !USB_GADGET)
> +
> +config USB_MTU3_HOST
> +       bool "Host only mode"
> +       depends on USB=y || USB=USB_MTU3

Is this Kconfig grammer supported by U-Boot?

> +       select USB_XHCI_HCD
> +       help
> +         Select this when you want to use MTU3 in host mode only,
> +         thereby the gadget feature will be regressed.
> +
> +config USB_MTU3_GADGET
> +       bool "Gadget only mode"
> +       depends on USB_GADGET=y || USB_GADGET=USB_MTU3
> +       select USB_GADGET_DUALSPEED
> +       help
> +         Select this when you want to use MTU3 in gadget mode only,
> +         thereby the host feature will be regressed.
> +
> +endchoice
> +
> +config USB_MTU3_DEBUG
> +       bool "Enable Debugging Messages"
> +       help
> +         Say Y here to enable debugging messages in the MTU3 Driver.
> +
> +endif
> diff --git a/drivers/usb/mtu3/Makefile b/drivers/usb/mtu3/Makefile
> new file mode 100644
> index 0000000..234f3a3
> --- /dev/null
> +++ b/drivers/usb/mtu3/Makefile
> @@ -0,0 +1,11 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +ccflags-$(CONFIG_USB_MTU3_DEBUG)       += -DDEBUG
> +
> +obj-$(CONFIG_USB_MTU3) += mtu3.o
> +
> +mtu3-y := mtu3_plat.o
> +
> +obj-$(CONFIG_USB_MTU3_GADGET)  += mtu3_core.o mtu3_gadget_ep0.o mtu3_gadget.o
> +obj-$(CONFIG_USB_MTU3_GADGET)  += mtu3_qmu.o
> +obj-$(CONFIG_USB_MTU3_HOST)    += mtu3_host.o

[snip]

Regards,
Bin


More information about the U-Boot mailing list