linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/13] usb: Add host and device support for RZ/A2
@ 2019-05-15 15:20 Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 01/13] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt


NOTE 1:
This series requires the follow patch from Shimoda-san.
  [PATCH v2] usb: renesas_usbhs: Use specific struct instead of USBHS_TYPE_* enums


NOTE 2:
The first 2 patches from the V3 series (add USB_X1 clock) were removed from this
V4 series because Simon already applied them.



For the most part, the RZ/A2 has the same USB 2.0 host and device
HW as the R-Car Gen3, so we can reuse a lot of the code.

However, there are a couple extra register bits, and the CFIFO
register 8-bit access works a little different.

There is a dedicated DMAC for the RZ/A2 USB Device HW, but we
have not been able to reliably get that working yet, so device
operation is pio only at the moment.

On the RZ/A2M eval board, both USB channels can be used as either
host or device. But, it's not set up for otg (ie, there are jumpers
and separate connectors). Therefore, below is an example of what it
would look like to enable USB channel 0 as a device instead of a host.

&usb2_phy0 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb0_pins>;
	dr_mode = "peripheral";
	status = "okay";
};

&usbhs0 {
	status = "okay";
};

Chris Brandt (13):
  phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  dt-bindings: rcar-gen3-phy-usb2: Document dr_mode
  dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support
  usb: renesas_usbhs: move flags to param
  usb: renesas_usbhs: add support for CNEN bit
  usb: renesas_usbhs: support byte addressable CFIFO
  usb: renesas_usbhs: Add support for RZ/A2
  dt-bindings: usb: renesas_usbhs: Add support for r7s9210
  ARM: dts: r7s9210: Add USB Host support
  ARM: dts: r7s9210: Add USB Device support
  ARM: dts: rza2mevb: Add USB Host support

 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 19 +++--
 .../devicetree/bindings/usb/renesas_usbhs.txt      |  2 +
 arch/arm/boot/dts/r7s9210-rza2mevb.dts             | 36 +++++++++
 arch/arm/boot/dts/r7s9210.dtsi                     | 90 ++++++++++++++++++++++
 drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 26 +++++++
 drivers/usb/renesas_usbhs/Makefile                 |  2 +-
 drivers/usb/renesas_usbhs/common.c                 | 44 +++++++----
 drivers/usb/renesas_usbhs/common.h                 |  3 +-
 drivers/usb/renesas_usbhs/fifo.c                   |  9 ++-
 drivers/usb/renesas_usbhs/rza.h                    |  1 +
 drivers/usb/renesas_usbhs/rza2.c                   | 72 +++++++++++++++++
 include/linux/usb/renesas_usbhs.h                  |  4 +
 12 files changed, 282 insertions(+), 26 deletions(-)
 create mode 100644 drivers/usb/renesas_usbhs/rza2.c

-- 
2.16.1


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

* [PATCH v4 01/13] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 02/13] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

The RZ/A2 has an optional dedicated 48MHz clock input for the PLL.
If a clock node named 'usb_x1' exists and set to non-zero, then we can
assume we want it use it.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v4:
 * added reviewed-by
v3:
 * avoid magic number
 * use devm_clk_get and clk_get_rate
v2:
 * use 'usb_x1' clock node instead of 'renesas,uses_usb_x1' property
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 1322185a00a2..06e0fc804226 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -12,6 +12,7 @@
 #include <linux/extcon-provider.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -34,6 +35,7 @@
 #define USB2_VBCTRL		0x60c
 #define USB2_LINECTRL1		0x610
 #define USB2_ADPCTRL		0x630
+#define USB2_PHYCLK_CTRL	0x644
 
 /* INT_ENABLE */
 #define USB2_INT_ENABLE_UCOM_INTEN	BIT(3)
@@ -75,6 +77,9 @@
 #define USB2_ADPCTRL_IDPULLUP		BIT(5)	/* 1 = ID sampling is enabled */
 #define USB2_ADPCTRL_DRVVBUS		BIT(4)
 
+/* PHYCLK_CTRL */
+#define PHYCLK_CTRL_UCLKSEL		BIT(0)
+
 #define NUM_OF_PHYS			4
 enum rcar_gen3_phy_index {
 	PHY_INDEX_BOTH_HC,
@@ -110,6 +115,7 @@ struct rcar_gen3_chan {
 	bool extcon_host;
 	bool is_otg_channel;
 	bool uses_otg_pins;
+	bool uses_usb_x1;
 };
 
 /*
@@ -391,6 +397,9 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
 	void __iomem *usb2_base = channel->base;
 	u32 val;
 
+	if (channel->uses_usb_x1)
+		writel(PHYCLK_CTRL_UCLKSEL, usb2_base + USB2_PHYCLK_CTRL);
+
 	/* Initialize USB2 part */
 	val = readl(usb2_base + USB2_INT_ENABLE);
 	val |= USB2_INT_ENABLE_UCOM_INTEN | rphy->int_enable_bits;
@@ -583,6 +592,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rcar_gen3_chan *channel;
 	struct phy_provider *provider;
+	struct clk *usb_x1_clk;
 	struct resource *res;
 	const struct phy_ops *phy_usb2_ops;
 	int irq, ret = 0, i;
@@ -630,6 +640,10 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 		}
 	}
 
+	usb_x1_clk = devm_clk_get(dev, "usb_x1");
+	if (!IS_ERR(usb_x1_clk) && clk_get_rate(usb_x1_clk))
+		channel->uses_usb_x1 = true;
+
 	/*
 	 * devm_phy_create() will call pm_runtime_enable(&phy->dev);
 	 * And then, phy-core will manage runtime pm for this device.
-- 
2.16.1


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

* [PATCH v4 02/13] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 01/13] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 03/13] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Document the USB_X1 input and add clock-names to identify
functional and USB_X1 clocks.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v4:
 * 'Name' to 'Names'
 * "fclk" to "fck"
 * added reviewed-by
v3:
 * added clock names
v2:
 * removed 'use_usb_x1' option
 * document that 'usb_x1' clock node will be detected to determine if
   48MHz clock exists
---
 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index d46188f450bf..f05d2c39a556 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -28,7 +28,11 @@ Required properties:
 	      followed by the generic version.
 
 - reg: offset and length of the partial USB 2.0 Host register block.
-- clocks: clock phandle and specifier pair(s).
+- clocks: clock phandle and specifier pair(s). For SoCs that have a separate
+          dedicated USB_X1 input for the PLL, that is also listed.
+- clock-names: Names of the clocks. The functional clock shall be called "fck"
+	       and USB_X1 shall be called "usb_x1". If only one clock is listed,
+	       this property is not required.
 - #phy-cells: see phy-bindings.txt in the same directory, must be <1> (and
 	      using <0> is deprecated).
 
-- 
2.16.1


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

* [PATCH v4 03/13] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 01/13] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 02/13] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 04/13] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

When not using OTG, the PHY will need to know if it should function as
host or peripheral by checking dr_mode in the PHY node (not the parent
controller node).

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v4:
 * added reviewed-by
v3:
 * changed 'if' to 'switch'
 * use rcar_gen3_set_host_mode() instead of writel()
v2:
 * added braces to else statement
 * check if dr_mode is "host"
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 06e0fc804226..29da9c46ad9b 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -412,6 +412,18 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
 		if (rcar_gen3_needs_init_otg(channel))
 			rcar_gen3_init_otg(channel);
 		rphy->otg_initialized = true;
+	} else {
+		/* Not OTG, so dr_mode should be set in PHY node */
+		switch (usb_get_dr_mode(channel->dev)) {
+		case USB_DR_MODE_HOST:
+			rcar_gen3_set_host_mode(channel, 1);
+			break;
+		case USB_DR_MODE_PERIPHERAL:
+			rcar_gen3_set_host_mode(channel, 0);
+			break;
+		default:
+			break;
+		}
 	}
 
 	rphy->initialized = true;
-- 
2.16.1


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

* [PATCH v4 04/13] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (2 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 03/13] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 05/13] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support Chris Brandt
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Document the optional dr_mode property

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
 * added reviewed-by
---
 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index f05d2c39a556..fa58663b7641 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -50,6 +50,9 @@ channel as USB OTG:
 	       regulator will be managed during the PHY power on/off sequence.
 - renesas,no-otg-pins: boolean, specify when a board does not provide proper
 		       otg pins.
+- dr_mode: string, indicates the working mode for the PHY. Can be "host",
+           "peripheral", or "otg". Should be set if otg controller is not used.
+
 
 Example (R-Car H3):
 
-- 
2.16.1


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

* [PATCH v4 05/13] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (3 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 04/13] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 06/13] usb: renesas_usbhs: move flags to param Chris Brandt
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Document RZ/A2 (R7S9210) SoC bindings.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
 * added reviewed-by
---
 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
index fa58663b7641..7f7a2ed2c9b1 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -1,10 +1,12 @@
 * Renesas R-Car generation 3 USB 2.0 PHY
 
 This file provides information on what the device node for the R-Car generation
-3, RZ/G1C and RZ/G2 USB 2.0 PHY contain.
+3, RZ/G1C, RZ/G2 and RZ/A2 USB 2.0 PHY contain.
 
 Required properties:
-- compatible: "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470
+- compatible: "renesas,usb2-phy-r7s9210" if the device is a part of an R7S9210
+	      SoC.
+	      "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470
 	      SoC.
 	      "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1
 	      SoC.
@@ -20,8 +22,8 @@ Required properties:
 	      R8A77990 SoC.
 	      "renesas,usb2-phy-r8a77995" if the device is a part of an
 	      R8A77995 SoC.
-	      "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 or RZ/G2
-	      compatible device.
+	      "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3, RZ/G2 or
+	      RZ/A2 compatible device.
 
 	      When compatible with the generic version, nodes must list the
 	      SoC-specific version corresponding to the platform first
-- 
2.16.1


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

* [PATCH v4 06/13] usb: renesas_usbhs: move flags to param
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (4 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 05/13] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 07/13] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Move options from 'flags' field in private structure to param structure
where other options are already being kept.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
 * added reviewed-by
---
 drivers/usb/renesas_usbhs/common.c | 23 +++++++----------------
 drivers/usb/renesas_usbhs/common.h |  2 --
 include/linux/usb/renesas_usbhs.h  |  1 +
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 0ca89de7f842..1de7a44f3415 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -43,15 +43,6 @@
  *			| ....  |	+-----------+
  */
 
-
-#define USBHSF_RUNTIME_PWCTRL	(1 << 0)
-
-/* status */
-#define usbhsc_flags_init(p)   do {(p)->flags = 0; } while (0)
-#define usbhsc_flags_set(p, b) ((p)->flags |=  (b))
-#define usbhsc_flags_clr(p, b) ((p)->flags &= ~(b))
-#define usbhsc_flags_has(p, b) ((p)->flags &   (b))
-
 /*
  * platform call back
  *
@@ -479,7 +470,7 @@ static void usbhsc_hotplug(struct usbhs_priv *priv)
 		dev_dbg(&pdev->dev, "%s enable\n", __func__);
 
 		/* power on */
-		if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+		if (usbhs_get_dparam(priv, runtime_pwctrl))
 			usbhsc_power_ctrl(priv, enable);
 
 		/* bus init */
@@ -499,7 +490,7 @@ static void usbhsc_hotplug(struct usbhs_priv *priv)
 		usbhsc_bus_init(priv);
 
 		/* power off */
-		if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+		if (usbhs_get_dparam(priv, runtime_pwctrl))
 			usbhsc_power_ctrl(priv, enable);
 
 		usbhs_mod_change(priv, -1);
@@ -733,7 +724,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	/* FIXME */
 	/* runtime power control ? */
 	if (priv->pfunc.get_vbus)
-		usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL);
+		usbhs_get_dparam(priv, runtime_pwctrl) = 1;
 
 	/*
 	 * priv settings
@@ -807,7 +798,7 @@ static int usbhs_probe(struct platform_device *pdev)
 
 	/* power control */
 	pm_runtime_enable(&pdev->dev);
-	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
+	if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
 		usbhsc_power_ctrl(priv, 1);
 		usbhs_mod_autonomy_mode(priv);
 	}
@@ -848,7 +839,7 @@ static int usbhs_remove(struct platform_device *pdev)
 	dfunc->notify_hotplug = NULL;
 
 	/* power off */
-	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+	if (!usbhs_get_dparam(priv, runtime_pwctrl))
 		usbhsc_power_ctrl(priv, 0);
 
 	pm_runtime_disable(&pdev->dev);
@@ -873,7 +864,7 @@ static __maybe_unused int usbhsc_suspend(struct device *dev)
 		usbhs_mod_change(priv, -1);
 	}
 
-	if (mod || !usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+	if (mod || !usbhs_get_dparam(priv, runtime_pwctrl))
 		usbhsc_power_ctrl(priv, 0);
 
 	return 0;
@@ -884,7 +875,7 @@ static __maybe_unused int usbhsc_resume(struct device *dev)
 	struct usbhs_priv *priv = dev_get_drvdata(dev);
 	struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
+	if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
 		usbhsc_power_ctrl(priv, 1);
 		usbhs_mod_autonomy_mode(priv);
 	}
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index de1a6638bf68..1fbffb7bbc8f 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -260,8 +260,6 @@ struct usbhs_priv {
 
 	spinlock_t		lock;
 
-	u32 flags;
-
 	/*
 	 * module control
 	 */
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 53924f8e840c..17fae6e504cc 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -189,6 +189,7 @@ struct renesas_usbhs_driver_param {
 	u32 has_otg:1; /* for controlling PWEN/EXTLP */
 	u32 has_sudmac:1; /* for SUDMAC */
 	u32 has_usb_dmac:1; /* for USB-DMAC */
+	u32 runtime_pwctrl:1;
 #define USBHS_USB_DMAC_XFER_SIZE	32	/* hardcode the xfer size */
 };
 
-- 
2.16.1


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

* [PATCH v4 07/13] usb: renesas_usbhs: add support for CNEN bit
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (5 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 06/13] usb: renesas_usbhs: move flags to param Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 08/13] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

For some SoC, CNEN must be set for USB Device mode operation.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v3:
 * added reviewed-by
v2:
 * options are now held in param
---
 drivers/usb/renesas_usbhs/common.c | 6 ++++++
 drivers/usb/renesas_usbhs/common.h | 1 +
 include/linux/usb/renesas_usbhs.h  | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 1de7a44f3415..734fb4e542c5 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -114,6 +114,12 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable)
 	u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
 	u16 val  = HSE | USBE;
 
+	/* CNEN bit is required for function operation */
+	if (usbhs_get_dparam(priv, has_cnen)) {
+		mask |= CNEN;
+		val  |= CNEN;
+	}
+
 	/*
 	 * if enable
 	 *
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 1fbffb7bbc8f..de74ebd1a347 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -104,6 +104,7 @@ struct usbhs_priv;
 
 /* SYSCFG */
 #define SCKE	(1 << 10)	/* USB Module Clock Enable */
+#define CNEN	(1 << 8)	/* Single-ended receiver operation Enable */
 #define HSE	(1 << 7)	/* High-Speed Operation Enable */
 #define DCFM	(1 << 6)	/* Controller Function Select */
 #define DRPD	(1 << 5)	/* D+ Line/D- Line Resistance Control */
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 17fae6e504cc..9097a38fcda8 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -190,6 +190,7 @@ struct renesas_usbhs_driver_param {
 	u32 has_sudmac:1; /* for SUDMAC */
 	u32 has_usb_dmac:1; /* for USB-DMAC */
 	u32 runtime_pwctrl:1;
+	u32 has_cnen:1;
 #define USBHS_USB_DMAC_XFER_SIZE	32	/* hardcode the xfer size */
 };
 
-- 
2.16.1


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

* [PATCH v4 08/13] usb: renesas_usbhs: support byte addressable CFIFO
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (6 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 07/13] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 09/13] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Some SoC have a CFIFO register that is byte addressable. This means
when the CFIFO access is set to 32-bit, you can write 8-bit values to
addresses CFIFO+0, CFIFO+1, CFIFO+2, CFIFO+3.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v3:
 * added reviewed-by
v2:
 * options ahve moved from flags to param
---
 drivers/usb/renesas_usbhs/fifo.c  | 9 +++++++--
 include/linux/usb/renesas_usbhs.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 39fa2fc1b8b7..452b456ac24e 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -543,8 +543,13 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
 	}
 
 	/* the rest operation */
-	for (i = 0; i < len; i++)
-		iowrite8(buf[i], addr + (0x03 - (i & 0x03)));
+	if (usbhs_get_dparam(priv, cfifo_byte_addr)) {
+		for (i = 0; i < len; i++)
+			iowrite8(buf[i], addr + (i & 0x03));
+	} else {
+		for (i = 0; i < len; i++)
+			iowrite8(buf[i], addr + (0x03 - (i & 0x03)));
+	}
 
 	/*
 	 * variable update
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 9097a38fcda8..87043fd21d54 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -191,6 +191,7 @@ struct renesas_usbhs_driver_param {
 	u32 has_usb_dmac:1; /* for USB-DMAC */
 	u32 runtime_pwctrl:1;
 	u32 has_cnen:1;
+	u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
 #define USBHS_USB_DMAC_XFER_SIZE	32	/* hardcode the xfer size */
 };
 
-- 
2.16.1


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

* [PATCH v4 09/13] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (7 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 08/13] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 10/13] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

The RZ/A2 is similar to the R-Car Gen3 with some small differences.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v4:
 * Removed extra blank line
 * Removed 'if' from exit function
 * added reviewed-by
v3:
 * Removed check for CONFIG_GENERIC_PHY
 * rebase on top of Shimoda-san (v2) patch
v2:
 * combined RZA1 and RZA2 for fifo setting
 * added braces to make code easier to read
 * fixed and clean up usbhs_rza2_power_ctrl()
---
 drivers/usb/renesas_usbhs/Makefile |  2 +-
 drivers/usb/renesas_usbhs/common.c | 15 ++++++++
 drivers/usb/renesas_usbhs/rza.h    |  1 +
 drivers/usb/renesas_usbhs/rza2.c   | 72 ++++++++++++++++++++++++++++++++++++++
 include/linux/usb/renesas_usbhs.h  |  1 +
 5 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/renesas_usbhs/rza2.c

diff --git a/drivers/usb/renesas_usbhs/Makefile b/drivers/usb/renesas_usbhs/Makefile
index 5c5b51bb48ef..a1fed56b0957 100644
--- a/drivers/usb/renesas_usbhs/Makefile
+++ b/drivers/usb/renesas_usbhs/Makefile
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_USB_RENESAS_USBHS)	+= renesas_usbhs.o
 
-renesas_usbhs-y			:= common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o
+renesas_usbhs-y			:= common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o rza2.o
 
 ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),)
 	renesas_usbhs-y		+= mod_host.o
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 734fb4e542c5..c7c9c5d75a56 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -571,6 +571,17 @@ static const struct usbhs_of_data rza1_data = {
 	}
 };
 
+static const struct usbhs_of_data rza2_data = {
+	.platform_callback = &usbhs_rza2_ops,
+	.param = {
+		.type = USBHS_TYPE_RZA2,
+		.has_cnen = 1,
+		.cfifo_byte_addr = 1,
+		.pipe_configs = usbhsc_new_pipe,
+		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+	}
+};
+
 /*
  *		platform functions
  */
@@ -619,6 +630,10 @@ static const struct of_device_id usbhs_of_match[] = {
 		.compatible = "renesas,rza1-usbhs",
 		.data = &rza1_data,
 	},
+	{
+		.compatible = "renesas,rza2-usbhs",
+		.data = &rza2_data,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, usbhs_of_match);
diff --git a/drivers/usb/renesas_usbhs/rza.h b/drivers/usb/renesas_usbhs/rza.h
index ca917ca54f6d..073a53d1d442 100644
--- a/drivers/usb/renesas_usbhs/rza.h
+++ b/drivers/usb/renesas_usbhs/rza.h
@@ -2,3 +2,4 @@
 #include "common.h"
 
 extern const struct renesas_usbhs_platform_callback usbhs_rza1_ops;
+extern const struct renesas_usbhs_platform_callback usbhs_rza2_ops;
diff --git a/drivers/usb/renesas_usbhs/rza2.c b/drivers/usb/renesas_usbhs/rza2.c
new file mode 100644
index 000000000000..9d8551f93533
--- /dev/null
+++ b/drivers/usb/renesas_usbhs/rza2.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas USB driver RZ/A2 initialization and power control
+ *
+ * Copyright (C) 2019 Chris Brandt
+ * Copyright (C) 2019 Renesas Electronics Corporation
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/of_device.h>
+#include <linux/phy/phy.h>
+#include "common.h"
+#include "rza.h"
+
+static int usbhs_rza2_hardware_init(struct platform_device *pdev)
+{
+	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+	struct phy *phy = phy_get(&pdev->dev, "usb");
+
+	if (IS_ERR(phy))
+		return PTR_ERR(phy);
+
+	priv->phy = phy;
+	return 0;
+}
+
+static int usbhs_rza2_hardware_exit(struct platform_device *pdev)
+{
+	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+
+	phy_put(priv->phy);
+	priv->phy = NULL;
+
+	return 0;
+}
+
+static int usbhs_rza2_power_ctrl(struct platform_device *pdev,
+				void __iomem *base, int enable)
+{
+	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+	int retval = 0;
+
+	if (!priv->phy)
+		return -ENODEV;
+
+	if (enable) {
+		retval = phy_init(priv->phy);
+		usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM);
+		udelay(100);	/* Wait for PLL to become stable */
+		if (!retval)
+			retval = phy_power_on(priv->phy);
+	} else {
+		usbhs_bset(priv, SUSPMODE, SUSPM, 0);
+		phy_power_off(priv->phy);
+		phy_exit(priv->phy);
+	}
+
+	return retval;
+}
+
+static int usbhs_rza2_get_id(struct platform_device *pdev)
+{
+	return USBHS_GADGET;
+}
+
+const struct renesas_usbhs_platform_callback usbhs_rza2_ops = {
+	.hardware_init = usbhs_rza2_hardware_init,
+	.hardware_exit = usbhs_rza2_hardware_exit,
+	.power_ctrl = usbhs_rza2_power_ctrl,
+	.get_id = usbhs_rza2_get_id,
+};
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 87043fd21d54..3f53043fb56b 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -199,6 +199,7 @@ struct renesas_usbhs_driver_param {
 #define USBHS_TYPE_RCAR_GEN3		2
 #define USBHS_TYPE_RCAR_GEN3_WITH_PLL	3
 #define USBHS_TYPE_RZA1			4
+#define USBHS_TYPE_RZA2			5
 
 /*
  * option:
-- 
2.16.1


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

* [PATCH v4 10/13] dt-bindings: usb: renesas_usbhs: Add support for r7s9210
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (8 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 09/13] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support Chris Brandt
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Add support for r7s9210 (RZ/A2M) SoC

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v3:
 * added reviewed-by
v2:
 * fixed typo from copy/paste of RZ/A1 line
---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index b8acc2a994a8..e39255ea6e4f 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -20,9 +20,11 @@ Required properties:
 	- "renesas,usbhs-r8a77990" for r8a77990 (R-Car E3) compatible device
 	- "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device
 	- "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device
+	- "renesas,usbhs-r7s9210" for r7s9210 (RZ/A2) compatible device
 	- "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices
 	- "renesas,rcar-gen3-usbhs" for R-Car Gen3 or RZ/G2 compatible devices
 	- "renesas,rza1-usbhs" for RZ/A1 compatible device
+	- "renesas,rza2-usbhs" for RZ/A2 compatible device
 
 	When compatible with the generic version, nodes must list the
 	SoC-specific version corresponding to the platform first followed
-- 
2.16.1


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

* [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (9 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 10/13] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-20 11:42   ` Simon Horman
  2019-05-15 15:20 ` [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support Chris Brandt
  2019-05-15 15:20 ` [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support Chris Brandt
  12 siblings, 1 reply; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Add EHCI and OHCI host support for RZ/A2.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v4:
 * "fclk" to "fck"
 * changed phy reg size 0x10 -> 0x700
 * added reviewed-by
v3:
 * add usb_x1 as a clock source
 * add clock-names
v2:
  * changed to generic name usb@xxx
  * Add space between compatible strings
---
 arch/arm/boot/dts/r7s9210.dtsi | 66 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210.dtsi b/arch/arm/boot/dts/r7s9210.dtsi
index 73041f04fef5..066e6fed11aa 100644
--- a/arch/arm/boot/dts/r7s9210.dtsi
+++ b/arch/arm/boot/dts/r7s9210.dtsi
@@ -329,6 +329,72 @@
 			status = "disabled";
 		};
 
+		ohci0: usb@e8218000 {
+			compatible = "generic-ohci";
+			reg = <0xe8218000 0x100>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 61>;
+			phys = <&usb2_phy0>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
+		ehci0: usb@e8218100 {
+			compatible = "generic-ehci";
+			reg = <0xe8218100 0x100>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 61>;
+			phys = <&usb2_phy0>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
+		usb2_phy0: usb-phy@e8218200 {
+			compatible = "renesas,usb2-phy-r7s9210", "renesas,rcar-gen3-usb2-phy";
+			reg = <0xe8218200 0x700>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 61>, <&usb_x1_clk>;
+			clock-names = "fck", "usb_x1";
+			power-domains = <&cpg>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
+		ohci1: usb@e821a000 {
+			compatible = "generic-ohci";
+			reg = <0xe821a000 0x100>;
+			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 60>;
+			phys = <&usb2_phy1>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
+		ehci1: usb@e821a100 {
+			compatible = "generic-ehci";
+			reg = <0xe821a100 0x100>;
+			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 60>;
+			phys = <&usb2_phy1>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
+		usb2_phy1: usb-phy@e821a200 {
+			compatible = "renesas,usb2-phy-r7s9210", "renesas,rcar-gen3-usb2-phy";
+			reg = <0xe821a200 0x700>;
+			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 60>, <&usb_x1_clk>;
+			clock-names = "fck", "usb_x1";
+			power-domains = <&cpg>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
 		sdhi0: sd@e8228000 {
 			compatible = "renesas,sdhi-r7s9210";
 			reg = <0xe8228000 0x8c0>;
-- 
2.16.1


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

* [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (10 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-20 11:43   ` Simon Horman
  2019-05-15 15:20 ` [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support Chris Brandt
  12 siblings, 1 reply; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Add USB Device support for RZ/A2.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
 * added reviewed-by
v2:
 * changed to generic name usb@xxx
 * Add space between compatible strings
---
 arch/arm/boot/dts/r7s9210.dtsi | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210.dtsi b/arch/arm/boot/dts/r7s9210.dtsi
index 066e6fed11aa..3d0bbc1f4543 100644
--- a/arch/arm/boot/dts/r7s9210.dtsi
+++ b/arch/arm/boot/dts/r7s9210.dtsi
@@ -362,6 +362,18 @@
 			status = "disabled";
 		};
 
+		usbhs0: usb@e8219000 {
+			compatible = "renesas,usbhs-r7s9210", "renesas,rza2-usbhs";
+			reg = <0xe8219000 0x724>;
+			interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 61>;
+			renesas,buswait = <7>;
+			phys = <&usb2_phy0>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
 		ohci1: usb@e821a000 {
 			compatible = "generic-ohci";
 			reg = <0xe821a000 0x100>;
@@ -395,6 +407,18 @@
 			status = "disabled";
 		};
 
+		usbhs1: usb@e821b000 {
+			compatible = "renesas,usbhs-r7s9210", "renesas,rza2-usbhs";
+			reg = <0xe821b000 0x724>;
+			interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 60>;
+			renesas,buswait = <7>;
+			phys = <&usb2_phy1>;
+			phy-names = "usb";
+			power-domains = <&cpg>;
+			status = "disabled";
+		};
+
 		sdhi0: sd@e8228000 {
 			compatible = "renesas,sdhi-r7s9210";
 			reg = <0xe8228000 0x8c0>;
-- 
2.16.1


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

* [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support
  2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (11 preceding siblings ...)
  2019-05-15 15:20 ` [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support Chris Brandt
@ 2019-05-15 15:20 ` Chris Brandt
  2019-05-20 11:43   ` Simon Horman
  12 siblings, 1 reply; 17+ messages in thread
From: Chris Brandt @ 2019-05-15 15:20 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc,
	Chris Brandt

Enable USB Host support for both the Type-C connector on the CPU board
and the Type-A plug on the sub board.

Both boards are also capable of USB Device operation as well after the
appropriate Device Tree modifications.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
 * moved note about JP3
 * added reviewed-by
v2:
 * added blank line between nodes
 * removed 'r7s9210-' from patch title
 * removed 'renesas,uses_usb_x1' property
---
 arch/arm/boot/dts/r7s9210-rza2mevb.dts | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210-rza2mevb.dts b/arch/arm/boot/dts/r7s9210-rza2mevb.dts
index 7da409170db5..3e1a8d943c17 100644
--- a/arch/arm/boot/dts/r7s9210-rza2mevb.dts
+++ b/arch/arm/boot/dts/r7s9210-rza2mevb.dts
@@ -107,6 +107,18 @@
 		pinmux = <RZA2_PINMUX(PORT5, 4, 3)>,	/* SD1_CD */
 			 <RZA2_PINMUX(PORT5, 5, 3)>;	/* SD1_WP */
 	};
+
+	usb0_pins: usb0 {
+		pinmux = <RZA2_PINMUX(PORT5, 2, 3)>,	/* VBUSIN0 */
+			 <RZA2_PINMUX(PORTC, 6, 1)>,	/* VBUSEN0 */
+			 <RZA2_PINMUX(PORTC, 7, 1)>;	/* OVRCUR0 */
+	};
+
+	usb1_pins: usb1 {
+		pinmux = <RZA2_PINMUX(PORTC, 0, 1)>,	/* VBUSIN1 */
+			 <RZA2_PINMUX(PORTC, 5, 1)>,	/* VBUSEN1 */
+			 <RZA2_PINMUX(PORT7, 5, 5)>;	/* OVRCUR1 */
+	};
 };
 
 /* High resolution System tick timers */
@@ -161,3 +173,27 @@
 	bus-width = <4>;
 	status = "okay";
 };
+
+/* USB-0 as Host */
+&usb2_phy0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb0_pins>;
+	dr_mode = "host";	/* Requires JP3 to be fitted */
+	status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};
+
+/* USB-1 as Host */
+&usb2_phy1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb1_pins>;
+	dr_mode = "host";
+	status = "okay";
+};
+
+&ehci1 {
+	status = "okay";
+};
-- 
2.16.1


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

* Re: [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support
  2019-05-15 15:20 ` [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support Chris Brandt
@ 2019-05-20 11:42   ` Simon Horman
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Horman @ 2019-05-20 11:42 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Yoshihiro Shimoda,
	Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc

On Wed, May 15, 2019 at 10:20:46AM -0500, Chris Brandt wrote:
> Add EHCI and OHCI host support for RZ/A2.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Chris,

applied for inclusion in v5.3.

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

* Re: [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support
  2019-05-15 15:20 ` [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support Chris Brandt
@ 2019-05-20 11:43   ` Simon Horman
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Horman @ 2019-05-20 11:43 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Yoshihiro Shimoda,
	Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc

On Wed, May 15, 2019 at 10:20:47AM -0500, Chris Brandt wrote:
> Add USB Device support for RZ/A2.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Chris,

applied for inclusion in v5.3.

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

* Re: [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support
  2019-05-15 15:20 ` [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support Chris Brandt
@ 2019-05-20 11:43   ` Simon Horman
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Horman @ 2019-05-20 11:43 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Yoshihiro Shimoda,
	Geert Uytterhoeven, Sergei Shtylyov, Chunfeng Yun,
	Kuninori Morimoto, linux-usb, devicetree, linux-renesas-soc

On Wed, May 15, 2019 at 10:20:48AM -0500, Chris Brandt wrote:
> Enable USB Host support for both the Type-C connector on the CPU board
> and the Type-A plug on the sub board.
> 
> Both boards are also capable of USB Device operation as well after the
> appropriate Device Tree modifications.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Chris,

applied for inclusion in v5.3.

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

end of thread, other threads:[~2019-05-20 11:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15 15:20 [PATCH v4 00/13] usb: Add host and device support for RZ/A2 Chris Brandt
2019-05-15 15:20 ` [PATCH v4 01/13] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
2019-05-15 15:20 ` [PATCH v4 02/13] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
2019-05-15 15:20 ` [PATCH v4 03/13] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
2019-05-15 15:20 ` [PATCH v4 04/13] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
2019-05-15 15:20 ` [PATCH v4 05/13] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support Chris Brandt
2019-05-15 15:20 ` [PATCH v4 06/13] usb: renesas_usbhs: move flags to param Chris Brandt
2019-05-15 15:20 ` [PATCH v4 07/13] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
2019-05-15 15:20 ` [PATCH v4 08/13] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
2019-05-15 15:20 ` [PATCH v4 09/13] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
2019-05-15 15:20 ` [PATCH v4 10/13] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
2019-05-15 15:20 ` [PATCH v4 11/13] ARM: dts: r7s9210: Add USB Host support Chris Brandt
2019-05-20 11:42   ` Simon Horman
2019-05-15 15:20 ` [PATCH v4 12/13] ARM: dts: r7s9210: Add USB Device support Chris Brandt
2019-05-20 11:43   ` Simon Horman
2019-05-15 15:20 ` [PATCH v4 13/13] ARM: dts: rza2mevb: Add USB Host support Chris Brandt
2019-05-20 11:43   ` Simon Horman

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