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

>From 99e428a1808c8ca91ff473d487b52ca5d355d875 Mon Sep 17 00:00:00 2001
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: Mon, 5 Sep 2016 10:27:07 +0800
Subject: [PATCH v6, 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 v6:
1. handle endianness of GPD and SETUP data
2. remove dummy error log and return suitable error number
3. cancel delay work when deregiseter driver

Change in v5:
1. modify some comments
2. rename some unsuitable variables
3. add reg-names property for host node
4. add USB_MTU3_DEBUG to control debug messages

Change in v4:
1. fix build errors on non-mediatek platforms
2. provide manual dual-role switch via debugfs instead of sysfs

Change in v3:
1. fix some typo error
2. rename mtu3.txt to mt8173-mtu3.txt

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
  dt-bindings: mt8173-mtu3: add devicetree bindings
  usb: xhci-mtk: make IPPC register optional
  usb: Add MediaTek USB3 DRD Driver
  arm64: dts: mediatek: add USB3 DRD driver

 .../devicetree/bindings/usb/mt8173-mtu3.txt        |   87 ++
 .../devicetree/bindings/usb/mt8173-xhci.txt        |   54 +-
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts        |   46 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi           |   29 +-
 drivers/usb/Kconfig                                |    2 +
 drivers/usb/Makefile                               |    1 +
 drivers/usb/host/xhci-mtk.c                        |   36 +-
 drivers/usb/mtu3/Kconfig                           |   54 ++
 drivers/usb/mtu3/Makefile                          |   19 +
 drivers/usb/mtu3/mtu3.h                            |  422 ++++++++++
 drivers/usb/mtu3/mtu3_core.c                       |  871 +++++++++++++++++++
 drivers/usb/mtu3/mtu3_dr.c                         |  379 +++++++++
 drivers/usb/mtu3/mtu3_dr.h                         |  108 +++
 drivers/usb/mtu3/mtu3_gadget.c                     |  731 ++++++++++++++++
 drivers/usb/mtu3/mtu3_gadget_ep0.c                 |  883 ++++++++++++++++++++
 drivers/usb/mtu3/mtu3_host.c                       |  294 +++++++
 drivers/usb/mtu3/mtu3_hw_regs.h                    |  473 +++++++++++
 drivers/usb/mtu3/mtu3_plat.c                       |  490 +++++++++++
 drivers/usb/mtu3/mtu3_qmu.c                        |  599 +++++++++++++
 drivers/usb/mtu3/mtu3_qmu.h                        |   43 +
 20 files changed, 5603 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/mt8173-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] 10+ messages in thread

* [RESEND PATCH v6, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
  2016-09-21  5:54 [RESEND PATCH v6, 0/5] Add MediaTek USB3 DRD Driver Chunfeng Yun
@ 2016-09-21  5:54 ` Chunfeng Yun
  2016-09-21  5:54 ` [RESEND PATCH v6, 2/5] dt-bindings: mt8173-mtu3: add devicetree bindings Chunfeng Yun
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-09-21  5:54 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>
Acked-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/usb/mt8173-xhci.txt        |   54 +++++++++++++++++++-
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
index b3a7ffa..2a930bd 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
@@ -2,10 +2,18 @@ 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,
-	the first one for MAC, the second for IPPC
+ - reg : specifies physical base address and size of the registers
+ - reg-names: should be "mac" for xHCI MAC and "ippc" for IP port control
  - interrupts : interrupt used by the controller
  - power-domains : a phandle to USB power domain node to control USB's
 	mtcmos
@@ -27,12 +35,16 @@ Optional properties:
 	control register, it depends on "mediatek,wakeup-src".
  - vbus-supply : reference to the VBUS regulator;
  - usb3-lpm-capable : supports USB3.0 LPM
+ - pinctrl-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 {
 	compatible = "mediatek,mt8173-xhci";
 	reg = <0 0x11270000 0 0x1000>,
 	      <0 0x11280700 0 0x0100>;
+	reg-names = "mac", "ippc";
 	interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
 	power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
 	clocks = <&topckgen CLK_TOP_USB30_SEL>,
@@ -49,3 +61,41 @@ 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
+ - reg-names: should be "mac" for xHCI MAC
+ - 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>;
+	reg-names = "mac";
+	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] 10+ messages in thread

* [RESEND PATCH v6, 2/5] dt-bindings: mt8173-mtu3: add devicetree bindings
  2016-09-21  5:54 [RESEND PATCH v6, 0/5] Add MediaTek USB3 DRD Driver Chunfeng Yun
  2016-09-21  5:54 ` [RESEND PATCH v6, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
@ 2016-09-21  5:54 ` Chunfeng Yun
  2016-09-21  5:54 ` [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-09-21  5:54 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>
Acked-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/usb/mt8173-mtu3.txt        |   87 ++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mt8173-mtu3.txt

diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
new file mode 100644
index 0000000..e049d19
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
@@ -0,0 +1,87 @@
+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 debugfs; usually
+	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>;
+		reg-names = "mac";
+		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] 10+ messages in thread

* [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional
  2016-09-21  5:54 [RESEND PATCH v6, 0/5] Add MediaTek USB3 DRD Driver Chunfeng Yun
  2016-09-21  5:54 ` [RESEND PATCH v6, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
  2016-09-21  5:54 ` [RESEND PATCH v6, 2/5] dt-bindings: mt8173-mtu3: add devicetree bindings Chunfeng Yun
@ 2016-09-21  5:54 ` Chunfeng Yun
  2016-10-09  6:50   ` Chunfeng Yun
  2016-10-10 10:55   ` Matthias Brugger
  2016-09-21  5:54 ` [RESEND PATCH v6, 5/5] arm64: dts: mediatek: add USB3 DRD driver Chunfeng Yun
       [not found] ` <1474437277-27201-5-git-send-email-chunfeng.yun@mediatek.com>
  4 siblings, 2 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-09-21  5:54 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 |   36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 79959f1..4bf99b9 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)
@@ -586,7 +605,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	mtk->hcd = platform_get_drvdata(pdev);
 	platform_set_drvdata(pdev, mtk);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac");
 	hcd->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(hcd->regs)) {
 		ret = PTR_ERR(hcd->regs);
@@ -595,11 +614,14 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	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;
+	mtk->ippc_regs = NULL;
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc");
+	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] 10+ messages in thread

* [RESEND PATCH v6, 5/5] arm64: dts: mediatek: add USB3 DRD driver
  2016-09-21  5:54 [RESEND PATCH v6, 0/5] Add MediaTek USB3 DRD Driver Chunfeng Yun
                   ` (2 preceding siblings ...)
  2016-09-21  5:54 ` [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
@ 2016-09-21  5:54 ` Chunfeng Yun
       [not found] ` <1474437277-27201-5-git-send-email-chunfeng.yun@mediatek.com>
  4 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-09-21  5:54 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    |   29 +++++++++++++----
 2 files changed, 66 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 10f638f..925948a 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -668,11 +668,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>,
@@ -680,10 +683,22 @@
 			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>;
+				reg-names = "mac";
+				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] 10+ messages in thread

* [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional
  2016-09-21  5:54 ` [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
@ 2016-10-09  6:50   ` Chunfeng Yun
  2016-10-10 10:55   ` Matthias Brugger
  1 sibling, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-10-09  6:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2016-09-21 at 13:54 +0800, Chunfeng Yun wrote:
> 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 |   36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)

Hi Mathias,

    Would you please take a little time out of your busy schedule and
help review this patch?

    Thank you very much.

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

* [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional
  2016-09-21  5:54 ` [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
  2016-10-09  6:50   ` Chunfeng Yun
@ 2016-10-10 10:55   ` Matthias Brugger
  2016-10-11  2:44     ` Chunfeng Yun
  1 sibling, 1 reply; 10+ messages in thread
From: Matthias Brugger @ 2016-10-10 10:55 UTC (permalink / raw)
  To: linux-arm-kernel



On 09/21/2016 07:54 AM, Chunfeng Yun wrote:
> 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 |   36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> index 79959f1..4bf99b9 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;
> +

I would prefer to add a flag/bool in xhci_hcd_mtk to signal the absence 
of the ippc. Or at least use a macro which checks the presence before 
calling any of this three functions.

Regards,
Matthias
>  	/* 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)
> @@ -586,7 +605,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
>  	mtk->hcd = platform_get_drvdata(pdev);
>  	platform_set_drvdata(pdev, mtk);
>
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac");
>  	hcd->regs = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(hcd->regs)) {
>  		ret = PTR_ERR(hcd->regs);
> @@ -595,11 +614,14 @@ static int xhci_mtk_probe(struct platform_device *pdev)
>  	hcd->rsrc_start = res->start;
>  	hcd->rsrc_len = resource_size(res);
>
> -	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;
> +	mtk->ippc_regs = NULL;
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc");
> +	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++) {
>

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

* [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional
  2016-10-10 10:55   ` Matthias Brugger
@ 2016-10-11  2:44     ` Chunfeng Yun
  0 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2016-10-11  2:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2016-10-10 at 12:55 +0200, Matthias Brugger wrote:
> 
> On 09/21/2016 07:54 AM, Chunfeng Yun wrote:
> > 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 |   36 +++++++++++++++++++++++++++++-------
> >  1 file changed, 29 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > index 79959f1..4bf99b9 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;
> > +
> 
> I would prefer to add a flag/bool in xhci_hcd_mtk to signal the absence 
> of the ippc. Or at least use a macro which checks the presence before 
> calling any of this three functions.

Ok. I will modify it later.

thanks.
> 
> Regards,
> Matthias

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

* [RESEND PATCH v6, 4/5] usb: Add MediaTek USB3 DRD Driver
       [not found]   ` <49293f1b-42b5-f06b-8fdc-f46fe996e237@gmail.com>
@ 2016-10-11  3:14     ` Chunfeng Yun
  2016-10-11 10:23       ` Matthias Brugger
  0 siblings, 1 reply; 10+ messages in thread
From: Chunfeng Yun @ 2016-10-11  3:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2016-10-10 at 13:00 +0200, Matthias Brugger wrote:
> 
> On 09/21/2016 07:54 AM, Chunfeng Yun wrote:
> > This patch adds support for the MediaTek USB3 controller
> > integrated into MT8173. It can be configured as Dual-Role
> > Device (DRD), Peripheral Only and Host Only (xHCI) modes.
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >  drivers/usb/Kconfig                |    2 +
> >  drivers/usb/Makefile               |    1 +
> >  drivers/usb/mtu3/Kconfig           |   54 +++
> >  drivers/usb/mtu3/Makefile          |   19 +
> >  drivers/usb/mtu3/mtu3.h            |  422 +++++++++++++++++
> >  drivers/usb/mtu3/mtu3_core.c       |  871 +++++++++++++++++++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_dr.c         |  379 ++++++++++++++++
> >  drivers/usb/mtu3/mtu3_dr.h         |  108 +++++
> >  drivers/usb/mtu3/mtu3_gadget.c     |  731 +++++++++++++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_gadget_ep0.c |  883 ++++++++++++++++++++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_host.c       |  294 ++++++++++++
> >  drivers/usb/mtu3/mtu3_hw_regs.h    |  473 +++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_plat.c       |  490 ++++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_qmu.c        |  599 ++++++++++++++++++++++++
> >  drivers/usb/mtu3/mtu3_qmu.h        |   43 ++
> >  15 files changed, 5369 insertions(+)
> >  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
> >
> 
> As Oliver already said, this patch is quiet big which makes it difficult 
> to review.
> I propose to provide a first implementation with minimal functionality 
> and incremental patches on top of this when the first got merged.
> 
> You could split the patch in three series/parts:
> 1. Host only
> 2. Peripheral only
> 3. Dual mode
> 
> What do you think?

Ok, I'll split the patch into some small ones as many as possible.

Thanks a lot
> 
> Regards,
> Matthias
> 

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

* [RESEND PATCH v6, 4/5] usb: Add MediaTek USB3 DRD Driver
  2016-10-11  3:14     ` [RESEND PATCH v6, 4/5] usb: Add MediaTek USB3 DRD Driver Chunfeng Yun
@ 2016-10-11 10:23       ` Matthias Brugger
  0 siblings, 0 replies; 10+ messages in thread
From: Matthias Brugger @ 2016-10-11 10:23 UTC (permalink / raw)
  To: linux-arm-kernel



On 10/11/2016 05:14 AM, Chunfeng Yun wrote:
> On Mon, 2016-10-10 at 13:00 +0200, Matthias Brugger wrote:
>>
>> On 09/21/2016 07:54 AM, Chunfeng Yun wrote:
>>> This patch adds support for the MediaTek USB3 controller
>>> integrated into MT8173. It can be configured as Dual-Role
>>> Device (DRD), Peripheral Only and Host Only (xHCI) modes.
>>>
>>> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
>>> ---
>>>  drivers/usb/Kconfig                |    2 +
>>>  drivers/usb/Makefile               |    1 +
>>>  drivers/usb/mtu3/Kconfig           |   54 +++
>>>  drivers/usb/mtu3/Makefile          |   19 +
>>>  drivers/usb/mtu3/mtu3.h            |  422 +++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_core.c       |  871 +++++++++++++++++++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_dr.c         |  379 ++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_dr.h         |  108 +++++
>>>  drivers/usb/mtu3/mtu3_gadget.c     |  731 +++++++++++++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_gadget_ep0.c |  883 ++++++++++++++++++++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_host.c       |  294 ++++++++++++
>>>  drivers/usb/mtu3/mtu3_hw_regs.h    |  473 +++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_plat.c       |  490 ++++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_qmu.c        |  599 ++++++++++++++++++++++++
>>>  drivers/usb/mtu3/mtu3_qmu.h        |   43 ++
>>>  15 files changed, 5369 insertions(+)
>>>  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
>>>
>>
>> As Oliver already said, this patch is quiet big which makes it difficult
>> to review.
>> I propose to provide a first implementation with minimal functionality
>> and incremental patches on top of this when the first got merged.
>>
>> You could split the patch in three series/parts:
>> 1. Host only
>> 2. Peripheral only
>> 3. Dual mode
>>
>> What do you think?
>
> Ok, I'll split the patch into some small ones as many as possible.

There is no direct policy how to do that and it depends a bit on every 
maintainer what he prefers. As a rule of thumb each commit should 
compile on it's own without errors. This makes bisecting the kernel much 
easier.

Regards,
Matthias

>
> Thanks a lot
>>
>> Regards,
>> Matthias
>>
>
>

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

end of thread, other threads:[~2016-10-11 10:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-21  5:54 [RESEND PATCH v6, 0/5] Add MediaTek USB3 DRD Driver Chunfeng Yun
2016-09-21  5:54 ` [RESEND PATCH v6, 1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode Chunfeng Yun
2016-09-21  5:54 ` [RESEND PATCH v6, 2/5] dt-bindings: mt8173-mtu3: add devicetree bindings Chunfeng Yun
2016-09-21  5:54 ` [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional Chunfeng Yun
2016-10-09  6:50   ` Chunfeng Yun
2016-10-10 10:55   ` Matthias Brugger
2016-10-11  2:44     ` Chunfeng Yun
2016-09-21  5:54 ` [RESEND PATCH v6, 5/5] arm64: dts: mediatek: add USB3 DRD driver Chunfeng Yun
     [not found] ` <1474437277-27201-5-git-send-email-chunfeng.yun@mediatek.com>
     [not found]   ` <49293f1b-42b5-f06b-8fdc-f46fe996e237@gmail.com>
2016-10-11  3:14     ` [RESEND PATCH v6, 4/5] usb: Add MediaTek USB3 DRD Driver Chunfeng Yun
2016-10-11 10:23       ` Matthias Brugger

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