linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Wu <william.wu@rock-chips.com>
To: gregkh@linuxfoundation.org, balbi@kernel.org, heiko@sntech.de
Cc: briannorris@google.com, dianders@google.com,
	kever.yang@rock-chips.com, huangtao@rock-chips.com,
	frank.wang@rock-chips.com, eddie.cai@rock-chips.com,
	John.Youn@synopsys.com, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, William Wu <william.wu@rock-chips.com>
Subject: [PATCH 3/4] usb: dwc3: make usb2 phy interface configurable in DT
Date: Mon,  9 May 2016 19:46:16 +0800	[thread overview]
Message-ID: <1462794377-6528-4-git-send-email-william.wu@rock-chips.com> (raw)
In-Reply-To: <1462794377-6528-1-git-send-email-william.wu@rock-chips.com>

Add snps,phyif_utmi_16_bits devicetree property. USB2 phy
interface is hardware property, and it's platform dependent,
so we need to configure it in devicetree to set the core to
support a UTMI+ PHY with an 8- or 16-bit interface.

And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM
must set to the corresponding value according to the usb2
phy interface.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
 Documentation/devicetree/bindings/usb/dwc3.txt |  2 ++
 drivers/usb/dwc3/core.c                        | 13 +++++++++++++
 drivers/usb/dwc3/core.h                        |  8 ++++++++
 drivers/usb/dwc3/platform_data.h               |  1 +
 4 files changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
index 1ada121..c5e72c8 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -19,6 +19,8 @@ Optional properties:
 	Only really useful for FPGA builds.
  - snps,has-lpm-erratum: true when DWC3 was configured with LPM Erratum enabled
  - snps,lpm-nyet-threshold: LPM NYET threshold
+ - snps,phyif_utmi_16_bits: true when configure the core to support
+			UTMI+ PHY with an 16-bit interface.
  - snps,u2exit_lfps_quirk: set if we want to enable u2exit lfps quirk
  - snps,u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk
  - snps,req_p1p2p3_quirk: when set, the core will always request for
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8bcd3cc..0205196 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -410,6 +410,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 static int dwc3_phy_setup(struct dwc3 *dwc)
 {
 	u32 reg;
+	u32 usbtrdtim;
 	int ret;
 
 	reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
@@ -505,6 +506,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->dis_u2_freeclk_exists_quirk)
 		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
 
+	if (dwc->phyif_utmi_16_bits)
+		reg |= DWC3_GUSB2PHYCFG_PHYIF;
+
+	usbtrdtim = (reg & DWC3_GUSB2PHYCFG_PHYIF) ?
+		    USBTRDTIM_UTMI_16_BIT : USBTRDTIM_UTMI_8_BIT;
+
+	reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
+	reg |= (usbtrdtim << DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT);
+
 	dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 
 	return 0;
@@ -879,6 +889,8 @@ static int dwc3_probe(struct platform_device *pdev)
 				&hird_threshold);
 	dwc->usb3_lpm_capable = device_property_read_bool(dev,
 				"snps,usb3_lpm_capable");
+	dwc->phyif_utmi_16_bits = device_property_read_bool(dev,
+				  "snps,phyif_utmi_16_bits");
 
 	dwc->disable_scramble_quirk = device_property_read_bool(dev,
 				"snps,disable_scramble_quirk");
@@ -926,6 +938,7 @@ static int dwc3_probe(struct platform_device *pdev)
 			hird_threshold = pdata->hird_threshold;
 
 		dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
+		dwc->phyif_utmi_16_bits = pdata->phyif_utmi_16_bits;
 		dwc->dr_mode = pdata->dr_mode;
 
 		dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index ac2e6b5..1736f87 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -200,6 +200,11 @@
 #define DWC3_GUSB2PHYCFG_SUSPHY		(1 << 6)
 #define DWC3_GUSB2PHYCFG_ULPI_UTMI	(1 << 4)
 #define DWC3_GUSB2PHYCFG_ENBLSLPM	(1 << 8)
+#define DWC3_GUSB2PHYCFG_PHYIF		(1 << 3)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK	(0xf << 10)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT	10
+#define USBTRDTIM_UTMI_8_BIT		9
+#define USBTRDTIM_UTMI_16_BIT		5
 
 /* Global USB2 PHY Vendor Control Register */
 #define DWC3_GUSB2PHYACC_NEWREGREQ	(1 << 25)
@@ -759,6 +764,8 @@ struct dwc3_scratchpad_array {
  * @start_config_issued: true when StartConfig command has been issued
  * @three_stage_setup: set if we perform a three phase setup
  * @usb3_lpm_capable: set if hadrware supports Link Power Management
+ * @phyif_utmi_16_bits: set if configure the core to support UTMI+ PHY
+ *			with an 16-bit interface
  * @disable_scramble_quirk: set if we enable the disable scramble quirk
  * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk
  * @u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk
@@ -904,6 +911,7 @@ struct dwc3 {
 	unsigned		setup_packet_pending:1;
 	unsigned		three_stage_setup:1;
 	unsigned		usb3_lpm_capable:1;
+	unsigned		phyif_utmi_16_bits:1;
 
 	unsigned		disable_scramble_quirk:1;
 	unsigned		u2exit_lfps_quirk:1;
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index e1a1631..2ce5e2f 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -24,6 +24,7 @@ struct dwc3_platform_data {
 	enum usb_device_speed maximum_speed;
 	enum usb_dr_mode dr_mode;
 	bool usb3_lpm_capable;
+	bool phyif_utmi_16_bits;
 
 	unsigned is_utmi_l1_suspend:1;
 	u8 hird_threshold;
-- 
1.9.1

  parent reply	other threads:[~2016-05-09 11:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-09 11:46 [PATCH 0/4] support rockchip dwc3 driver William Wu
2016-05-09 11:46 ` [PATCH 1/4] usb: dwc3: of-simple: add compatible for rockchip William Wu
2016-05-09 15:16   ` Doug Anderson
2016-05-10  7:14     ` Felipe Balbi
2016-05-10  7:39       ` William Wu
2016-05-10  8:11         ` Felipe Balbi
2016-05-10  8:27           ` William Wu
2016-05-09 19:24   ` Brian Norris
2016-05-10  7:15     ` Felipe Balbi
2016-05-10  8:14       ` William Wu
2016-05-09 11:46 ` [PATCH 2/4] usb: dwc3: add dis_u2_freeclk_exists_quirk William Wu
2016-05-09 11:46 ` William Wu [this message]
2016-05-09 12:18   ` [PATCH 3/4] usb: dwc3: make usb2 phy interface configurable in DT Felipe Balbi
2016-05-09 13:28     ` William Wu
2016-05-09 13:32       ` Felipe Balbi
2016-05-09 11:46 ` [PATCH 4/4] usb: dwc3: add dis_del_phy_power_chg_quirk William Wu
2016-05-13  9:24 ` [PATCH v2 0/5] support rockchip dwc3 driver William Wu
2016-05-13  9:24   ` [PATCH v2 1/5] usb: dwc3: of-simple: add compatible for rockchip William Wu
2016-05-13  9:24   ` [PATCH v2 2/5] usb: dwc3: add dis_u2_freeclk_exists_quirk William Wu
2016-05-13  9:24   ` [PATCH v2 3/5] usb: dwc3: add phyif_utmi_quirk William Wu
2016-05-13  9:25   ` [PATCH v2 4/5] usb: dwc3: add dis_del_phy_power_chg_quirk William Wu
2016-05-13  9:30   ` [PATCH v2 0/5] support rockchip dwc3 driver Heiko Stuebner
2016-05-13  9:37   ` Felipe Balbi
2016-05-13  9:48     ` William Wu

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=1462794377-6528-4-git-send-email-william.wu@rock-chips.com \
    --to=william.wu@rock-chips.com \
    --cc=John.Youn@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=briannorris@google.com \
    --cc=dianders@google.com \
    --cc=eddie.cai@rock-chips.com \
    --cc=frank.wang@rock-chips.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=huangtao@rock-chips.com \
    --cc=kever.yang@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).