Skip to contentSkip to conversation

rk3328: add support of usb host and gadget

PATCH Superseded Meng Dongyang 2 participants 25 messages Jun 23, 2017 – Jun 26, 2017

Subsystems (4)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover rk3328: add support of usb host and gadget

Add support of usb host and gadget function for rk3328.

Changed in v7:
- Romove unused variable ‘prop’ in dwc2 driver

Changed in v6:
- Rebase on the newest code of master branch
- Make xhci-rockchip driver depend on DM_REGULATOR and DM_USB
- Remove #ifdef DM_RERULATOR and DM_USB in xhci-rockchip driver
- Use dev_read_boot() instead of fdt_getprop() in dwc2 driver

Changes in v5:
- Propagate return value and print error message when failed

Changes in v4:
- Splite patch [U-boot,v3,04/10] into two patches
- Define set vbus as empty function if the macros aren't set
- Prepare a mask and set capabilities in GUSBCFG register once

Changes in v3:
- Revert change of macro definition in dwc2 driver
- Support host mode without HNP/SRP capability through DTS

Changes in v2:
- Add commit messages
- Split patch [U-boot,7/8] into two patches
- Use fixed regulator to control vbus instead of gpio

Meng Dongyang (8):
usb: Kconfig: config USB_XHCI_ROCKCHIP depends on DM_REGULATOR and
DM_USB
usb: host: xhci-rockchip: use fixed regulator to control vbus
rockchip: dts: rk3328: add fixed regulator node for xhci
rockchip: configs: rk3328: enable dwc2 driver and config fastboot
usb: dwc2: use dev_read_bool() instead of fdt_getprop()
rockchip: rk3328: board: add support of dwc2 gadget
rockchip: dts: rk3328: support and enable dwc2
rockchip: dts: rk3399: control vbus of typec by fixed regulator

 arch/arm/dts/rk3328-evb.dts            | 25 +++++++++++++++++++-
 arch/arm/dts/rk3328.dtsi               | 10 ++++++++
 arch/arm/dts/rk3399-evb.dts            | 16 +++++++++++--
 board/rockchip/evb_rk3328/evb-rk3328.c | 42 ++++++++++++++++++++++++++++++++++
 configs/evb-rk3328_defconfig           | 19 +++++++++++++--
 drivers/usb/host/Kconfig               |  2 ++
 drivers/usb/host/dwc2.c                | 16 +++++--------
 drivers/usb/host/xhci-rockchip.c       | 36 ++++++++++++++---------------
 include/configs/rk3328_common.h        |  3 +++
 9 files changed, 136 insertions(+), 33 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v7 1/8 usb: Kconfig: config USB_XHCI_ROCKCHIP depends on DM_REGULATOR and DM_USB

The xhci-rockchip driver depends on DM_REGULATOR and DM_USB. So add dependent features for xhci-rockchip driver in Kconfig.

---

Changes in v7: None
Changes in v6:
- New patch, add depends on features for xhci-rockchip in Kconfig

 drivers/usb/host/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/host/Kconfig +2 -0
index b824eec..5e07a10 100644
@@ -34,6 +34,8 @@ config USB_XHCI_MVEBU
 config USB_XHCI_ROCKCHIP
 	bool "Support for Rockchip on-chip xHCI USB controller"
 	depends on ARCH_ROCKCHIP
+	depends on DM_REGULATOR
+	depends on DM_USB
 	default y
 	help
 	  Enables support for the on-chip xHCI controller on Rockchip SoCs.
Signature · 1 line
1.9.1
#2 lore raw

PATCH v7 1/8 usb: Kconfig: config USB_XHCI_ROCKCHIP depends on DM_REGULATOR and DM_USB

Quoted 4 lines

The xhci-rockchip driver depends on DM_REGULATOR and DM_USB. So add dependent features for xhci-rockchip driver in Kconfig.

Quoted 9 lines

---

Changes in v7: None
Changes in v6:
- New patch, add depends on features for xhci-rockchip in Kconfig

 drivers/usb/host/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
#3 lore raw

PATCH v7 1/8 usb: Kconfig: config USB_XHCI_ROCKCHIP depends on DM_REGULATOR and DM_USB

In reply to Meng Dongyang
Quoted 5 lines

The xhci-rockchip driver depends on DM_REGULATOR and DM_USB. So add dependent features for xhci-rockchip driver in Kconfig.

Quoted 9 lines

---

Changes in v7: None
Changes in v6:
- New patch, add depends on features for xhci-rockchip in Kconfig

 drivers/usb/host/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
#4 lore raw

PATCH v7 2/8 usb: host: xhci-rockchip: use fixed regulator to control vbus

In reply to Meng Dongyang

Use fixed regulator to control the voltage of vbus. Enable vbus supply when usb start and disable vbus supply when usb stop.

---

Changes in v7: None
Changes in v6:
- Remove #ifdef DM_REGULATOR and DM_USB due to the addition in Kconfig

Changes in v5:
- Propagate the return value of setting VBus and print error when failed

Changes in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't set

Changes in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpio

 drivers/usb/host/xhci-rockchip.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/usb/host/xhci-rockchip.c +18 -18
index c4ae55f..6b4caf9 100644
@@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	 */
 	plat->hcd_base = devfdt_get_addr(dev);
 	if (plat->hcd_base == FDT_ADDR_T_NONE) {
-		debug("Can't get the XHCI register base address\n");
+		error("Can't get the XHCI register base address\n");
 		return -ENXIO;
 	}
 
@@ -62,17 +62,15 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	if (plat->phy_base == FDT_ADDR_T_NONE) {
-		debug("Can't get the usbphy register address\n");
+		error("Can't get the usbphy register address\n");
 		return -ENXIO;
 	}
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
 	/* Vbus regulator */
 	ret = device_get_supply_regulator(dev, "vbus-supply",
 					  &plat->vbus_supply);
 	if (ret)
-		debug("Can't get vbus supply\n");
-#endif
+		debug("Can't get VBus regulator!\n");
 
 	return 0;
 }
@@ -126,7 +124,7 @@ static int rockchip_xhci_core_init(struct rockchip_xhci *rkxhci,
 
 	ret = dwc3_core_init(rkxhci->dwc3_reg);
 	if (ret) {
-		debug("failed to initialize core\n");
+		error("failed to initialize core\n");
 		return ret;
 	}
 
@@ -155,15 +153,17 @@ static int xhci_usb_probe(struct udevice *dev)
 	hcor = (struct xhci_hcor *)((uint64_t)ctx->hcd +
 			HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase)));
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
-	ret = regulator_set_enable(plat->vbus_supply, true);
-	if (ret)
-		debug("XHCI: Failed to enable vbus supply\n");
-#endif
+	if (plat->vbus_supply) {
+		ret = regulator_set_enable(plat->vbus_supply, true);
+		if (ret) {
+			error("XHCI: failed to set VBus supply\n");
+			return ret;
+		}
+	}
 
 	ret = rockchip_xhci_core_init(ctx, dev);
 	if (ret) {
-		debug("XHCI: failed to initialize controller\n");
+		error("XHCI: failed to initialize controller\n");
 		return ret;
 	}
 
@@ -183,13 +183,13 @@ static int xhci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
-	ret = regulator_set_enable(plat->vbus_supply, false);
-	if (ret)
-		debug("XHCI: Failed to disable vbus supply\n");
-#endif
+	if (plat->vbus_supply) {
+		ret = regulator_set_enable(plat->vbus_supply, false);
+		if (ret)
+			error("XHCI: failed to set VBus supply\n");
+	}
 
-	return 0;
+	return ret;
 }
 
 static const struct udevice_id xhci_usb_ids[] = {
Signature · 1 line
1.9.1
#5 lore raw

PATCH v7 2/8 usb: host: xhci-rockchip: use fixed regulator to control vbus

Quoted 17 lines

Use fixed regulator to control the voltage of vbus. Enable vbus supply when usb start and disable vbus supply when usb stop.

---

Changes in v7: None
Changes in v6:
- Remove #ifdef DM_REGULATOR and DM_USB due to the addition in Kconfig

Changes in v5:
- Propagate the return value of setting VBus and print error when failed

Changes in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't set

Quoted 7 lines

Changes in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpio

 drivers/usb/host/xhci-rockchip.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
#6 lore raw

PATCH v7 2/8 usb: host: xhci-rockchip: use fixed regulator to control vbus

In reply to Meng Dongyang
Quoted 18 lines

Use fixed regulator to control the voltage of vbus. Enable vbus supply when usb start and disable vbus supply when usb stop.

---

Changes in v7: None
Changes in v6:
- Remove #ifdef DM_REGULATOR and DM_USB due to the addition in Kconfig

Changes in v5:
- Propagate the return value of setting VBus and print error when failed

Changes in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't set

Quoted 7 lines

Changes in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpio

 drivers/usb/host/xhci-rockchip.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
#7 lore raw

PATCH v7 3/8 rockchip: dts: rk3328: add fixed regulator node for xhci

In reply to Meng Dongyang

The driver changes gpio to fixed regulator to control vbus, so add fixed regulator node in DTS for xhci driver.

---

Changes in v7: None
Changes in v6:
- New patch, splited from [PATCH,v5,06/11]

 arch/arm/dts/rk3328-evb.dts | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm/dts/rk3328-evb.dts +10 -1
index b807bc5..4cf6d2e 100644
@@ -14,6 +14,15 @@
 	chosen {
 		stdout-path = &uart2;
 	};
+
+	vcc5v0_host_xhci: vcc5v0-host-xhci-drv {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		regulator-name = "vcc5v0_host_xhci";
+		gpio = <&gpio0 0 GPIO_ACTIVE_HIGH>;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+	};
 };
 
 &uart2 {
@@ -53,6 +62,6 @@
 };
 
 &usb_host0_xhci {
-	rockchip,vbus-gpio = <&gpio0 0 GPIO_ACTIVE_HIGH>;
+	vbus-supply = <&vcc5v0_host_xhci>;
 	status = "okay";
 };
Signature · 1 line
1.9.1
#8 lore raw

PATCH v7 3/8 rockchip: dts: rk3328: add fixed regulator node for xhci

Quoted 4 lines

The driver changes gpio to fixed regulator to control vbus, so add fixed regulator node in DTS for xhci driver.

Quoted 9 lines

---

Changes in v7: None
Changes in v6:
- New patch, splited from [PATCH,v5,06/11]

 arch/arm/dts/rk3328-evb.dts | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
#9 lore raw

PATCH v7 3/8 rockchip: dts: rk3328: add fixed regulator node for xhci

In reply to Meng Dongyang
Quoted 5 lines

The driver changes gpio to fixed regulator to control vbus, so add fixed regulator node in DTS for xhci driver.

Quoted 9 lines

---

Changes in v7: None
Changes in v6:
- New patch, splited from [PATCH,v5,06/11]

 arch/arm/dts/rk3328-evb.dts | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
#10 lore raw

PATCH v7 4/8 rockchip: configs: rk3328: enable dwc2 driver and config fastboot

In reply to Meng Dongyang

Config dwc2 driver support host and gadget function. Add support of fastboot function.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 configs/evb-rk3328_defconfig    | 19 +++++++++++++++++--
 include/configs/rk3328_common.h |  3 +++
 2 files changed, 20 insertions(+), 2 deletions(-)
configs/evb-rk3328_defconfig +17 -2
index 1384e87..9739fd6 100644
@@ -31,12 +31,27 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550=y
 CONFIG_SYSRESET=y
 CONFIG_USB=y
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_GENERIC=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_RK=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_G_DNL_MANUFACTURER="Rockchip"
+CONFIG_G_DNL_VENDOR_NUM=0x2207
+CONFIG_G_DNL_PRODUCT_NUM=0x330a
+CONFIG_FASTBOOT=y
+CONFIG_CMD_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_BUF_ADDR=0x00800800
+CONFIG_FASTBOOT_BUF_SIZE=0x08000000
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_ERRNO_STR=y
include/configs/rk3328_common.h +3 -0
index 5a06244..2cace24 100644
@@ -59,6 +59,9 @@
 
 #endif
 
+/* dwc2 otg */
+#define CONFIG_USB_DWC2
+
 /* rockchip ohci host driver */
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	1
Signature · 1 line
1.9.1
#11 lore raw

PATCH v7 4/8 rockchip: configs: rk3328: enable dwc2 driver and config fastboot

Quoted 14 lines

Config dwc2 driver support host and gadget function. Add support of fastboot function.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

Quoted 4 lines
 configs/evb-rk3328_defconfig    | 19 +++++++++++++++++--
 include/configs/rk3328_common.h |  3 +++
 2 files changed, 20 insertions(+), 2 deletions(-)
#12 lore raw

PATCH v7 4/8 rockchip: configs: rk3328: enable dwc2 driver and config fastboot

In reply to Meng Dongyang
Quoted 58 lines · Meng Dongyang

Config dwc2 driver support host and gadget function. Add support of fastboot function.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

configs/evb-rk3328_defconfig | 19 +++++++++++++++++--
include/configs/rk3328_common.h | 3 +++

2 files changed, 20 insertions(+), 2 deletions(-)
configs/evb-rk3328_defconfig +0 -0
index 1384e87..9739fd6 100644
@@ -31,12 +31,27 @@ CONFIG_DEBUG_UART_SHIFT=2

CONFIG_SYS_NS16550=y
CONFIG_SYSRESET=y
CONFIG_USB=y

configs/evb-rk3328_defconfig +0 -2
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_OHCI_GENERIC=y
CONFIG_USB_STORAGE=y

configs/evb-rk3328_defconfig +17 -0
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_RK=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_G_DNL_MANUFACTURER="Rockchip"
+CONFIG_G_DNL_VENDOR_NUM=0x2207
+CONFIG_G_DNL_PRODUCT_NUM=0x330a
+CONFIG_FASTBOOT=y
+CONFIG_CMD_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_BUF_ADDR=0x00800800
+CONFIG_FASTBOOT_BUF_SIZE=0x08000000

CONFIG_USE_TINY_PRINTF=y
CONFIG_ERRNO_STR=y

include/configs/rk3328_common.h +0 -0
index 5a06244..2cace24 100644

include/configs/rk3328_common.h line 64

Quoted 6 lines
include/configs/rk3328_common.h +3 -0
@@ -59,6 +59,9 @@
 
 #endif
 
+/* dwc2 otg */
+#define CONFIG_USB_DWC2
+

Please convert this to a Kconfig entry.
You can then select it from the ROCKCHIP_RK322X (and others), as needed.

Quoted 4 lines
include/configs/rk3328_common.h +0 -0
 /* rockchip ohci host driver */
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	1
#13 lore raw

PATCH v7 5/8 usb: dwc2: use dev_read_bool() instead of fdt_getprop()

In reply to Meng Dongyang

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.

---

Changes in v7:
- Romove unused variable ‘prop’ in dwc2 driver

Changes in v6:
- New patch
- Use dev_read_bool() instead of fdt_getprop()
- Add a comment for "hnp-srp-disable" feature

 drivers/usb/host/dwc2.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/usb/host/dwc2.c +6 -10
index 841e596..64c42ac 100644
@@ -43,6 +43,10 @@ struct dwc2_priv {
 	struct dwc2_core_regs *regs;
 	int root_hub_devnum;
 	bool ext_vbus;
+	/*
+	 * The hnp/srp capability must be disabled if the platform
+	 * does't support hnp/srp. Otherwise the force mode can't work.
+	 */
 	bool hnp_srp_disable;
 	bool oc_disable;
 };
@@ -1239,7 +1243,6 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	const void *prop;
 	fdt_addr_t addr;
 
 	addr = devfdt_get_addr(dev);
@@ -1247,15 +1250,8 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	priv->regs = (struct dwc2_core_regs *)addr;
 
-	prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
-			   "disable-over-current", NULL);
-	if (prop)
-		priv->oc_disable = true;
-
-	prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
-			   "hnp-srp-disable", NULL);
-	if (prop)
-		priv->hnp_srp_disable = true;
+	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
+	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
 
 	return 0;
 }
Signature · 1 line
1.9.1
#14 lore raw

PATCH v7 5/8 usb: dwc2: use dev_read_bool() instead of fdt_getprop()

Quoted 10 lines

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.

---

Changes in v7:
- Romove unused variable ‘prop’ in dwc2 driver

Quoted 8 lines

Changes in v6:
- New patch
- Use dev_read_bool() instead of fdt_getprop()
- Add a comment for "hnp-srp-disable" feature

 drivers/usb/host/dwc2.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
#15 lore raw

PATCH v7 5/8 usb: dwc2: use dev_read_bool() instead of fdt_getprop()

In reply to Meng Dongyang
Quoted 11 lines

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.

---

Changes in v7:
- Romove unused variable ‘prop’ in dwc2 driver

Quoted 8 lines

Changes in v6:
- New patch
- Use dev_read_bool() instead of fdt_getprop()
- Add a comment for "hnp-srp-disable" feature

 drivers/usb/host/dwc2.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
#16 lore raw

PATCH v7 6/8 rockchip: rk3328: board: add support of dwc2 gadget

In reply to Meng Dongyang

Probe dwc2 udc in the function of board_usb_start to enable usb gadget function.

---

Changes in v7: None
Changes in v6: None
Chagnes in v5: None
Changes in v4: None
Changes in v3: None

 board/rockchip/evb_rk3328/evb-rk3328.c | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
board/rockchip/evb_rk3328/evb-rk3328.c +42 -0
index 0a26ed5..7fc25bb 100644
@@ -31,7 +31,49 @@ int dram_init_banksize(void)
 	return 0;
 }
 
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
+#include <usb.h>
+#include <usb/dwc2_udc.h>
+
+static struct dwc2_plat_otg_data rk3328_otg_data = {
+	.rx_fifo_sz	= 512,
+	.np_tx_fifo_sz	= 16,
+	.tx_fifo_sz	= 128,
+};
+
 int board_usb_init(int index, enum usb_init_type init)
 {
+	int node;
+	const char *mode;
+	bool matched = false;
+	const void *blob = gd->fdt_blob;
+
+	/* find the usb_otg node */
+	node = fdt_node_offset_by_compatible(blob, -1,
+					"rockchip,rk3328-usb");
+
+	while (node > 0) {
+		mode = fdt_getprop(blob, node, "dr_mode", NULL);
+		if (mode && strcmp(mode, "otg") == 0) {
+			matched = true;
+			break;
+		}
+
+		node = fdt_node_offset_by_compatible(blob, node,
+					"rockchip,rk3328-usb");
+	}
+	if (!matched) {
+		debug("Not found usb_otg device\n");
+		return -ENODEV;
+	}
+
+	rk3328_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
+
+	return dwc2_udc_probe(&rk3328_otg_data);
+}
+
+int board_usb_cleanup(int index, enum usb_init_type init)
+{
 	return 0;
 }
+#endif
Signature · 1 line
1.9.1
#17 lore raw

PATCH v7 6/8 rockchip: rk3328: board: add support of dwc2 gadget

Quoted 7 lines

Probe dwc2 udc in the function of board_usb_start to enable usb gadget function.

---

Quoted 9 lines

Changes in v7: None
Changes in v6: None
Chagnes in v5: None
Changes in v4: None
Changes in v3: None

 board/rockchip/evb_rk3328/evb-rk3328.c | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
#18 lore raw

PATCH v7 6/8 rockchip: rk3328: board: add support of dwc2 gadget

In reply to Meng Dongyang
Quoted 8 lines

Probe dwc2 udc in the function of board_usb_start to enable usb gadget function.

---

Quoted 9 lines

Changes in v7: None
Changes in v6: None
Chagnes in v5: None
Changes in v4: None
Changes in v3: None

 board/rockchip/evb_rk3328/evb-rk3328.c | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
#19 lore raw

PATCH v7 7/8 rockchip: dts: rk3328: support and enable dwc2

In reply to Meng Dongyang

Enable dwc2 controller and add fixed regulator for dwc2 controller to control vbus.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- add hnp-srp-disable property

 arch/arm/dts/rk3328-evb.dts | 14 ++++++++++++++
 arch/arm/dts/rk3328.dtsi    | 10 ++++++++++
 2 files changed, 24 insertions(+)
arch/arm/dts/rk3328-evb.dts +14 -0
index 4cf6d2e..220d0ab 100644
@@ -15,6 +15,15 @@
 		stdout-path = &uart2;
 	};
 
+	vcc5v0_otg: vcc5v0-otg-drv {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		regulator-name = "vcc5v0_otg";
+		gpio = <&gpio0 27 GPIO_ACTIVE_HIGH>;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+	};
+
 	vcc5v0_host_xhci: vcc5v0-host-xhci-drv {
 		compatible = "regulator-fixed";
 		enable-active-high;
@@ -61,6 +70,11 @@
 	status = "okay";
 };
 
+&usb20_otg {
+	vbus-supply = <&vcc5v0_otg>;
+	status = "okay";
+};
+
 &usb_host0_xhci {
 	vbus-supply = <&vcc5v0_host_xhci>;
 	status = "okay";
arch/arm/dts/rk3328.dtsi +10 -0
index f18cfc2..1290982 100644
@@ -460,6 +460,16 @@
 		status = "disabled";
 	};
 
+	usb20_otg: usb at ff580000 {
+		compatible = "rockchip,rk3328-usb", "rockchip,rk3066-usb",
+			     "snps,dwc2";
+		reg = <0x0 0xff580000 0x0 0x40000>;
+		interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+		hnp-srp-disable;
+		dr_mode = "otg";
+		status = "disabled";
+	};
+
 	sdmmc_ext: rksdmmc at ff5f0000 {
 		compatible = "rockchip,rk3328-dw-mshc", "rockchip,rk3288-dw-mshc";
 		reg = <0x0 0xff5f0000 0x0 0x4000>;
Signature · 1 line
1.9.1
#20 lore raw

PATCH v7 7/8 rockchip: dts: rk3328: support and enable dwc2

Quoted 14 lines

Enable dwc2 controller and add fixed regulator for dwc2 controller to control vbus.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- add hnp-srp-disable property

Quoted 4 lines
 arch/arm/dts/rk3328-evb.dts | 14 ++++++++++++++
 arch/arm/dts/rk3328.dtsi    | 10 ++++++++++
 2 files changed, 24 insertions(+)
#21 lore raw

PATCH v7 7/8 rockchip: dts: rk3328: support and enable dwc2

In reply to Meng Dongyang
Quoted 15 lines

Enable dwc2 controller and add fixed regulator for dwc2 controller to control vbus.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- add hnp-srp-disable property

Quoted 4 lines
 arch/arm/dts/rk3328-evb.dts | 14 ++++++++++++++
 arch/arm/dts/rk3328.dtsi    | 10 ++++++++++
 2 files changed, 24 insertions(+)
#22 lore raw

PATCH v7 8/8 rockchip: dts: rk3399: control vbus of typec by fixed regulator

In reply to Meng Dongyang

Add fixed regulator for the port of typec0 and typec1 to control vbus instead of gpio.

---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 arch/arm/dts/rk3399-evb.dts | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
arch/arm/dts/rk3399-evb.dts +14 -2
index f5af75b..bff00c3 100644
@@ -60,6 +60,18 @@
 		gpio = <&gpio4 25 GPIO_ACTIVE_HIGH>;
 	};
 
+	vcc5v0_typec0: vcc5v0-typec0-en {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc5v0_typec0";
+		gpio = <&gpio1 3 GPIO_ACTIVE_HIGH>;
+	};
+
+	vcc5v0_typec1: vcc5v0-typec1-en {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc5v0_typec1";
+		gpio = <&gpio1 4 GPIO_ACTIVE_HIGH>;
+	};
+
 	clkin_gmac: external-gmac-clock {
 		compatible = "fixed-clock";
 		clock-frequency = <125000000>;
@@ -163,7 +175,7 @@
 };
 
 &dwc3_typec0 {
-	rockchip,vbus-gpio = <&gpio1 3 GPIO_ACTIVE_HIGH>;
+	vbus-supply = <&vcc5v0_typec0>;
 	status = "okay";
 };
 
@@ -176,7 +188,7 @@
 };
 
 &dwc3_typec1 {
-	rockchip,vbus-gpio = <&gpio1 4 GPIO_ACTIVE_HIGH>;
+	vbus-supply = <&vcc5v0_typec1>;
 	status = "okay";
 };
 
Signature · 1 line
1.9.1
#23 lore raw

PATCH v7 8/8 rockchip: dts: rk3399: control vbus of typec by fixed regulator

Quoted 7 lines

Add fixed regulator for the port of typec0 and typec1 to control vbus instead of gpio.

---

Quoted 9 lines

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 arch/arm/dts/rk3399-evb.dts | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
#24 lore raw

PATCH v7 8/8 rockchip: dts: rk3399: control vbus of typec by fixed regulator

In reply to Meng Dongyang
Quoted 8 lines

Add fixed regulator for the port of typec0 and typec1 to control vbus instead of gpio.

---

Quoted 9 lines

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 arch/arm/dts/rk3399-evb.dts | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)