Skip to contentSkip to conversation

Add support MediaTek USB3 DRD driver

PATCH Superseded Chunfeng Yun 3 participants 29 messages Sep 18, 2020 – Oct 14, 2020

Subsystems (5)
Arm (32-bit) USB Kbuild Arm MediaTek +1 more subsystems

v7 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Chunfeng Yun

author maintainer
#0 lore raw

v7 cover Add support MediaTek USB3 DRD driver

These patches introduce the MediaTek USB3 Dual-Role Controller driver.
The driver can be configured as Peripheral only and Host only(xHCI) modes, and it's ported from Linux Kernel 5.8-rc1

v7 changes
1. use xhci quirk flag XHCI_MTK_HOST

v6 changes
1. modify commit message of [4/10]

v5 changes:
1. change condition of readl_poll_timeout() when check clocks
2. add xhci-mtk.c and myself as maintainer for MTK USB

v4 changes:
1. [4/10], [9/10] and [10/10] are new patches
2. add a glue driver
3. add host driver and rebuild host flow
4. support force_vbus mode for device
5. update bindings to support glue driver

v3 changes:
1. add patch [5/7]
2. add udc_set_speed()
3. simplify some code flow

v2 changes:
1. simplify QMU operations

Chunfeng Yun (10):
dt-binding: usb: add bindings for some common properties
dt-bindings: usb: mtu3: add bindings for MediaTek USB3 DRD
usb: add USB_SPEED_SUPER_PLUS
usb: common: add define of usb_speed_string()
usb: add MediaTek USB3 DRD driver
usb: gadget: Add bcdDevice for the MTU3 USB Gadget Controller
arm: dts: mt8512: add usb related nodes
configs: mt8512: enable fastboot
configs: mt8512: add USB host related configs
MAINTAINERS: add USB driver to ARM MEDIATEK

 MAINTAINERS                                    |   3 +
 Makefile                                       |   1 +
 arch/arm/dts/mt8512-bm1-emmc.dts               |  34 +
 arch/arm/dts/mt8512.dtsi                       |  49 +-
 configs/mt8512_bm1_emmc_defconfig              |  26 +
 doc/device-tree-bindings/usb/generic.txt       |  31 +
 doc/device-tree-bindings/usb/mediatek,mtu3.txt |  79 +++
 drivers/usb/Kconfig                            |   2 +
 drivers/usb/common/common.c                    |   8 +
 drivers/usb/gadget/gadget_chips.h              |   8 +
 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 +
 include/linux/usb/ch9.h                        |   5 +-
 23 files changed, 4794 insertions(+), 5 deletions(-)
 create mode 100644 doc/device-tree-bindings/usb/generic.txt
 create mode 100644 doc/device-tree-bindings/usb/mediatek,mtu3.txt
 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
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v7 1/10 dt-binding: usb: add bindings for some common properties

Add bindings for common properties, include maximum-speed, dr_mode and phy_type

---
v2~v7: no changes

---
 doc/device-tree-bindings/usb/generic.txt | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/generic.txt
doc/device-tree-bindings/usb/generic.txt new file +31 -0
new file mode 100644
index 0000000..a02a198
@@ -0,0 +1,31 @@
+Generic USB Properties
+
+Optional properties:
+ - maximum-speed: tells USB controllers we want to work up to a certain
+			speed. Valid arguments are "super-speed-plus",
+			"super-speed", "high-speed", "full-speed" and
+			"low-speed". In case this isn't passed via DT, USB
+			controllers should default to their maximum HW
+			capability.
+ - dr_mode: tells Dual-Role USB controllers that we want to work on a
+			particular mode. Valid arguments are "host",
+			"peripheral" and "otg". In case this attribute isn't
+			passed via DT, USB DRD controllers should default to
+			OTG.
+ - phy_type: tells USB controllers that we want to configure the core to support
+			a UTMI+ PHY with an 8- or 16-bit interface if UTMI+ is
+			selected. Valid arguments are "utmi" and "utmi_wide".
+			In case this isn't passed via DT, USB controllers should
+			default to HW capability.
+
+This is an attribute to a USB controller such as:
+
+dwc3 at 4a030000 {
+	compatible = "synopsys,dwc3";
+	reg = <0x4a030000 0xcfff>;
+	interrupts = <0 92 4>
+	usb-phy = <&usb2_phy>, <&usb3,phy>;
+	maximum-speed = "super-speed";
+	dr_mode = "otg";
+	phy_type = "utmi_wide";
+};
Signature · 1 line
1.9.1
#2 lore raw

PATCH v7 1/10 dt-binding: usb: add bindings for some common properties

Quoted 4 lines · Chunfeng Yun

Add bindings for common properties, include maximum-speed, dr_mode and phy_type

Quoted 8 lines

---
v2~v7: no changes

---
 doc/device-tree-bindings/usb/generic.txt | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/generic.txt
author maintainer
#3 lore raw

PATCH v7 2/10 dt-bindings: usb: mtu3: add bindings for MediaTek USB3 DRD

In reply to Chunfeng Yun

Add dt-binding for MediaTek USB3 DRD Driver

---
v5~v7: no changes

v4:
Add support host mode, introduce some new properties and subnode

v2~v3: no changes

---
 doc/device-tree-bindings/usb/mediatek,mtu3.txt | 79 ++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/mediatek,mtu3.txt
doc/device-tree-bindings/usb/mediatek,mtu3.txt new file +79 -0
new file mode 100644
index 0000000..ab877bf
@@ -0,0 +1,79 @@
+The device node for Mediatek USB3 DRD controller
+
+Required properties:
+ - compatible : should be "mediatek,<soc-model>-mtu3", "mediatek,mtu3",
+	soc-model is the name of SoC, such as mt8512 etc,
+	when using "mediatek,mtu3" compatible string, you need SoC specific
+	ones in addition, one of:
+	- "mediatek,mt8512-mtu3"
+ - reg : specifies physical base address and size of the registers
+ - reg-names: should be
+	- "ippc" : IP Port Control
+ - power-domains : a phandle to USB power domain node to control USB's MTCMOS
+ - clocks : a list of phandle + clock-specifier pairs, one for each
+	entry in clock-names
+ - clock-names : must contain "sys_ck" for clock of controller,
+	the following clocks are optional:
+	"ref_ck", "mcu_ck", "dma_ck" and "xhci_ck";
+ - phys : list of all the USB PHYs on this HCD
+ - #address-cells, #size-cells : used for sub-nodes with 'reg' property
+ - ranges : allows valid 1:1 translation between child's address space and
+	parent's address space
+
+Optional properties:
+ - vusb33-supply : regulator of USB AVDD3.3v
+ - vbus-supply : regulator of VBUS 5v, needed when supports host mode.
+
+Sub-nodes:
+Required properties:
+ - compatible : should be "mediatek,ssusb"
+ - reg : specifies physical base address and size of the registers
+ - reg-names: should be
+	- "mac" : SSUSB MAC, include xHCI and device
+ - interrupts : interrupt used by xHCI or device
+ - dr_mode : should be one of "host" or "peripheral",
+	see : usb/generic.txt
+
+Optional properties:
+ - pinctrl-names : a pinctrl state named "default" is optional
+ - pinctrl-0 : pin control group
+	See: pinctrl/pinctrl-bindings.txt
+
+ - device mode:
+   - maximum-speed : valid arguments are "full-speed", "high-speed",
+	"super-speed" and "super-speed-plus",
+	see: usb/generic.txt
+   - mediatek,force-vbus : force vbus as valid by SW
+
+ - host mode (dr_mode is "host"):
+   - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
+	bit1 for u3port1, ... etc;
+
+Example:
+usb3: usb at 11213e00 {
+	compatible = "mediatek,mt8512-mtu3", "mediatek,mtu3";
+	reg = <0x11213e00 0x0100>;
+	reg-names = "ippc";
+	phys = <&u2port0 PHY_TYPE_USB2>, <&u2port1 PHY_TYPE_USB2>;
+	power-domains = <&scpsys MT8512_POWER_DOMAIN_USB>;
+	clocks = <&infracfg CLK_INFRA_USB_SYS>,
+		 <&topckgen CLK_TOP_SSUSB_TOP_CK_EN>,
+		 <&infracfg CLK_INFRA_ICUSB>;
+	clock-names = "sys_ck", "ref_ck", "mcu_ck";
+	vusb33-supply = <reg_3p3v>;
+	vbus-supply = <&usb_p0_vbus>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+	ranges;
+	status = "disabled";
+
+	ssusb: usb at 11210000 {
+		compatible = "mediatek,ssusb";
+		reg = <0x11210000 0x3e00>;
+		interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_LOW>;
+		reg-names = "mac";
+		dr_mode = "peripheral";
+		maximum-speed = "high-speed";
+		status = "disabled";
+	};
+};
Signature · 1 line
1.9.1
#4 lore raw

PATCH v7 2/10 dt-bindings: usb: mtu3: add bindings for MediaTek USB3 DRD

Quoted 2 lines · Chunfeng Yun

Add dt-binding for MediaTek USB3 DRD Driver

There are some differences compared to the one in the Linux kernel:
https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/usb/mediatek%2Cmtu3.txt

Please specify which kernel commit id the device bindings are referenced here.

Quoted 5 lines

---
v5~v7: no changes

Quoted 9 lines

v4:
Add support host mode, introduce some new properties and subnode

v2~v3: no changes

---
 doc/device-tree-bindings/usb/mediatek,mtu3.txt | 79 ++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/mediatek,mtu3.txt

Regards,
Bin

author maintainer
#5 lore raw

PATCH v7 2/10 dt-bindings: usb: mtu3: add bindings for MediaTek USB3 DRD

Quoted 5 lines · Bin Meng
Quoted 2 lines · Chunfeng Yun

Add dt-binding for MediaTek USB3 DRD Driver

There are some differences compared to the one in the Linux kernel:

Some properties are removed due to dual-role switch is not supported in Uboot.

Quoted 3 lines

https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/usb/mediatek%2Cmtu3.txt

Please specify which kernel commit id the device bindings are referenced here.

Ok, will add it in next version

Thanks

Quoted 18 lines
Quoted 6 lines

---
v5~v7: no changes

Quoted 9 lines

v4:
Add support host mode, introduce some new properties and subnode

v2~v3: no changes

---
 doc/device-tree-bindings/usb/mediatek,mtu3.txt | 79 ++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/mediatek,mtu3.txt

Regards,
Bin

author maintainer
#6 lore raw

PATCH v7 3/10 usb: add USB_SPEED_SUPER_PLUS

In reply to Chunfeng Yun

Add enum USB_SPEED_SUPER_PLUS for USB3.1

---
v5~v7: no changes

v4: also add it into speed_names array

v2~v3: no changes

---
 drivers/usb/common/common.c | 1 +
 include/linux/usb/ch9.h     | 1 +
 2 files changed, 2 insertions(+)
drivers/usb/common/common.c +1 -0
index d4ae186..76f5a9c 100644
@@ -46,6 +46,7 @@ static const char *const speed_names[] = {
 	[USB_SPEED_HIGH] = "high-speed",
 	[USB_SPEED_WIRELESS] = "wireless",
 	[USB_SPEED_SUPER] = "super-speed",
+	[USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
 enum usb_device_speed usb_get_maximum_speed(ofnode node)
include/linux/usb/ch9.h +1 -0
index 989a5fc..7d225ee 100644
@@ -956,6 +956,7 @@ enum usb_device_speed {
 	USB_SPEED_HIGH,				/* usb 2.0 */
 	USB_SPEED_WIRELESS,			/* wireless (usb 2.5) */
 	USB_SPEED_SUPER,			/* usb 3.0 */
+	USB_SPEED_SUPER_PLUS,			/* usb 3.1 */
 };
 
 #ifdef __KERNEL__
Signature · 1 line
1.9.1
#7 lore raw

PATCH v7 3/10 usb: add USB_SPEED_SUPER_PLUS

Quoted 32 lines · Chunfeng Yun

Add enum USB_SPEED_SUPER_PLUS for USB3.1

---
v5~v7: no changes

v4: also add it into speed_names array

v2~v3: no changes

---
 drivers/usb/common/common.c | 1 +
 include/linux/usb/ch9.h     | 1 +
 2 files changed, 2 insertions(+)
drivers/usb/common/common.c +1 -0
index d4ae186..76f5a9c 100644
@@ -46,6 +46,7 @@ static const char *const speed_names[] = {
        [USB_SPEED_HIGH] = "high-speed",
        [USB_SPEED_WIRELESS] = "wireless",
        [USB_SPEED_SUPER] = "super-speed",
+       [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
 enum usb_device_speed usb_get_maximum_speed(ofnode node)
include/linux/usb/ch9.h +0 -0
index 989a5fc..7d225ee 100644

include/linux/usb/ch9.h enum usb_device_speed { · line 962

Quoted 7 lines
include/linux/usb/ch9.h +1 -0
@@ -956,6 +956,7 @@ enum usb_device_speed {
        USB_SPEED_HIGH,                         /* usb 2.0 */
        USB_SPEED_WIRELESS,                     /* wireless (usb 2.5) */
        USB_SPEED_SUPER,                        /* usb 3.0 */
+       USB_SPEED_SUPER_PLUS,                   /* usb 3.1 */
 };
 
 #ifdef __KERNEL__

Should we add usb 3.2 as well?

author maintainer
#8 lore raw

PATCH v7 3/10 usb: add USB_SPEED_SUPER_PLUS

Quoted 39 lines · Bin Meng
Quoted 38 lines · Chunfeng Yun

Add enum USB_SPEED_SUPER_PLUS for USB3.1

---
v5~v7: no changes

v4: also add it into speed_names array

v2~v3: no changes

---
 drivers/usb/common/common.c | 1 +
 include/linux/usb/ch9.h     | 1 +
 2 files changed, 2 insertions(+)
drivers/usb/common/common.c +1 -0
index d4ae186..76f5a9c 100644
@@ -46,6 +46,7 @@ static const char *const speed_names[] = {
        [USB_SPEED_HIGH] = "high-speed",
        [USB_SPEED_WIRELESS] = "wireless",
        [USB_SPEED_SUPER] = "super-speed",
+       [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
 enum usb_device_speed usb_get_maximum_speed(ofnode node)
include/linux/usb/ch9.h +1 -0
index 989a5fc..7d225ee 100644
@@ -956,6 +956,7 @@ enum usb_device_speed {
        USB_SPEED_HIGH,                         /* usb 2.0 */
        USB_SPEED_WIRELESS,                     /* wireless (usb 2.5) */
        USB_SPEED_SUPER,                        /* usb 3.0 */
+       USB_SPEED_SUPER_PLUS,                   /* usb 3.1 */
 };
 
Quoted 3 lines

include/linux/usb/ch9.h enum usb_device_speed { · line 962

Quoted 1 line
include/linux/usb/ch9.h +0 -0
 #ifdef __KERNEL__

Should we add usb 3.2 as well?

I found the patches to support USB3.2 are still in public review for Linux kernel, so no need support it currently

Quoted 2 lines
author maintainer
#9 lore raw

PATCH v7 4/10 usb: common: add define of usb_speed_string()

In reply to Chunfeng Yun

There is only declaration of usb_speed_string(), but no definition, so add it to avoid build error when call it.

---
v7: no changes

v6: modify commit message suggested by Roger

v5: no changes

v4: new patch

---
 drivers/usb/common/common.c | 7 +++++++
 include/linux/usb/ch9.h     | 4 ----
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/usb/common/common.c +7 -0
index 76f5a9c..5e5c3c3 100644
@@ -49,6 +49,13 @@ static const char *const speed_names[] = {
 	[USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
+const char *usb_speed_string(enum usb_device_speed speed)
+{
+	if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
+		speed = USB_SPEED_UNKNOWN;
+	return speed_names[speed];
+}
+
 enum usb_device_speed usb_get_maximum_speed(ofnode node)
 {
 	const char *max_speed;
include/linux/usb/ch9.h +0 -4
index 7d225ee..a8fa5d7 100644
@@ -959,8 +959,6 @@ enum usb_device_speed {
 	USB_SPEED_SUPER_PLUS,			/* usb 3.1 */
 };
 
-#ifdef __KERNEL__
-
 /**
  * usb_speed_string() - Returns human readable-name of the speed.
  * @speed: The speed to return human-readable name for.  If it's not
@@ -969,8 +967,6 @@ enum usb_device_speed {
  */
 extern const char *usb_speed_string(enum usb_device_speed speed);
 
-#endif
-
 enum usb_device_state {
 	/* NOTATTACHED isn't in the USB spec, and this state acts
 	 * the same as ATTACHED ... but it's clearer this way.
Signature · 1 line
1.9.1
#10 lore raw

PATCH v7 4/10 usb: common: add define of usb_speed_string()

Quoted 10 lines · Chunfeng Yun

There is only declaration of usb_speed_string(), but no definition, so add it to avoid build error when call it.

---
v7: no changes

v6: modify commit message suggested by Roger

Quoted 8 lines

v5: no changes

v4: new patch

---
 drivers/usb/common/common.c | 7 +++++++
 include/linux/usb/ch9.h     | 4 ----
 2 files changed, 7 insertions(+), 4 deletions(-)
author maintainer
#11 lore raw

PATCH v7 5/10 usb: add MediaTek USB3 DRD driver

In reply to Chunfeng Yun

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.

---
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
Makefile +1 -0
index 7a05fc7..2dcc41a 100644
@@ -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/
drivers/usb/Kconfig +2 -0
index 34881a1..fedc013 100644
@@ -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"
drivers/usb/mtu3/Kconfig new file +45 -0

45 lines not on this page · raw message

drivers/usb/mtu3/Makefile new file +11 -0
new file mode 100644
index 0000000..234f3a3
@@ -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
drivers/usb/mtu3/mtu3.h new file +423 -0

423 lines not on this page · raw message

drivers/usb/mtu3/mtu3_core.c new file +838 -0

838 lines not on this page · raw message

drivers/usb/mtu3/mtu3_dr.h new file +52 -0

52 lines not on this page · raw message

drivers/usb/mtu3/mtu3_gadget.c new file +686 -0

686 lines not on this page · raw message

drivers/usb/mtu3/mtu3_gadget_ep0.c new file +933 -0

930 lines not on this page · raw message

drivers/usb/mtu3/mtu3_host.c new file +141 -0

141 lines not on this page · raw message

drivers/usb/mtu3/mtu3_hw_regs.h new file +515 -0

515 lines not on this page · raw message

drivers/usb/mtu3/mtu3_plat.c new file +368 -0

368 lines not on this page · raw message

drivers/usb/mtu3/mtu3_qmu.c new file +504 -0

504 lines not on this page · raw message

drivers/usb/mtu3/mtu3_qmu.h new file +37 -0
new file mode 100644
index 0000000..ba8a3aa

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.1

Part of the diff is not shown here. View the raw message.

#12 lore raw

PATCH v7 5/10 usb: add MediaTek USB3 DRD driver

Quoted 6 lines · Chunfeng Yun

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.

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

Quoted 94 lines

---
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
Makefile +1 -0
index 7a05fc7..2dcc41a 100644
@@ -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/
drivers/usb/Kconfig +2 -0
index 34881a1..fedc013 100644
@@ -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"
drivers/usb/mtu3/Kconfig new file +14 -0
new file mode 100644
index 0000000..66651ad
@@ -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.

drivers/usb/mtu3/Kconfig line 24

Quoted 10 lines
drivers/usb/mtu3/Kconfig new file +10 -0
+
+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?

Quoted 28 lines
drivers/usb/mtu3/Kconfig new file +21 -0
+       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
drivers/usb/mtu3/Makefile new file +1 -0
new file mode 100644
index 0000000..234f3a3
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0

drivers/usb/mtu3/Makefile line 11

Quoted 10 lines
drivers/usb/mtu3/Makefile new file +10 -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

author maintainer
#13 lore raw

PATCH v7 5/10 usb: add MediaTek USB3 DRD driver

Quoted 10 lines · Bin Meng
Quoted 6 lines · Chunfeng Yun

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.

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

It's good enough, I and my workmate will test the function

Quoted 99 lines
Quoted 99 lines

---
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
Makefile +1 -0
index 7a05fc7..2dcc41a 100644
@@ -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/
drivers/usb/Kconfig +2 -0
index 34881a1..fedc013 100644
@@ -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"
drivers/usb/mtu3/Kconfig new file +18 -0
new file mode 100644
index 0000000..66651ad
@@ -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"
Quoted 8 lines

drivers/usb/mtu3/Kconfig line 24

Quoted 6 lines
drivers/usb/mtu3/Kconfig new file +6 -0
+       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?

Yes, no error happens when use menuconfig, but can be simplified, I modify it.

Thanks a lot

Quoted 44 lines
Quoted 29 lines
drivers/usb/mtu3/Kconfig new file +21 -0
+       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
drivers/usb/mtu3/Makefile new file +1 -0
new file mode 100644
index 0000000..234f3a3
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0

drivers/usb/mtu3/Makefile line 11

Quoted 10 lines
drivers/usb/mtu3/Makefile new file +10 -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

author maintainer
#14 lore raw

PATCH v7 6/10 usb: gadget: Add bcdDevice for the MTU3 USB Gadget Controller

In reply to Chunfeng Yun

Add an entry in usb_gadget_controller_number() for the MTU3 gadget controller. It is used to bind the USB Ethernet driver.

---
v4~v7: no changes

v3: new patch

---
 drivers/usb/gadget/gadget_chips.h | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/gadget/gadget_chips.h +8 -0
index 587204c..0cdf47c 100644
@@ -161,6 +161,12 @@
 #define gadget_is_max3420(g)        0
 #endif
 
+#ifdef CONFIG_USB_MTU3_GADGET
+#define gadget_is_mtu3(g)        (!strcmp("mtu3-gadget", (g)->name))
+#else
+#define gadget_is_mtu3(g)        0
+#endif
+
 /**
  * usb_gadget_controller_number - support bcdDevice id convention
  * @gadget: the controller being driven
@@ -224,5 +230,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
 		return 0x24;
 	else if (gadget_is_max3420(gadget))
 		return 0x25;
+	else if (gadget_is_mtu3(gadget))
+		return 0x26;
 	return -ENOENT;
 }
Signature · 1 line
1.9.1
#15 lore raw

PATCH v7 6/10 usb: gadget: Add bcdDevice for the MTU3 USB Gadget Controller

Quoted 4 lines · Chunfeng Yun

Add an entry in usb_gadget_controller_number() for the MTU3 gadget controller. It is used to bind the USB Ethernet driver.

Quoted 9 lines

---
v4~v7: no changes

v3: new patch

---
 drivers/usb/gadget/gadget_chips.h | 8 ++++++++
 1 file changed, 8 insertions(+)
author maintainer
#16 lore raw

PATCH v7 7/10 arm: dts: mt8512: add usb related nodes

In reply to Chunfeng Yun

Add usb, usb phy, and fixed regulators nodes

---
v5~v7: no changes

v4: add host related properties, add subnode.

v3: remove unused property mediatek,discth

v2: no changes

---
 arch/arm/dts/mt8512-bm1-emmc.dts | 34 ++++++++++++++++++++++++++++
 arch/arm/dts/mt8512.dtsi         | 49 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 82 insertions(+), 1 deletion(-)
arch/arm/dts/mt8512-bm1-emmc.dts +34 -0
index 296ed93..12511b5 100644
@@ -43,6 +43,25 @@
 		regulator-boot-on;
 		regulator-always-on;
 	};
+
+	usb_p0_vbus: regulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "p0_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 27 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+
+	usb_p1_vbus: regulator at 1 {
+		compatible = "regulator-fixed";
+		regulator-name = "p1_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 32 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		regulator-always-on;
+	};
 };
 
 &mmc0 {
@@ -95,6 +114,21 @@
 		};
 };
 
+&ssusb {
+	dr_mode = "peripheral";
+	maximum-speed = "high-speed";
+	status = "okay";
+};
+
+&usb3 {
+	vbus-supply = <&usb_p0_vbus>;
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pins>;
arch/arm/dts/mt8512.dtsi +48 -1

65 lines not on this page · raw message

Signature · 1 line
1.9.1
#17 lore raw

PATCH v7 7/10 arm: dts: mt8512: add usb related nodes

Quoted 9 lines · Chunfeng Yun

Add usb, usb phy, and fixed regulators nodes

---
v5~v7: no changes

v4: add host related properties, add subnode.

Quoted 8 lines

v3: remove unused property mediatek,discth

v2: no changes

---
 arch/arm/dts/mt8512-bm1-emmc.dts | 34 ++++++++++++++++++++++++++++
 arch/arm/dts/mt8512.dtsi         | 49 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 82 insertions(+), 1 deletion(-)

LGTM

author maintainer
#18 lore raw

PATCH v7 8/10 configs: mt8512: enable fastboot

In reply to Chunfeng Yun

Enable fastboot to support download image from usb, also enable usb related drivers, such as usb phy etc.

---
v2~v7: no changes

---
 configs/mt8512_bm1_emmc_defconfig | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
configs/mt8512_bm1_emmc_defconfig +19 -0
index 950507f..d41446f 100644
@@ -9,6 +9,7 @@ CONFIG_DM_GPIO=y
 CONFIG_TARGET_MT8512=y
 CONFIG_DEFAULT_DEVICE_TREE="mt8512-bm1-emmc"
 CONFIG_FIT=y
+CONFIG_EFI_PARTITION=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_DEFAULT_FDT_FILE="mt8512-bm1-emmc.dtb"
 CONFIG_SYS_PROMPT="MT8512> "
@@ -26,6 +27,15 @@ CONFIG_PINCONF=y
 CONFIG_PINCTRL_MT8512=y
 CONFIG_RAM=y
 CONFIG_BAUDRATE=921600
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x56000000
+CONFIG_FASTBOOT_BUF_SIZE=0x1e00000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_DM_REGULATOR=y
 CONFIG_DM_SERIAL=y
 CONFIG_MTK_SERIAL=y
 CONFIG_TIMER=y
@@ -33,3 +43,12 @@ CONFIG_MTK_TIMER=y
 CONFIG_WDT=y
 CONFIG_WDT_MTK=y
 CONFIG_LZO=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_MTU3=y
+CONFIG_USB_MTU3_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="MediaTek"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d
+CONFIG_USB_GADGET_PRODUCT_NUM=0x201c
Signature · 1 line
1.9.1
author maintainer
#19 lore raw

PATCH v7 9/10 configs: mt8512: add USB host related configs

In reply to Chunfeng Yun

Add USB, FAT commands, and fixed regulator, mass storage drivers.
Due to device mode is enabled by default, comment out the host mode config here.

---
v5~v7: no changes

v4: new patch

---
 configs/mt8512_bm1_emmc_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
configs/mt8512_bm1_emmc_defconfig +7 -0
index d41446f..6b5454c 100644
@@ -15,6 +15,10 @@ CONFIG_DEFAULT_FDT_FILE="mt8512-bm1-emmc.dtb"
 CONFIG_SYS_PROMPT="MT8512> "
 CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_ENV_OVERWRITE=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
@@ -36,6 +40,7 @@ CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
 CONFIG_PHY=y
 CONFIG_PHY_MTK_TPHY=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_SERIAL=y
 CONFIG_MTK_SERIAL=y
 CONFIG_TIMER=y
@@ -48,6 +53,8 @@ CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
 CONFIG_USB_MTU3=y
 CONFIG_USB_MTU3_GADGET=y
+#CONFIG_USB_MTU3_HOST=y
+CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="MediaTek"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d
Signature · 1 line
1.9.1
#20 lore raw

PATCH v7 9/10 configs: mt8512: add USB host related configs

Quoted 5 lines · Chunfeng Yun

Add USB, FAT commands, and fixed regulator, mass storage drivers.
Due to device mode is enabled by default, comment out the host mode config here.

This patch should be squashed into patch [08/10]

Quoted 34 lines

---
v5~v7: no changes

v4: new patch

---
 configs/mt8512_bm1_emmc_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
configs/mt8512_bm1_emmc_defconfig +5 -0
index d41446f..6b5454c 100644
@@ -15,6 +15,10 @@ CONFIG_DEFAULT_FDT_FILE="mt8512-bm1-emmc.dtb"
 CONFIG_SYS_PROMPT="MT8512> "
 CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_ENV_OVERWRITE=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
@@ -36,6 +40,7 @@ CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
 CONFIG_PHY=y
 CONFIG_PHY_MTK_TPHY=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_SERIAL=y
 CONFIG_MTK_SERIAL=y
 CONFIG_TIMER=y

configs/mt8512_bm1_emmc_defconfig CONFIG_DM_USB=y · line 56

Quoted 4 lines
configs/mt8512_bm1_emmc_defconfig +1 -0
@@ -48,6 +53,8 @@ CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
 CONFIG_USB_MTU3=y
 CONFIG_USB_MTU3_GADGET=y
+#CONFIG_USB_MTU3_HOST=y

This should be :

# CONFIG_USB_MTU3_HOST is not set

configs/mt8512_bm1_emmc_defconfig CONFIG_DM_USB=y

Quoted 5 lines
configs/mt8512_bm1_emmc_defconfig +1 -1
+CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="MediaTek"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d
--

Regards,
Bin

author maintainer
#21 lore raw

PATCH v7 9/10 configs: mt8512: add USB host related configs

Quoted 8 lines · Bin Meng
Quoted 5 lines · Chunfeng Yun

Add USB, FAT commands, and fixed regulator, mass storage drivers.
Due to device mode is enabled by default, comment out the host mode config here.

This patch should be squashed into patch [08/10]

Ok

Quoted 42 lines
Quoted 35 lines

---
v5~v7: no changes

v4: new patch

---
 configs/mt8512_bm1_emmc_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
configs/mt8512_bm1_emmc_defconfig +5 -0
index d41446f..6b5454c 100644
@@ -15,6 +15,10 @@ CONFIG_DEFAULT_FDT_FILE="mt8512-bm1-emmc.dtb"
 CONFIG_SYS_PROMPT="MT8512> "
 CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_ENV_OVERWRITE=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
@@ -36,6 +40,7 @@ CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
 CONFIG_PHY=y
 CONFIG_PHY_MTK_TPHY=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_SERIAL=y
 CONFIG_MTK_SERIAL=y
 CONFIG_TIMER=y

configs/mt8512_bm1_emmc_defconfig CONFIG_DM_USB=y · line 56

Quoted 4 lines
configs/mt8512_bm1_emmc_defconfig +1 -0
@@ -48,6 +53,8 @@ CONFIG_DM_USB=y
 CONFIG_DM_USB_GADGET=y
 CONFIG_USB_MTU3=y
 CONFIG_USB_MTU3_GADGET=y
+#CONFIG_USB_MTU3_HOST=y

This should be :

Quoted 1 line

# CONFIG_USB_MTU3_HOST is not set

Will modify it.

Thanks a lot

Quoted 9 lines

configs/mt8512_bm1_emmc_defconfig CONFIG_DM_USB=y

Quoted 6 lines
configs/mt8512_bm1_emmc_defconfig +1 -1
+CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="MediaTek"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d
--

Regards,
Bin

author maintainer
#22 lore raw

PATCH v7 10/10 MAINTAINERS: add USB driver to ARM MEDIATEK

In reply to Chunfeng Yun

Add MediaTek USB3 Dual-Role controller driver to ARM MEDIATEK, and add myself as a maintainer for it.

---
v6~v7: no changes

v5: add mtu3/, xhci-mtk.c, and myself as maintainer for MTK USB

v4: new patch

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
index 7e46470..08724f8 100644
@@ -262,6 +262,7 @@ F:	arch/arm/include/asm/arch-pxa/
 ARM MEDIATEK
 M:	Ryder Lee <[email protected]>
 M:	Weijie Gao <[email protected]>
+M:	Chunfeng Yun <[email protected]>
 R:	GSS_MTK_Uboot_upstream <[email protected]>
 S:	Maintained
 F:	arch/arm/mach-mediatek/
@@ -278,6 +279,8 @@ F:	drivers/power/domain/mtk-power-domain.c
 F:	drivers/ram/mediatek/
 F:	drivers/spi/mtk_snfi_spi.c
 F:	drivers/timer/mtk_timer.c
+F:	drivers/usb/host/xhci-mtk.c
+F:	drivers/usb/mtu3/
 F:	drivers/watchdog/mtk_wdt.c
 F:	drivers/net/mtk_eth.c
 F:	drivers/reset/reset-mediatek.c
Signature · 1 line
1.9.1
#23 lore raw

PATCH v7 10/10 MAINTAINERS: add USB driver to ARM MEDIATEK

Quoted 8 lines · Chunfeng Yun

Add MediaTek USB3 Dual-Role controller driver to ARM MEDIATEK, and add myself as a maintainer for it.

---
v6~v7: no changes

Quoted 7 lines

v5: add mtu3/, xhci-mtk.c, and myself as maintainer for MTK USB

v4: new patch

---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)
author maintainer
#24 lore raw

v7 cover Add support MediaTek USB3 DRD driver

In reply to Chunfeng Yun

Hi Marek, Lukasz

Any comments on this patch series?

Thanks a lot

Quoted 81 lines · Chunfeng Yun

These patches introduce the MediaTek USB3 Dual-Role Controller driver.
The driver can be configured as Peripheral only and Host only(xHCI) modes, and it's ported from Linux Kernel 5.8-rc1

v7 changes
1. use xhci quirk flag XHCI_MTK_HOST

v6 changes
1. modify commit message of [4/10]

v5 changes:
1. change condition of readl_poll_timeout() when check clocks
2. add xhci-mtk.c and myself as maintainer for MTK USB

v4 changes:
1. [4/10], [9/10] and [10/10] are new patches
2. add a glue driver
3. add host driver and rebuild host flow
4. support force_vbus mode for device
5. update bindings to support glue driver

v3 changes:
1. add patch [5/7]
2. add udc_set_speed()
3. simplify some code flow

v2 changes:
1. simplify QMU operations

Chunfeng Yun (10):
dt-binding: usb: add bindings for some common properties
dt-bindings: usb: mtu3: add bindings for MediaTek USB3 DRD
usb: add USB_SPEED_SUPER_PLUS
usb: common: add define of usb_speed_string()
usb: add MediaTek USB3 DRD driver
usb: gadget: Add bcdDevice for the MTU3 USB Gadget Controller
arm: dts: mt8512: add usb related nodes
configs: mt8512: enable fastboot
configs: mt8512: add USB host related configs
MAINTAINERS: add USB driver to ARM MEDIATEK

 MAINTAINERS                                    |   3 +
 Makefile                                       |   1 +
 arch/arm/dts/mt8512-bm1-emmc.dts               |  34 +
 arch/arm/dts/mt8512.dtsi                       |  49 +-
 configs/mt8512_bm1_emmc_defconfig              |  26 +
 doc/device-tree-bindings/usb/generic.txt       |  31 +
 doc/device-tree-bindings/usb/mediatek,mtu3.txt |  79 +++
 drivers/usb/Kconfig                            |   2 +
 drivers/usb/common/common.c                    |   8 +
 drivers/usb/gadget/gadget_chips.h              |   8 +
 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 +
 include/linux/usb/ch9.h                        |   5 +-
 23 files changed, 4794 insertions(+), 5 deletions(-)
 create mode 100644 doc/device-tree-bindings/usb/generic.txt
 create mode 100644 doc/device-tree-bindings/usb/mediatek,mtu3.txt
 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
#25 lore raw

v7 cover Add support MediaTek USB3 DRD driver

On 9/28/20 4:01 AM, Chunfeng Yun wrote:
[...]

Quoted 9 lines
Quoted 9 lines
 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

Since this is USB3 driver, you want this reviewed by Bin

author maintainer
#26 lore raw

v7 cover Add support MediaTek USB3 DRD driver

Hi Marek,

Quoted 12 lines · Marek Vasut

On 9/28/20 4:01 AM, Chunfeng Yun wrote:
[...]

Quoted 9 lines
Quoted 9 lines
 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
Quoted 1 line

Since this is USB3 driver, you want this reviewed by Bin

Got it.

Hi Bin,

Would you please help to review this series?

Thank you Marek and Bin

author maintainer
#27 lore raw

v7 cover Add support MediaTek USB3 DRD driver

In reply to Marek Vasut

Hi Bin,

Gentle ping...

Could you help to review this series?

Thanks a lot

Quoted 13 lines · Marek Vasut

On 9/28/20 4:01 AM, Chunfeng Yun wrote:
[...]

Quoted 9 lines
Quoted 9 lines
 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

Since this is USB3 driver, you want this reviewed by Bin

#28 lore raw

v7 cover Add support MediaTek USB3 DRD driver

Hi Chunfeng,

Quoted 6 lines · Chunfeng Yun

Hi Bin,

Gentle ping...

Could you help to review this series?

Will have a look soon.

Quoted 19 lines

Thanks a lot

Quoted 13 lines · Marek Vasut

On 9/28/20 4:01 AM, Chunfeng Yun wrote:
[...]

Quoted 9 lines
Quoted 9 lines
 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

Since this is USB3 driver, you want this reviewed by Bin

Regards,
Bin