linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Add MediaTek USB3 DRD Driver
@ 2016-05-31  5:52 Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Chunfeng Yun @ 2016-05-31  5:52 UTC (permalink / raw)
  To: linux-arm-kernel

>From f2b6744b1ed13636db8690dd3e8d65ad7f3fb7ce Mon Sep 17 00:00:00 2001
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: Tue, 31 May 2016 10:52:46 +0800
Subject: [PATCH 0/5] Add MediaTek USB3 DRD Driver

These patches introduce the MediaTek USB3 dual-role controller
driver.

The driver can be configured as Dual-Role Device (DRD),
Peripheral Only and Host Only (xHCI) modes. It works well
with Mass Storage, RNDIS and g_zero on FS/HS and SS. And it is
tested on MT8173 platform which only contains USB2.0 device IP,
and on MT6290 platform which contains USB3.0 device IP.

Change in v2:
1. modify binding docs according to suggestions 
2. modify some comments and remove some dummy blank lines
3. fix memory leakage

Chunfeng Yun (5):
  dt-bindings: mt8173-xhci: support host side of dual-role mode
  usb: xhci-mtk: make IPPC register optional
  dt-bindings: mtu3: add devicetree bindings
  usb: Add MediaTek USB3 DRD Driver
  arm64: dts: mediatek: add USB3 DRD driver

 .../devicetree/bindings/usb/mt8173-xhci.txt        |   48 ++
 Documentation/devicetree/bindings/usb/mtu3.txt     |   85 ++
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts        |   46 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi           |   28 +-
 drivers/usb/Kconfig                                |    2 +
 drivers/usb/Makefile                               |    1 +
 drivers/usb/host/xhci-mtk.c                        |   32 +-
 drivers/usb/mtu3/Kconfig                           |   47 ++
 drivers/usb/mtu3/Makefile                          |   20 +
 drivers/usb/mtu3/mtu3.h                            |  422 ++++++++++
 drivers/usb/mtu3/mtu3_core.c                       |  879 ++++++++++++++++++++
 drivers/usb/mtu3/mtu3_dr.c                         |  348 ++++++++
 drivers/usb/mtu3/mtu3_dr.h                         |  108 +++
 drivers/usb/mtu3/mtu3_gadget.c                     |  731 ++++++++++++++++
 drivers/usb/mtu3/mtu3_gadget_ep0.c                 |  879 ++++++++++++++++++++
 drivers/usb/mtu3/mtu3_host.c                       |  294 +++++++
 drivers/usb/mtu3/mtu3_hw_regs.h                    |  474 +++++++++++
 drivers/usb/mtu3/mtu3_plat.c                       |  490 +++++++++++
 drivers/usb/mtu3/mtu3_qmu.c                        |  599 +++++++++++++
 drivers/usb/mtu3/mtu3_qmu.h                        |   43 +
 20 files changed, 5562 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/mtu3.txt
 create mode 100644 drivers/usb/mtu3/Kconfig
 create mode 100644 drivers/usb/mtu3/Makefile
 create mode 100644 drivers/usb/mtu3/mtu3.h
 create mode 100644 drivers/usb/mtu3/mtu3_core.c
 create mode 100644 drivers/usb/mtu3/mtu3_dr.c
 create mode 100644 drivers/usb/mtu3/mtu3_dr.h
 create mode 100644 drivers/usb/mtu3/mtu3_gadget.c
 create mode 100644 drivers/usb/mtu3/mtu3_gadget_ep0.c
 create mode 100644 drivers/usb/mtu3/mtu3_host.c
 create mode 100644 drivers/usb/mtu3/mtu3_hw_regs.h
 create mode 100644 drivers/usb/mtu3/mtu3_plat.c
 create mode 100644 drivers/usb/mtu3/mtu3_qmu.c
 create mode 100644 drivers/usb/mtu3/mtu3_qmu.h

-- 
1.7.9.5

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

* [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
  2016-05-31  5:52 Add MediaTek USB3 DRD Driver Chunfeng Yun
@ 2016-05-31  5:52 ` Chunfeng Yun
  2016-05-31 11:07   ` [PATCH v2,1/5] " Sergei Shtylyov
  2016-05-31  5:52 ` [PATCH v2,2/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Chunfeng Yun @ 2016-05-31  5:52 UTC (permalink / raw)
  To: linux-arm-kernel

Some resources, such as IPPC register etc, shared with device
driver are moved into common glue layer when xHCI driver is the
host side of dual-role mode and they should be changed as optional
properties if they are required ones before. For clarity, add
a new part of binding to support host side of dual-role mode.

Additionally add optional properties of pinctrl for host only mode

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 .../devicetree/bindings/usb/mt8173-xhci.txt        |   48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
index b3a7ffa..542e3fa 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
@@ -2,6 +2,14 @@ MT8173 xHCI
 
 The device node for Mediatek SOC USB3.0 host controller
 
+There are two scenarios: the first one only supports xHCI driver;
+the second one supports dual-role mode, and the host is based on xHCI
+driver. Take account of backward compatibility, we divide bindings
+into two parts.
+
+1st: only supports xHCI driver
+------------------------------------------------------------------------
+
 Required properties:
  - compatible : should contain "mediatek,mt8173-xhci"
  - reg : specifies physical base address and size of the registers,
@@ -27,6 +35,9 @@ Optional properties:
 	control register, it depends on "mediatek,wakeup-src".
  - vbus-supply : reference to the VBUS regulator;
  - usb3-lpm-capable : supports USB3.0 LPM
+ - pinctl-names : a pinctrl state named "default" must be defined
+ - pinctrl-0 : pin control group
+	See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
 
 Example:
 usb30: usb at 11270000 {
@@ -49,3 +60,40 @@ usb30: usb at 11270000 {
 	mediatek,syscon-wakeup = <&pericfg>;
 	mediatek,wakeup-src = <1>;
 };
+
+2nd: dual-role mode with xHCI driver
+------------------------------------------------------------------------
+
+In the case, xhci is added as subnode to mtu3. An example and the DT binding
+details of mtu3 can be found in:
+Documentation/devicetree/bindings/usb/mtu3.txt
+
+Required properties:
+ - compatible : should contain "mediatek,mt8173-xhci"
+ - reg : specifies physical base address and size of the registers,
+	should be only for xHCI IP registers
+ - interrupts : interrupt used by the host controller
+ - power-domains : a phandle to USB power domain node to control USB's
+	mtcmos
+ - vusb33-supply : regulator of USB avdd3.3v
+
+ - clocks : a list of phandle + clock-specifier pairs, one for each
+	entry in clock-names
+ - clock-names : must be
+	"sys_ck": for clock of xHCI MAC
+
+Optional properties:
+ - vbus-supply : reference to the VBUS regulator;
+ - usb3-lpm-capable : supports USB3.0 LPM
+
+Example:
+usb30: usb at 11270000 {
+	compatible = "mediatek,mt8173-xhci";
+	reg = <0 0x11270000 0 0x1000>;
+	interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+	power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+	clocks = <&topckgen CLK_TOP_USB30_SEL>;
+	clock-names = "sys_ck";
+	vusb33-supply = <&mt6397_vusb_reg>;
+	usb3-lpm-capable;
+};
-- 
1.7.9.5

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

* [PATCH v2,2/5] usb: xhci-mtk: make IPPC register optional
  2016-05-31  5:52 Add MediaTek USB3 DRD Driver Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
@ 2016-05-31  5:52 ` Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2,5/5] arm64: dts: mediatek: add USB3 DRD driver Chunfeng Yun
  3 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2016-05-31  5:52 UTC (permalink / raw)
  To: linux-arm-kernel

Make IPPC register optional to support host side of dual-role mode,
due to it is moved into common glue layer for simplification.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c |   32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 79959f1..dc86832 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -94,6 +94,9 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
 	int ret;
 	int i;
 
+	if (ippc == NULL)
+		return 0;
+
 	/* power on host ip */
 	value = readl(&ippc->ip_pw_ctr1);
 	value &= ~CTRL1_IP_HOST_PDN;
@@ -139,6 +142,9 @@ static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk)
 	int ret;
 	int i;
 
+	if (ippc == NULL)
+		return 0;
+
 	/* power down all u3 ports */
 	for (i = 0; i < mtk->num_u3_ports; i++) {
 		value = readl(&ippc->u3_ctrl_p[i]);
@@ -173,6 +179,9 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
 	struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs;
 	u32 value;
 
+	if (ippc == NULL)
+		return 0;
+
 	/* reset whole ip */
 	value = readl(&ippc->ip_pw_ctr0);
 	value |= CTRL0_IP_SW_RST;
@@ -475,6 +484,7 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
 /* called during probe() after chip reset completes */
 static int xhci_mtk_setup(struct usb_hcd *hcd)
 {
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 	struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
 	int ret;
 
@@ -482,12 +492,21 @@ static int xhci_mtk_setup(struct usb_hcd *hcd)
 		ret = xhci_mtk_ssusb_config(mtk);
 		if (ret)
 			return ret;
+	}
+
+	ret = xhci_gen_setup(hcd, xhci_mtk_quirks);
+	if (ret)
+		return ret;
+
+	if (usb_hcd_is_primary_hcd(hcd)) {
+		mtk->num_u3_ports = xhci->num_usb3_ports;
+		mtk->num_u2_ports = xhci->num_usb2_ports;
 		ret = xhci_mtk_sch_init(mtk);
 		if (ret)
 			return ret;
 	}
 
-	return xhci_gen_setup(hcd, xhci_mtk_quirks);
+	return ret;
 }
 
 static int xhci_mtk_probe(struct platform_device *pdev)
@@ -595,11 +614,14 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
+	mtk->ippc_regs = NULL;
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	mtk->ippc_regs = devm_ioremap_resource(dev, res);
-	if (IS_ERR(mtk->ippc_regs)) {
-		ret = PTR_ERR(mtk->ippc_regs);
-		goto put_usb2_hcd;
+	if (res) {	/* ippc register is optional */
+		mtk->ippc_regs = devm_ioremap_resource(dev, res);
+		if (IS_ERR(mtk->ippc_regs)) {
+			ret = PTR_ERR(mtk->ippc_regs);
+			goto put_usb2_hcd;
+		}
 	}
 
 	for (phy_num = 0; phy_num < mtk->num_phys; phy_num++) {
-- 
1.7.9.5

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

* [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings
  2016-05-31  5:52 Add MediaTek USB3 DRD Driver Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
  2016-05-31  5:52 ` [PATCH v2,2/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
@ 2016-05-31  5:52 ` Chunfeng Yun
  2016-06-03 13:34   ` Matthias Brugger
  2016-05-31  5:52 ` [PATCH v2,5/5] arm64: dts: mediatek: add USB3 DRD driver Chunfeng Yun
  3 siblings, 1 reply; 9+ messages in thread
From: Chunfeng Yun @ 2016-05-31  5:52 UTC (permalink / raw)
  To: linux-arm-kernel

add a DT binding doc for MediaTek USB3 DRD driver

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 Documentation/devicetree/bindings/usb/mtu3.txt |   85 ++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mtu3.txt

diff --git a/Documentation/devicetree/bindings/usb/mtu3.txt b/Documentation/devicetree/bindings/usb/mtu3.txt
new file mode 100644
index 0000000..571ae8b
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mtu3.txt
@@ -0,0 +1,85 @@
+The device node for Mediatek USB3.0 DRD controller
+
+Required properties:
+ - compatible : should be "mediatek,mt8173-mtu3"
+ - reg : specifies physical base address and size of the registers
+ - reg-names: should be "mac" for device IP and "ippc" for IP port control
+ - interrupts : interrupt used by the device IP
+ - power-domains : a phandle to USB power domain node to control USB's
+	mtcmos
+ - vusb33-supply : regulator of USB avdd3.3v
+ - clocks : a list of phandle + clock-specifier pairs, one for each
+	entry in clock-names
+ - clock-names : must contain "sys_ck" for clock of controller;
+	"wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are
+	depends on "mediatek,enable-wakeup"
+ - phys : a list of phandle + phy specifier pairs
+ - dr_mode : should be one of "host", "peripheral" or "otg",
+	refer to usb/generic.txt
+
+Optional properties:
+ - #address-cells, #size-cells : should be '2' if the device has sub-nodes
+	with 'reg' property
+ - ranges : allows valid 1:1 translation between child's address space and
+	parent's address space
+ - extcon : external connector for vbus and idpin changes detection, needed
+	when supports dual-role mode.
+ - vbus-supply : reference to the VBUS regulator, needed when supports
+	dual-role mode.
+ - pinctl-names : a pinctrl state named "default" must be defined,
+	"id_float" and "id_ground" are optinal which depends on
+	"mediatek,enable-manual-drd"
+ - pinctrl-0 : pin control group
+	See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+
+ - maximum-speed : valid arguments are "super-speed", "high-speed" and
+	"full-speed"; refer to usb/generic.txt
+ - enable-manual-drd : supports manual dual-role switch via sysfs; only used
+	when receptacle is TYPE-A and also wants to support dual-role mode.
+ - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode
+ - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
+	control register, it depends on "mediatek,enable-wakeup".
+
+Sub-nodes:
+The xhci should be added as subnode to mtu3 as shown in the following example
+if host mode is enabled. The DT binding details of xhci can be found in:
+Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+
+Example:
+ssusb: usb at 11271000 {
+	compatible = "mediatek,mt8173-mtu3";
+	reg = <0 0x11271000 0 0x3000>,
+	      <0 0x11280700 0 0x0100>;
+	reg-names = "mac", "ippc";
+	interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
+	phys = <&phy_port0 PHY_TYPE_USB3>,
+	       <&phy_port1 PHY_TYPE_USB2>;
+	power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+	clocks = <&topckgen CLK_TOP_USB30_SEL>,
+		 <&pericfg CLK_PERI_USB0>,
+		 <&pericfg CLK_PERI_USB1>;
+	clock-names = "sys_ck",
+		      "wakeup_deb_p0",
+		      "wakeup_deb_p1";
+	vusb33-supply = <&mt6397_vusb_reg>;
+	vbus-supply = <&usb_p0_vbus>;
+	extcon = <&extcon_usb>;
+	dr_mode = "otg";
+	mediatek,enable-wakeup;
+	mediatek,syscon-wakeup = <&pericfg>;
+	#address-cells = <2>;
+	#size-cells = <2>;
+	ranges;
+	status = "disabled";
+
+	usb_host: xhci at 11270000 {
+		compatible = "mediatek,mt8173-xhci";
+		reg = <0 0x11270000 0 0x1000>;
+		interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+		power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+		clocks = <&topckgen CLK_TOP_USB30_SEL>;
+		clock-names = "sys_ck";
+		vusb33-supply = <&mt6397_vusb_reg>;
+		status = "disabled";
+	};
+};
-- 
1.7.9.5

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

* [PATCH v2,5/5] arm64: dts: mediatek: add USB3 DRD driver
  2016-05-31  5:52 Add MediaTek USB3 DRD Driver Chunfeng Yun
                   ` (2 preceding siblings ...)
  2016-05-31  5:52 ` [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings Chunfeng Yun
@ 2016-05-31  5:52 ` Chunfeng Yun
  3 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2016-05-31  5:52 UTC (permalink / raw)
  To: linux-arm-kernel

USB3 DRD driver is added for MT8173-EVB, and xHCI driver
becomes its subnode

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts |   46 +++++++++++++++++++++++++--
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    |   28 ++++++++++++----
 2 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 7453a47..682dfd7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -34,6 +34,11 @@
 
 	chosen { };
 
+	extcon_usb: extcon_iddig {
+		compatible = "linux,extcon-usb-gpio";
+		id-gpio = <&pio 16 GPIO_ACTIVE_HIGH>;
+	};
+
 	usb_p1_vbus: regulator at 0 {
 		compatible = "regulator-fixed";
 		regulator-name = "usb_vbus";
@@ -42,6 +47,16 @@
 		gpio = <&pio 130 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 	};
+
+	usb_p0_vbus: regulator at 1 {
+		compatible = "regulator-fixed";
+		regulator-name = "vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&pio 9 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+
 };
 
 &i2c1 {
@@ -205,6 +220,20 @@
 			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
 		};
 	};
+
+	usb_id_pins_float: usb_iddig_pull_up {
+		pins_iddig {
+			pinmux = <MT8173_PIN_16_IDDIG__FUNC_IDDIG>;
+			bias-pull-up;
+		};
+	};
+
+	usb_id_pins_ground: usb_iddig_pull_down {
+		pins_iddig {
+			pinmux = <MT8173_PIN_16_IDDIG__FUNC_IDDIG>;
+			bias-pull-down;
+		};
+	};
 };
 
 &pwm0 {
@@ -431,12 +460,25 @@
 	status = "okay";
 };
 
+&ssusb {
+	vusb33-supply = <&mt6397_vusb_reg>;
+	vbus-supply = <&usb_p0_vbus>;
+	extcon = <&extcon_usb>;
+	dr_mode = "otg";
+	mediatek,enable-wakeup;
+	pinctrl-names = "default", "id_float", "id_ground";
+	pinctrl-0 = <&usb_id_pins_float>;
+	pinctrl-1 = <&usb_id_pins_float>;
+	pinctrl-2 = <&usb_id_pins_ground>;
+	status = "okay";
+};
+
 &uart0 {
 	status = "okay";
 };
 
-&usb30 {
+&usb_host {
 	vusb33-supply = <&mt6397_vusb_reg>;
 	vbus-supply = <&usb_p1_vbus>;
-	mediatek,wakeup-src = <1>;
+	status = "okay";
 };
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 05f89c4..723ab6e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -608,11 +608,14 @@
 			status = "disabled";
 		};
 
-		usb30: usb at 11270000 {
-			compatible = "mediatek,mt8173-xhci";
-			reg = <0 0x11270000 0 0x1000>,
+		ssusb: usb at 11271000 {
+			compatible = "mediatek,mt8173-mtu3";
+			reg = <0 0x11271000 0 0x3000>,
 			      <0 0x11280700 0 0x0100>;
-			interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
+			phys = <&phy_port0 PHY_TYPE_USB3>,
+			       <&phy_port1 PHY_TYPE_USB2>;
 			power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
 			clocks = <&topckgen CLK_TOP_USB30_SEL>,
 				 <&pericfg CLK_PERI_USB0>,
@@ -620,10 +623,21 @@
 			clock-names = "sys_ck",
 				      "wakeup_deb_p0",
 				      "wakeup_deb_p1";
-			phys = <&phy_port0 PHY_TYPE_USB3>,
-			       <&phy_port1 PHY_TYPE_USB2>;
 			mediatek,syscon-wakeup = <&pericfg>;
-			status = "okay";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			usb_host: xhci at 11270000 {
+				compatible = "mediatek,mt8173-xhci";
+				reg = <0 0x11270000 0 0x1000>;
+				interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+				power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+				clocks = <&topckgen CLK_TOP_USB30_SEL>;
+				clock-names = "sys_ck";
+				status = "disabled";
+			};
 		};
 
 		u3phy: usb-phy at 11290000 {
-- 
1.7.9.5

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

* [PATCH v2,1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
  2016-05-31  5:52 ` [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
@ 2016-05-31 11:07   ` Sergei Shtylyov
  2016-06-01 12:04     ` chunfeng yun
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2016-05-31 11:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 5/31/2016 8:52 AM, Chunfeng Yun wrote:

> Some resources, such as IPPC register etc, shared with device
> driver are moved into common glue layer when xHCI driver is the
> host side of dual-role mode and they should be changed as optional
> properties if they are required ones before. For clarity, add
> a new part of binding to support host side of dual-role mode.
>
> Additionally add optional properties of pinctrl for host only mode
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  .../devicetree/bindings/usb/mt8173-xhci.txt        |   48 ++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> index b3a7ffa..542e3fa 100644
> --- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> @@ -2,6 +2,14 @@ MT8173 xHCI
>
>  The device node for Mediatek SOC USB3.0 host controller
>
> +There are two scenarios: the first one only supports xHCI driver;
> +the second one supports dual-role mode, and the host is based on xHCI
> +driver. Take account of backward compatibility, we divide bindings
> +into two parts.
> +
> +1st: only supports xHCI driver
> +------------------------------------------------------------------------
> +
>  Required properties:
>   - compatible : should contain "mediatek,mt8173-xhci"
>   - reg : specifies physical base address and size of the registers,
> @@ -27,6 +35,9 @@ Optional properties:
>  	control register, it depends on "mediatek,wakeup-src".
>   - vbus-supply : reference to the VBUS regulator;
>   - usb3-lpm-capable : supports USB3.0 LPM
> + - pinctl-names : a pinctrl state named "default" must be defined

    pinctrl-names.

> + - pinctrl-0 : pin control group
> +	See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
>
>  Example:
>  usb30: usb at 11270000 {
[...]

MBR, Sergei

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

* [PATCH v2,1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
  2016-05-31 11:07   ` [PATCH v2,1/5] " Sergei Shtylyov
@ 2016-06-01 12:04     ` chunfeng yun
  0 siblings, 0 replies; 9+ messages in thread
From: chunfeng yun @ 2016-06-01 12:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Tue, 2016-05-31 at 14:07 +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 5/31/2016 8:52 AM, Chunfeng Yun wrote:
> 
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >  .../devicetree/bindings/usb/mt8173-xhci.txt        |   48 ++++++++++++++++++++
> >  1 file changed, 48 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> > index b3a7ffa..542e3fa 100644
> > --- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> > +++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> > @@ -2,6 +2,14 @@ MT8173 xHCI
> >
> >  The device node for Mediatek SOC USB3.0 host controller
[...]
> >  Required properties:
> >   - compatible : should contain "mediatek,mt8173-xhci"
> >   - reg : specifies physical base address and size of the registers,
> > @@ -27,6 +35,9 @@ Optional properties:
> >  	control register, it depends on "mediatek,wakeup-src".
> >   - vbus-supply : reference to the VBUS regulator;
> >   - usb3-lpm-capable : supports USB3.0 LPM
> > + - pinctl-names : a pinctrl state named "default" must be defined
> 
>     pinctrl-names.
> 
Thanks.

> > + - pinctrl-0 : pin control group
> > +	See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
> >
> >  Example:
> >  usb30: usb at 11270000 {
> [...]
> 
> MBR, Sergei
> 

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

* [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings
  2016-05-31  5:52 ` [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings Chunfeng Yun
@ 2016-06-03 13:34   ` Matthias Brugger
  2016-06-05  9:33     ` chunfeng yun
  0 siblings, 1 reply; 9+ messages in thread
From: Matthias Brugger @ 2016-06-03 13:34 UTC (permalink / raw)
  To: linux-arm-kernel



On 31/05/16 07:52, Chunfeng Yun wrote:
> add a DT binding doc for MediaTek USB3 DRD driver
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>   Documentation/devicetree/bindings/usb/mtu3.txt |   85 ++++++++++++++++++++++++
>   1 file changed, 85 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/usb/mtu3.txt
>
> diff --git a/Documentation/devicetree/bindings/usb/mtu3.txt b/Documentation/devicetree/bindings/usb/mtu3.txt
> new file mode 100644
> index 0000000..571ae8b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/mtu3.txt

The file should be called mt8173-mtu3.txt to be in line with mt8173-xhci.txt

> @@ -0,0 +1,85 @@
> +The device node for Mediatek USB3.0 DRD controller
> +
> +Required properties:
> + - compatible : should be "mediatek,mt8173-mtu3"
> + - reg : specifies physical base address and size of the registers
> + - reg-names: should be "mac" for device IP and "ippc" for IP port control
> + - interrupts : interrupt used by the device IP
> + - power-domains : a phandle to USB power domain node to control USB's
> +	mtcmos
> + - vusb33-supply : regulator of USB avdd3.3v
> + - clocks : a list of phandle + clock-specifier pairs, one for each
> +	entry in clock-names
> + - clock-names : must contain "sys_ck" for clock of controller;
> +	"wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are
> +	depends on "mediatek,enable-wakeup"
> + - phys : a list of phandle + phy specifier pairs
> + - dr_mode : should be one of "host", "peripheral" or "otg",
> +	refer to usb/generic.txt
> +
> +Optional properties:
> + - #address-cells, #size-cells : should be '2' if the device has sub-nodes
> +	with 'reg' property
> + - ranges : allows valid 1:1 translation between child's address space and
> +	parent's address space
> + - extcon : external connector for vbus and idpin changes detection, needed
> +	when supports dual-role mode.
> + - vbus-supply : reference to the VBUS regulator, needed when supports
> +	dual-role mode.
> + - pinctl-names : a pinctrl state named "default" must be defined,
> +	"id_float" and "id_ground" are optinal which depends on
> +	"mediatek,enable-manual-drd"

So pinctrl is optional, but if you put it, you need at least "default"?

Apart from that, DT maintainers prefer to have the binding patches at 
the beginning of a series, so it's easier for them to not oversee any.

Regards,
Matthias

> + - pinctrl-0 : pin control group
> +	See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
> +
> + - maximum-speed : valid arguments are "super-speed", "high-speed" and
> +	"full-speed"; refer to usb/generic.txt
> + - enable-manual-drd : supports manual dual-role switch via sysfs; only used
> +	when receptacle is TYPE-A and also wants to support dual-role mode.
> + - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode
> + - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
> +	control register, it depends on "mediatek,enable-wakeup".
> +
> +Sub-nodes:
> +The xhci should be added as subnode to mtu3 as shown in the following example
> +if host mode is enabled. The DT binding details of xhci can be found in:
> +Documentation/devicetree/bindings/usb/mt8173-xhci.txt
> +
> +Example:
> +ssusb: usb at 11271000 {
> +	compatible = "mediatek,mt8173-mtu3";
> +	reg = <0 0x11271000 0 0x3000>,
> +	      <0 0x11280700 0 0x0100>;
> +	reg-names = "mac", "ippc";
> +	interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
> +	phys = <&phy_port0 PHY_TYPE_USB3>,
> +	       <&phy_port1 PHY_TYPE_USB2>;
> +	power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> +	clocks = <&topckgen CLK_TOP_USB30_SEL>,
> +		 <&pericfg CLK_PERI_USB0>,
> +		 <&pericfg CLK_PERI_USB1>;
> +	clock-names = "sys_ck",
> +		      "wakeup_deb_p0",
> +		      "wakeup_deb_p1";
> +	vusb33-supply = <&mt6397_vusb_reg>;
> +	vbus-supply = <&usb_p0_vbus>;
> +	extcon = <&extcon_usb>;
> +	dr_mode = "otg";
> +	mediatek,enable-wakeup;
> +	mediatek,syscon-wakeup = <&pericfg>;
> +	#address-cells = <2>;
> +	#size-cells = <2>;
> +	ranges;
> +	status = "disabled";
> +
> +	usb_host: xhci at 11270000 {
> +		compatible = "mediatek,mt8173-xhci";
> +		reg = <0 0x11270000 0 0x1000>;
> +		interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> +		power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> +		clocks = <&topckgen CLK_TOP_USB30_SEL>;
> +		clock-names = "sys_ck";
> +		vusb33-supply = <&mt6397_vusb_reg>;
> +		status = "disabled";
> +	};
> +};
>

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

* [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings
  2016-06-03 13:34   ` Matthias Brugger
@ 2016-06-05  9:33     ` chunfeng yun
  0 siblings, 0 replies; 9+ messages in thread
From: chunfeng yun @ 2016-06-05  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2016-06-03 at 15:34 +0200, Matthias Brugger wrote:
> 
> On 31/05/16 07:52, Chunfeng Yun wrote:
> > add a DT binding doc for MediaTek USB3 DRD driver
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   Documentation/devicetree/bindings/usb/mtu3.txt |   85 ++++++++++++++++++++++++
> >   1 file changed, 85 insertions(+)
> >   create mode 100644 Documentation/devicetree/bindings/usb/mtu3.txt
> >
> > diff --git a/Documentation/devicetree/bindings/usb/mtu3.txt b/Documentation/devicetree/bindings/usb/mtu3.txt
> > new file mode 100644
> > index 0000000..571ae8b
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/mtu3.txt
> 
> The file should be called mt8173-mtu3.txt to be in line with mt8173-xhci.txt
> Ok, I will rename it
> 
> > @@ -0,0 +1,85 @@
> > +The device node for Mediatek USB3.0 DRD controller
> > +
> > +Required properties:
> > + - compatible : should be "mediatek,mt8173-mtu3"
> > + - reg : specifies physical base address and size of the registers
> > + - reg-names: should be "mac" for device IP and "ippc" for IP port control
> > + - interrupts : interrupt used by the device IP
> > + - power-domains : a phandle to USB power domain node to control USB's
> > +	mtcmos
> > + - vusb33-supply : regulator of USB avdd3.3v
> > + - clocks : a list of phandle + clock-specifier pairs, one for each
> > +	entry in clock-names
> > + - clock-names : must contain "sys_ck" for clock of controller;
> > +	"wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are
> > +	depends on "mediatek,enable-wakeup"
> > + - phys : a list of phandle + phy specifier pairs
> > + - dr_mode : should be one of "host", "peripheral" or "otg",
> > +	refer to usb/generic.txt
> > +
> > +Optional properties:
> > + - #address-cells, #size-cells : should be '2' if the device has sub-nodes
> > +	with 'reg' property
> > + - ranges : allows valid 1:1 translation between child's address space and
> > +	parent's address space
> > + - extcon : external connector for vbus and idpin changes detection, needed
> > +	when supports dual-role mode.
> > + - vbus-supply : reference to the VBUS regulator, needed when supports
> > +	dual-role mode.
> > + - pinctl-names : a pinctrl state named "default" must be defined,
> > +	"id_float" and "id_ground" are optinal which depends on
> > +	"mediatek,enable-manual-drd"
> 
> So pinctrl is optional, but if you put it, you need at least "default"?
Yes, the first one is "default".

> 
> Apart from that, DT maintainers prefer to have the binding patches at 
> the beginning of a series, so it's easier for them to not oversee any.
> Ok.

Thanks a lot.
> Regards,
> Matthias

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

end of thread, other threads:[~2016-06-05  9:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-31  5:52 Add MediaTek USB3 DRD Driver Chunfeng Yun
2016-05-31  5:52 ` [PATCH v2, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
2016-05-31 11:07   ` [PATCH v2,1/5] " Sergei Shtylyov
2016-06-01 12:04     ` chunfeng yun
2016-05-31  5:52 ` [PATCH v2,2/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
2016-05-31  5:52 ` [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings Chunfeng Yun
2016-06-03 13:34   ` Matthias Brugger
2016-06-05  9:33     ` chunfeng yun
2016-05-31  5:52 ` [PATCH v2,5/5] arm64: dts: mediatek: add USB3 DRD driver Chunfeng Yun

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