All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Wang <frank.wang@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 4/7] usb: dwc3: add make compatible for rockchip platform
Date: Thu,  7 May 2020 16:12:10 +0800	[thread overview]
Message-ID: <20200507081213.16107-5-frank.wang@rock-chips.com> (raw)
In-Reply-To: <20200507081213.16107-1-frank.wang@rock-chips.com>

RK3399 Type-C PHY is required that must hold whole USB3.0 OTG controller
in resetting to hold pipe power state in P2 before initializing the PHY.
This commit fixed it and added device compatible for rockchip platform.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
---
Changes for v3:
 - none

 drivers/usb/dwc3/dwc3-generic.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index febcfc0f54..0031e8bf44 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -24,6 +24,12 @@
 #include <clk.h>
 #include <usb/xhci.h>
 
+struct dwc3_glue_data {
+	struct clk_bulk		clks;
+	struct reset_ctl_bulk	resets;
+	fdt_addr_t regs;
+};
+
 struct dwc3_generic_plat {
 	fdt_addr_t base;
 	u32 maximum_speed;
@@ -48,6 +54,7 @@ static int dwc3_generic_probe(struct udevice *dev,
 	int rc;
 	struct dwc3_generic_plat *plat = dev_get_platdata(dev);
 	struct dwc3 *dwc3 = &priv->dwc3;
+	struct dwc3_glue_data *glue = dev_get_platdata(dev->parent);
 
 	dwc3->dev = dev;
 	dwc3->maximum_speed = plat->maximum_speed;
@@ -56,10 +63,22 @@ static int dwc3_generic_probe(struct udevice *dev,
 	dwc3_of_parse(dwc3);
 #endif
 
+	/*
+	 * It must hold whole USB3.0 OTG controller in resetting to hold pipe
+	 * power state in P2 before initializing TypeC PHY on RK3399 platform.
+	 */
+	if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) {
+		reset_assert_bulk(&glue->resets);
+		udelay(1);
+	}
+
 	rc = dwc3_setup_phy(dev, &priv->phys, &priv->num_phys);
 	if (rc)
 		return rc;
 
+	if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3"))
+		reset_deassert_bulk(&glue->resets);
+
 	priv->base = map_physmem(plat->base, DWC3_OTG_REGS_END, MAP_NOCACHE);
 	dwc3->regs = priv->base + DWC3_GLOBALS_REGS_START;
 
@@ -187,12 +206,6 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 };
 #endif
 
-struct dwc3_glue_data {
-	struct clk_bulk		clks;
-	struct reset_ctl_bulk	resets;
-	fdt_addr_t regs;
-};
-
 struct dwc3_glue_ops {
 	void (*select_dr_mode)(struct udevice *dev, int index,
 			       enum usb_dr_mode mode);
@@ -395,6 +408,12 @@ static int dwc3_glue_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	if (glue->resets.count < 1) {
+		ret = dwc3_glue_reset_init(child, glue);
+		if (ret)
+			return ret;
+	}
+
 	while (child) {
 		enum usb_dr_mode dr_mode;
 
@@ -425,6 +444,8 @@ static const struct udevice_id dwc3_glue_ids[] = {
 	{ .compatible = "ti,dwc3", .data = (ulong)&ti_ops },
 	{ .compatible = "ti,am437x-dwc3", .data = (ulong)&ti_ops },
 	{ .compatible = "ti,am654-dwc3" },
+	{ .compatible = "rockchip,rk3328-dwc3" },
+	{ .compatible = "rockchip,rk3399-dwc3" },
 	{ }
 };
 
-- 
2.17.1

  parent reply	other threads:[~2020-05-07  8:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07  8:12 [PATCH v3 0/7] Add Rockchip RK3399 USB3.0 Host support Frank Wang
2020-05-07  8:12 ` [PATCH v3 1/7] usb: dwc3: add dis_enblslpm_quirk Frank Wang
2020-05-08 18:36   ` Jagan Teki
2020-05-07  8:12 ` [PATCH v3 2/7] usb: dwc3: add dis_u2_freeclk_exists_quirk Frank Wang
2020-05-08 18:32   ` Jagan Teki
2020-05-07  8:12 ` [PATCH v3 3/7] usb: dwc3: amend UTMI/UTMIW phy interface setup Frank Wang
2020-05-07  8:12 ` Frank Wang [this message]
2020-05-07  8:13 ` [PATCH v3 5/7] driver: usb: drop legacy rockchip xhci driver Frank Wang
2020-05-07  8:13 ` [PATCH v3 6/7] ARM: dts: rk3399-evb: usb3.0 host support Frank Wang
2020-05-07  8:17   ` Peter Robinson
2020-05-08  0:13     ` Frank Wang
2020-05-07  8:13 ` [PATCH v3 7/7] configs: evb-rk3399: update support usb3.0 host Frank Wang
2020-05-08 17:24   ` Jagan Teki
2020-05-08 17:43     ` Marek Vasut
2020-05-08 17:46       ` Jagan Teki
2020-05-08 18:33         ` Marek Vasut
2020-05-08 18:52           ` Jagan Teki
2020-05-09  3:08             ` Frank Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200507081213.16107-5-frank.wang@rock-chips.com \
    --to=frank.wang@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.