public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget
@ 2017-06-21  3:58 Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 1/8] usb: Kconfig: add depends on features for xhci-rockchip driver Meng Dongyang
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

Add support of usb host and gadget function for rk3328.

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: add depends on feature for xhci-rockchip driver
  usb: host: xhci-rockchip: use fixed regulator to control vbus
  rockchip: dts: rk3328: support and enable 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                | 15 +++++-------
 drivers/usb/host/xhci-rockchip.c       | 36 ++++++++++++++---------------
 include/configs/rk3328_common.h        |  3 +++
 9 files changed, 136 insertions(+), 32 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 1/8] usb: Kconfig: add depends on features for xhci-rockchip driver
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 2/8] usb: host: xhci-rockchip: use fixed regulator to control vbus Meng Dongyang
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

The xhci-rockchip driver depends on DM_REGULATOR and DM_USB.
So add depends on features in Kconfig to make the driver explicitly
depend on DM_REGULATOR and DM_USB.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
---

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

 drivers/usb/host/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index b824eec..5e07a10 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -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.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 2/8] usb: host: xhci-rockchip: use fixed regulator to control vbus
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 1/8] usb: Kconfig: add depends on features for xhci-rockchip driver Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 3/8] rockchip: dts: rk3328: add fix-regulator node for xhci Meng Dongyang
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

Use fixed regulator to control the voltage of vbus and turn off
vbus when usb stop.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
---

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(-)

diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c
index c4ae55f..6b4caf9 100644
--- a/drivers/usb/host/xhci-rockchip.c
+++ b/drivers/usb/host/xhci-rockchip.c
@@ -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[] = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 3/8] rockchip: dts: rk3328: add fix-regulator node for xhci
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 1/8] usb: Kconfig: add depends on features for xhci-rockchip driver Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 2/8] usb: host: xhci-rockchip: use fixed regulator to control vbus Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 4/8] rockchip: configs: rk3328: enable dwc2 driver and config fastboot Meng Dongyang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
---

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(-)

diff --git a/arch/arm/dts/rk3328-evb.dts b/arch/arm/dts/rk3328-evb.dts
index b807bc5..4cf6d2e 100644
--- a/arch/arm/dts/rk3328-evb.dts
+++ b/arch/arm/dts/rk3328-evb.dts
@@ -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";
 };
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 4/8] rockchip: configs: rk3328: enable dwc2 driver and config fastboot
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
                   ` (2 preceding siblings ...)
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 3/8] rockchip: dts: rk3328: add fix-regulator node for xhci Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop() Meng Dongyang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

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(-)

diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig
index 1384e87..9739fd6 100644
--- a/configs/evb-rk3328_defconfig
+++ b/configs/evb-rk3328_defconfig
@@ -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
diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h
index 5a06244..2cace24 100644
--- a/include/configs/rk3328_common.h
+++ b/include/configs/rk3328_common.h
@@ -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
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop()
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
                   ` (3 preceding siblings ...)
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 4/8] rockchip: configs: rk3328: enable dwc2 driver and config fastboot Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-22 17:29   ` Heiko Stuebner
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 6/8] rockchip: rk3328: board: add support of dwc2 gadget Meng Dongyang
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

Use dev_read_bool() instead of fdt_getprop() to get the property
from DTS. And add a comment for "hnp-srp-disable" property to
fully describe its effect.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
---

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 | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 841e596..3996f67 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -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;
 };
@@ -1247,15 +1251,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;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 6/8] rockchip: rk3328: board: add support of dwc2 gadget
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
                   ` (4 preceding siblings ...)
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop() Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 7/8] rockchip: dts: rk3328: support and enable dwc2 Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 8/8] rockchip: dts: rk3399: control vbus of typec by fixed regulator Meng Dongyang
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

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(+)

diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c
index 0a26ed5..7fc25bb 100644
--- a/board/rockchip/evb_rk3328/evb-rk3328.c
+++ b/board/rockchip/evb_rk3328/evb-rk3328.c
@@ -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
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 7/8] rockchip: dts: rk3328: support and enable dwc2
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
                   ` (5 preceding siblings ...)
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 6/8] rockchip: rk3328: board: add support of dwc2 gadget Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 8/8] rockchip: dts: rk3399: control vbus of typec by fixed regulator Meng Dongyang
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

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(+)

diff --git a/arch/arm/dts/rk3328-evb.dts b/arch/arm/dts/rk3328-evb.dts
index 4cf6d2e..220d0ab 100644
--- a/arch/arm/dts/rk3328-evb.dts
+++ b/arch/arm/dts/rk3328-evb.dts
@@ -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";
diff --git a/arch/arm/dts/rk3328.dtsi b/arch/arm/dts/rk3328.dtsi
index f18cfc2..1290982 100644
--- a/arch/arm/dts/rk3328.dtsi
+++ b/arch/arm/dts/rk3328.dtsi
@@ -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>;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 8/8] rockchip: dts: rk3399: control vbus of typec by fixed regulator
  2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
                   ` (6 preceding siblings ...)
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 7/8] rockchip: dts: rk3328: support and enable dwc2 Meng Dongyang
@ 2017-06-21  3:58 ` Meng Dongyang
  7 siblings, 0 replies; 11+ messages in thread
From: Meng Dongyang @ 2017-06-21  3:58 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

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(-)

diff --git a/arch/arm/dts/rk3399-evb.dts b/arch/arm/dts/rk3399-evb.dts
index f5af75b..bff00c3 100644
--- a/arch/arm/dts/rk3399-evb.dts
+++ b/arch/arm/dts/rk3399-evb.dts
@@ -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";
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop()
  2017-06-21  3:58 ` [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop() Meng Dongyang
@ 2017-06-22 17:29   ` Heiko Stuebner
  2017-06-23  3:55     ` rock-chips
  0 siblings, 1 reply; 11+ messages in thread
From: Heiko Stuebner @ 2017-06-22 17:29 UTC (permalink / raw)
  To: u-boot

Hi,

Am Mittwoch, 21. Juni 2017, 11:58:24 CEST schrieb 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.
> 
> Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
> ---
> 
> 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 | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
> index 841e596..3996f67 100644
> --- a/drivers/usb/host/dwc2.c
> +++ b/drivers/usb/host/dwc2.c
> @@ -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;
>  };
> @@ -1247,15 +1251,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");

with this patch applied, I get

drivers/usb/host/dwc2.c: In function ‘dwc2_usb_ofdata_to_platdata’:
drivers/usb/host/dwc2.c:1246:14: warning: unused variable ‘prop’ [-Wunused-variable]
  const void *prop;
              ^~~~

so you might want to remove the prop var as well?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop()
  2017-06-22 17:29   ` Heiko Stuebner
@ 2017-06-23  3:55     ` rock-chips
  0 siblings, 0 replies; 11+ messages in thread
From: rock-chips @ 2017-06-23  3:55 UTC (permalink / raw)
  To: u-boot



On 2017/6/23 1:29, Heiko Stuebner wrote:
> Hi,
>
> Am Mittwoch, 21. Juni 2017, 11:58:24 CEST schrieb 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.
>>
>> Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
>> ---
>>
>> 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 | 15 ++++++---------
>>   1 file changed, 6 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
>> index 841e596..3996f67 100644
>> --- a/drivers/usb/host/dwc2.c
>> +++ b/drivers/usb/host/dwc2.c
>> @@ -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;
>>   };
>> @@ -1247,15 +1251,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");
> with this patch applied, I get
>
> drivers/usb/host/dwc2.c: In function ‘dwc2_usb_ofdata_to_platdata’:
> drivers/usb/host/dwc2.c:1246:14: warning: unused variable ‘prop’ [-Wunused-variable]
>    const void *prop;
>                ^~~~
>
> so you might want to remove the prop var as well?

Yes, I forgot this.

>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-23  3:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21  3:58 [U-Boot] [PATCH v6 0/8] rk3328: add support of usb host and gadget Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 1/8] usb: Kconfig: add depends on features for xhci-rockchip driver Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 2/8] usb: host: xhci-rockchip: use fixed regulator to control vbus Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 3/8] rockchip: dts: rk3328: add fix-regulator node for xhci Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 4/8] rockchip: configs: rk3328: enable dwc2 driver and config fastboot Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 5/8] usb: dwc2: use dev_read_bool() instead of fdt_getprop() Meng Dongyang
2017-06-22 17:29   ` Heiko Stuebner
2017-06-23  3:55     ` rock-chips
2017-06-21  3:58 ` [U-Boot] [PATCH v6 6/8] rockchip: rk3328: board: add support of dwc2 gadget Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 7/8] rockchip: dts: rk3328: support and enable dwc2 Meng Dongyang
2017-06-21  3:58 ` [U-Boot] [PATCH v6 8/8] rockchip: dts: rk3399: control vbus of typec by fixed regulator Meng Dongyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox