Skip to contentSkip to conversation

rockchip: rk3399: Fix USB3 support

PATCH New Mark Kettenis 2 participants 11 messages Jun 30, 2019 – Jul 15, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover rockchip: rk3399: Fix USB3 support

Ever since the dts files were synchronized in commit 0a09f2f1173d ("rockchip: Adjust rk3399 device tree to be closer to linux") USB3 support on Rockchip RK3399 boards has been broken.

This series restores the functionality by adopting the dwc3-of-simple glue driver.

Changes in v2:
- fix spelling of "snps,dis_enblslpm-quirk" property

Mark Kettenis (4):
rockchip: clk: rk3399: handle clk_enable requests for USB3
usb: dwc3-of-simple: Add support for RK3399
usb: xhci-dwc3: Add USB2 PHY configuration
rockchip: xhci: Remove RK3399 support

 drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++
 drivers/usb/host/Kconfig          |  1 +
 drivers/usb/host/dwc3-of-simple.c |  1 +
 drivers/usb/host/xhci-dwc3.c      | 20 ++++++++++++++++++++
 drivers/usb/host/xhci-rockchip.c  |  2 --
 5 files changed, 34 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/4 rockchip: clk: rk3399: handle clk_enable requests for USB3

The "simple" OF glue layer for the Designware USB3 core enables all refernced clocks. These need to be need to be implemented otherwise the driver fails to probe. A dummy implementation that simply returns success is sufficient since the RK3399 comes out of reset with all clock gates open.

---
 drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +12 -0
index 79007b8682..d9950c159b 100644
@@ -1080,6 +1080,18 @@ static int rk3399_clk_enable(struct clk *clk)
 	case PCLK_GMAC:
 		/* Required to successfully probe the Designware GMAC driver */
 		return 0;
+
+	case SCLK_USB3OTG0_REF:
+	case SCLK_USB3OTG1_REF:
+	case SCLK_USB3OTG0_SUSPEND:
+	case SCLK_USB3OTG1_SUSPEND:
+	case ACLK_USB3OTG0:
+	case ACLK_USB3OTG1:
+	case ACLK_USB3_RKSOC_AXI_PERF:
+	case ACLK_USB3:
+	case ACLK_USB3_GRF:
+		/* Required to successfully probe the Designware USB3 driver */
+		return 0;
 	}
 
 	debug("%s: unsupported clk %ld\n", __func__, clk->id);
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 1/4 rockchip: clk: rk3399: handle clk_enable requests for USB3

Hi Mark,

Quoted 7 lines · Mark Kettenis

The "simple" OF glue layer for the Designware USB3 core enables all refernced clocks. These need to be need to be implemented otherwise the driver fails to probe. A dummy implementation that simply returns success is sufficient since the RK3399 comes out of reset with all clock gates open.

Thanks,
- Kever

Quoted 27 lines
---
 drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +12 -0
index 79007b8682..d9950c159b 100644
@@ -1080,6 +1080,18 @@ static int rk3399_clk_enable(struct clk *clk)
 	case PCLK_GMAC:
 		/* Required to successfully probe the Designware GMAC driver */
 		return 0;
+
+	case SCLK_USB3OTG0_REF:
+	case SCLK_USB3OTG1_REF:
+	case SCLK_USB3OTG0_SUSPEND:
+	case SCLK_USB3OTG1_SUSPEND:
+	case ACLK_USB3OTG0:
+	case ACLK_USB3OTG1:
+	case ACLK_USB3_RKSOC_AXI_PERF:
+	case ACLK_USB3:
+	case ACLK_USB3_GRF:
+		/* Required to successfully probe the Designware USB3 driver */
+		return 0;
 	}
 
 	debug("%s: unsupported clk %ld\n", __func__, clk->id);
#3 lore raw

PATCH v2 1/4 rockchip: clk: rk3399: handle clk_enable requests for USB3【请注意,邮件由[email protected]代发】

Quoted 4 lines · Kever Yang

Hi Mark,

On 07/01/2019 12:01 AM, Mark Kettenis wrote:

Quoted 8 lines
Quoted 7 lines

The "simple" OF glue layer for the Designware USB3 core enables all refernced clocks. These need to be need to be implemented otherwise the driver fails to probe. A dummy implementation that simply returns success is sufficient since the RK3399 comes out of reset with all clock gates open.

Applied to u-boot-rockchip.

Thanks,
- Kever

Quoted 35 lines

Thanks,
- Kever

Quoted 17 lines
---
  drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +5 -0
index 79007b8682..d9950c159b 100644
@@ -1080,6 +1080,18 @@ static int rk3399_clk_enable(struct clk *clk)
  	case PCLK_GMAC:
  		/* Required to successfully probe the Designware GMAC driver */
  		return 0;
+
+	case SCLK_USB3OTG0_REF:
+	case SCLK_USB3OTG1_REF:
+	case SCLK_USB3OTG0_SUSPEND:
+	case SCLK_USB3OTG1_SUSPEND:

drivers/clk/rockchip/clk_rk3399.c static int rk3399_clk_enable(struct clk *clk) · line 1097

Quoted 10 lines
drivers/clk/rockchip/clk_rk3399.c +7 -0
+	case ACLK_USB3OTG0:
+	case ACLK_USB3OTG1:
+	case ACLK_USB3_RKSOC_AXI_PERF:
+	case ACLK_USB3:
+	case ACLK_USB3_GRF:
+		/* Required to successfully probe the Designware USB3 driver */
+		return 0;
  	}
 
  	debug("%s: unsupported clk %ld\n", __func__, clk->id);

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#4 lore raw

PATCH v2 2/4 usb: dwc3-of-simple: Add support for RK3399

In reply to Mark Kettenis

Add compatible string for RK3399 and enable it by default on Rockchip platforms with USB3 support.

---
 drivers/usb/host/Kconfig          | 1 +
 drivers/usb/host/dwc3-of-simple.c | 1 +
 2 files changed, 2 insertions(+)
drivers/usb/host/Kconfig +1 -0
index b1188bcbf5..ac68aa2d27 100644
@@ -24,6 +24,7 @@ config USB_XHCI_DWC3
 config USB_XHCI_DWC3_OF_SIMPLE
 	bool "DesignWare USB3 DRD Generic OF Simple Glue Layer"
 	depends on DM_USB
+	default y if ARCH_ROCKCHIP
 	default y if DRA7XX
 	help
 	  Support USB2/3 functionality in simple SoC integrations with
drivers/usb/host/dwc3-of-simple.c +1 -0
index b118997f6e..45df614b09 100644
@@ -92,6 +92,7 @@ static int dwc3_of_simple_remove(struct udevice *dev)
 
 static const struct udevice_id dwc3_of_simple_ids[] = {
 	{ .compatible = "amlogic,meson-gxl-dwc3" },
+	{ .compatible = "rockchip,rk3399-dwc3" },
 	{ .compatible = "ti,dwc3" },
 	{ }
 };
Signature · 1 line
2.21.0
#5 lore raw

PATCH v2 2/4 usb: dwc3-of-simple: Add support for RK3399

Quoted 5 lines · Mark Kettenis

Add compatible string for RK3399 and enable it by default on Rockchip platforms with USB3 support.

Applied to u-boot-rockchip.

Thanks,
- Kever

Quoted 29 lines
---
  drivers/usb/host/Kconfig          | 1 +
  drivers/usb/host/dwc3-of-simple.c | 1 +
  2 files changed, 2 insertions(+)
drivers/usb/host/Kconfig +1 -0
index b1188bcbf5..ac68aa2d27 100644
@@ -24,6 +24,7 @@ config USB_XHCI_DWC3
  config USB_XHCI_DWC3_OF_SIMPLE
  	bool "DesignWare USB3 DRD Generic OF Simple Glue Layer"
  	depends on DM_USB
+	default y if ARCH_ROCKCHIP
  	default y if DRA7XX
  	help
  	  Support USB2/3 functionality in simple SoC integrations with
drivers/usb/host/dwc3-of-simple.c +1 -0
index b118997f6e..45df614b09 100644
@@ -92,6 +92,7 @@ static int dwc3_of_simple_remove(struct udevice *dev)
 
  static const struct udevice_id dwc3_of_simple_ids[] = {
  	{ .compatible = "amlogic,meson-gxl-dwc3" },
+	{ .compatible = "rockchip,rk3399-dwc3" },
  	{ .compatible = "ti,dwc3" },
  	{ }
  };
#6 lore raw

PATCH v2 3/4 usb: xhci-dwc3: Add USB2 PHY configuration

In reply to Mark Kettenis

Configure USB2 PHY register based on "phy_type" property and handle all the quirks that are relevant for Rockchip RK3399 SoCs.

---
 drivers/usb/host/xhci-dwc3.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/usb/host/xhci-dwc3.c +20 -0
index 83b9f119e7..9e8cae7ae4 100644
@@ -118,6 +118,8 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	struct dwc3 *dwc3_reg;
 	enum usb_dr_mode dr_mode;
 	struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
+	const char *phy;
+	u32 reg;
 	int ret;
 
 	hccr = (struct xhci_hccr *)((uintptr_t)dev_read_addr(dev));
@@ -132,6 +134,24 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
 	dwc3_core_init(dwc3_reg);
 
+	/* Set dwc3 usb2 phy config */
+	reg = readl(&dwc3_reg->g_usb2phycfg[0]);
+
+	phy = dev_read_string(dev, "phy_type");
+	if (phy && strcmp(phy, "utmi_wide") == 0) {
+		reg |= DWC3_GUSB2PHYCFG_PHYIF;
+		reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
+		reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT;
+	}
+
+	if (dev_read_bool(dev, "snps,dis_enblslpm-quirk"))
+		reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
+
+	if (dev_read_bool(dev, "snps,dis-u2-freeclk-exists-quirk"))
+		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
+
+	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
+
 	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
Signature · 1 line
2.21.0
#7 lore raw

PATCH v2 3/4 usb: xhci-dwc3: Add USB2 PHY configuration

Hi Mark,

Quoted 4 lines · Mark Kettenis

Configure USB2 PHY register based on "phy_type" property and handle all the quirks that are relevant for Rockchip RK3399 SoCs.

Thanks,
- Kever

Quoted 42 lines
---
 drivers/usb/host/xhci-dwc3.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/usb/host/xhci-dwc3.c +20 -0
index 83b9f119e7..9e8cae7ae4 100644
@@ -118,6 +118,8 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	struct dwc3 *dwc3_reg;
 	enum usb_dr_mode dr_mode;
 	struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
+	const char *phy;
+	u32 reg;
 	int ret;
 
 	hccr = (struct xhci_hccr *)((uintptr_t)dev_read_addr(dev));
@@ -132,6 +134,24 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
 	dwc3_core_init(dwc3_reg);
 
+	/* Set dwc3 usb2 phy config */
+	reg = readl(&dwc3_reg->g_usb2phycfg[0]);
+
+	phy = dev_read_string(dev, "phy_type");
+	if (phy && strcmp(phy, "utmi_wide") == 0) {
+		reg |= DWC3_GUSB2PHYCFG_PHYIF;
+		reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
+		reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT;
+	}
+
+	if (dev_read_bool(dev, "snps,dis_enblslpm-quirk"))
+		reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
+
+	if (dev_read_bool(dev, "snps,dis-u2-freeclk-exists-quirk"))
+		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
+
+	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
+
 	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
#8 lore raw

PATCH v2 3/4 usb: xhci-dwc3: Add USB2 PHY configuration【请注意,邮件由[email protected]代发】 configuration

Quoted 9 lines · Kever Yang

Hi Mark,

Quoted 4 lines · Mark Kettenis

Configure USB2 PHY register based on "phy_type" property and handle all the quirks that are relevant for Rockchip RK3399 SoCs.

Applied to u-boot-rockchip.

Thanks,
- Kever

Quoted 50 lines

Thanks,
- Kever

Quoted 32 lines
---
  drivers/usb/host/xhci-dwc3.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/usb/host/xhci-dwc3.c +13 -0
index 83b9f119e7..9e8cae7ae4 100644
@@ -118,6 +118,8 @@ static int xhci_dwc3_probe(struct udevice *dev)
  	struct dwc3 *dwc3_reg;
  	enum usb_dr_mode dr_mode;
  	struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
+	const char *phy;
+	u32 reg;
  	int ret;
 
  	hccr = (struct xhci_hccr *)((uintptr_t)dev_read_addr(dev));
@@ -132,6 +134,24 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
  	dwc3_core_init(dwc3_reg);
 
+	/* Set dwc3 usb2 phy config */
+	reg = readl(&dwc3_reg->g_usb2phycfg[0]);
+
+	phy = dev_read_string(dev, "phy_type");
+	if (phy && strcmp(phy, "utmi_wide") == 0) {
+		reg |= DWC3_GUSB2PHYCFG_PHYIF;
+		reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
+		reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT;
+	}
+
+	if (dev_read_bool(dev, "snps,dis_enblslpm-quirk"))

drivers/usb/host/xhci-dwc3.c static int xhci_dwc3_probe(struct udevice *dev) · line 157

Quoted 10 lines
drivers/usb/host/xhci-dwc3.c +7 -0
+		reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
+
+	if (dev_read_bool(dev, "snps,dis-u2-freeclk-exists-quirk"))
+		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
+
+	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
+
  	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
  	if (dr_mode == USB_DR_MODE_UNKNOWN)
  		/* by default set dual role mode to HOST */

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#9 lore raw

PATCH v2 4/4 rockchip: xhci: Remove RK3399 support

In reply to Mark Kettenis

Remove RK3399 compatible strings as this driver is no longer used on that SoC.

---
 drivers/usb/host/xhci-rockchip.c | 2 --
 1 file changed, 2 deletions(-)
drivers/usb/host/xhci-rockchip.c +0 -2
index f19bea3a91..e7b0dbcca5 100644
@@ -167,7 +167,6 @@ static int xhci_usb_remove(struct udevice *dev)
 }
 
 static const struct udevice_id xhci_usb_ids[] = {
-	{ .compatible = "rockchip,rk3399-xhci" },
 	{ .compatible = "rockchip,rk3328-xhci" },
 	{ }
 };
@@ -187,7 +186,6 @@ U_BOOT_DRIVER(usb_xhci) = {
 };
 
 static const struct udevice_id usb_phy_ids[] = {
-	{ .compatible = "rockchip,rk3399-usb3-phy" },
 	{ .compatible = "rockchip,rk3328-usb3-phy" },
 	{ }
 };
Signature · 1 line
2.21.0
#10 lore raw

PATCH v2 4/4 rockchip: xhci: Remove RK3399 support

Quoted 5 lines · Mark Kettenis

Remove RK3399 compatible strings as this driver is no longer used on that SoC.

Applied to u-boot-rockchip.

Thanks,
- Kever

Quoted 24 lines
---
  drivers/usb/host/xhci-rockchip.c | 2 --
  1 file changed, 2 deletions(-)
drivers/usb/host/xhci-rockchip.c +0 -2
index f19bea3a91..e7b0dbcca5 100644
@@ -167,7 +167,6 @@ static int xhci_usb_remove(struct udevice *dev)
  }
 
  static const struct udevice_id xhci_usb_ids[] = {
-	{ .compatible = "rockchip,rk3399-xhci" },
  	{ .compatible = "rockchip,rk3328-xhci" },
  	{ }
  };
@@ -187,7 +186,6 @@ U_BOOT_DRIVER(usb_xhci) = {
  };
 
  static const struct udevice_id usb_phy_ids[] = {
-	{ .compatible = "rockchip,rk3399-usb3-phy" },
  	{ .compatible = "rockchip,rk3328-usb3-phy" },
  	{ }
  };