Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 00/15] usb: Add host and device support for RZ/A2
@ 2019-05-09 20:11 Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 01/15] ARM: dts: r7s9210: Add USB clock Chris Brandt
                   ` (14 more replies)
  0 siblings, 15 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

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 (15):
  ARM: dts: r7s9210: Add USB clock
  ARM: dts: rza2mevb: Add 48MHz USB clock
  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 macros
  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 | 17 ++--
 .../devicetree/bindings/usb/renesas_usbhs.txt      |  2 +
 arch/arm/boot/dts/r7s9210-rza2mevb.dts             | 42 ++++++++++
 arch/arm/boot/dts/r7s9210.dtsi                     | 95 ++++++++++++++++++++++
 drivers/phy/renesas/phy-rcar-gen3-usb2.c           | 22 +++++
 drivers/usb/renesas_usbhs/Makefile                 |  2 +-
 drivers/usb/renesas_usbhs/common.c                 | 25 ++++--
 drivers/usb/renesas_usbhs/common.h                 | 13 +++
 drivers/usb/renesas_usbhs/fifo.c                   |  9 +-
 drivers/usb/renesas_usbhs/rza.h                    |  1 +
 drivers/usb/renesas_usbhs/rza2.c                   | 79 ++++++++++++++++++
 include/linux/usb/renesas_usbhs.h                  |  1 +
 12 files changed, 292 insertions(+), 16 deletions(-)
 create mode 100644 drivers/usb/renesas_usbhs/rza2.c

-- 
2.16.1


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

* [PATCH v2 01/15] ARM: dts: r7s9210: Add USB clock
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-13 12:25   ` Simon Horman
  2019-05-09 20:11 ` [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz " Chris Brandt
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

Add USB clock node. If present, this clock input must be 48MHz.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 arch/arm/boot/dts/r7s9210.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210.dtsi b/arch/arm/boot/dts/r7s9210.dtsi
index 2eaa5eeba509..73041f04fef5 100644
--- a/arch/arm/boot/dts/r7s9210.dtsi
+++ b/arch/arm/boot/dts/r7s9210.dtsi
@@ -30,6 +30,13 @@
 		clock-frequency = <0>;
 	};
 
+	usb_x1_clk: usb_x1 {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		/* If clk present, value (48000000) must be set by board */
+		clock-frequency = <0>;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
-- 
2.16.1


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

* [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz USB clock
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 01/15] ARM: dts: r7s9210: Add USB clock Chris Brandt
@ 2019-05-09 20:11 ` " Chris Brandt
  2019-05-13 12:26   ` Simon Horman
  2019-05-09 20:11 ` [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

The RZ/A2M EVB has a 48MHz clock attached to USB_X1.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 arch/arm/boot/dts/r7s9210-rza2mevb.dts | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210-rza2mevb.dts b/arch/arm/boot/dts/r7s9210-rza2mevb.dts
index 7795066d82cb..7da409170db5 100644
--- a/arch/arm/boot/dts/r7s9210-rza2mevb.dts
+++ b/arch/arm/boot/dts/r7s9210-rza2mevb.dts
@@ -58,6 +58,11 @@
 	clock-frequency = <32768>;
 };
 
+/* USB_X1 */
+&usb_x1_clk {
+	clock-frequency = <48000000>;
+};
+
 &pinctrl {
 	/* Serial Console */
 	scif4_pins: serial4 {
-- 
2.16.1


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

* [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 01/15] ARM: dts: r7s9210: Add USB clock Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz " Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-10  1:57   ` Chunfeng Yun
  2019-05-10  4:17   ` Yoshihiro Shimoda
  2019-05-09 20:11 ` [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
                   ` (11 subsequent siblings)
  14 siblings, 2 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
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..1ebb08f8323f 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -34,6 +34,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)
@@ -110,6 +111,7 @@ struct rcar_gen3_chan {
 	bool extcon_host;
 	bool is_otg_channel;
 	bool uses_otg_pins;
+	bool uses_usb_x1;
 };
 
 /*
@@ -391,6 +393,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(0x00000001, 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;
@@ -582,10 +587,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct rcar_gen3_chan *channel;
+	struct device_node *usb_x1_clk;
 	struct phy_provider *provider;
 	struct resource *res;
 	const struct phy_ops *phy_usb2_ops;
 	int irq, ret = 0, i;
+	u32 freq_usb = 0;
 
 	if (!dev->of_node) {
 		dev_err(dev, "This driver needs device tree\n");
@@ -630,6 +637,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 		}
 	}
 
+	usb_x1_clk = of_find_node_by_name(NULL, "usb_x1");
+	if (usb_x1_clk) {
+		of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
+		if (freq_usb)
+			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	[flat|nested] 40+ messages in thread

* [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (2 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-10  4:38   ` Yoshihiro Shimoda
  2019-05-09 20:11 ` [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

Document the optional renesas,uses_usb_x1 property.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
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 | 4 +++-
 1 file changed, 3 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..79d8360d92e5 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -28,7 +28,9 @@ 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 48MHz USB_X1 input, if a 'usb_x1' clock node exists and is
+          set to non-zero, the PHY will use the 48MHZ input for the PLL.
 - #phy-cells: see phy-bindings.txt in the same directory, must be <1> (and
 	      using <0> is deprecated).
 
-- 
2.16.1


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

* [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (3 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-10  8:36   ` Sergei Shtylyov
  2019-05-09 20:11 ` [PATCH v2 06/15] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
v2:
 * added braces to else statement
 * check if dr_mode is "host"
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 1ebb08f8323f..5e5e5e938f80 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -391,6 +391,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
 	struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
 	struct rcar_gen3_chan *channel = rphy->ch;
 	void __iomem *usb2_base = channel->base;
+	enum usb_dr_mode mode;
 	u32 val;
 
 	if (channel->uses_usb_x1)
@@ -408,6 +409,13 @@ 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 */
+		mode = usb_get_dr_mode(channel->dev);
+		if (mode == USB_DR_MODE_HOST)
+			writel(0x00000000, usb2_base + USB2_COMMCTRL);
+		else if (mode == USB_DR_MODE_PERIPHERAL)
+			writel(0x80000000, usb2_base + USB2_COMMCTRL);
 	}
 
 	rphy->initialized = true;
-- 
2.16.1


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

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

Document the optional dr_mode property

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 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 79d8360d92e5..d2bbfe577345 100644
--- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
+++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
@@ -48,6 +48,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	[flat|nested] 40+ messages in thread

* [PATCH v2 07/15] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (5 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 06/15] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 08/15] usb: renesas_usbhs: move flags macros Chris Brandt
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

Document RZ/A2 (R7S9210) SoC bindings.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 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 d2bbfe577345..d6b48704e3f2 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	[flat|nested] 40+ messages in thread

* [PATCH v2 08/15] usb: renesas_usbhs: move flags macros
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (6 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 07/15] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-10  1:59   ` Chunfeng Yun
  2019-05-10  8:41   ` Sergei Shtylyov
  2019-05-09 20:11 ` [PATCH v2 09/15] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
                   ` (6 subsequent siblings)
  14 siblings, 2 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

Move flags macros to header file so they can be used by other files.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c |  7 -------
 drivers/usb/renesas_usbhs/common.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 249fbee97f3f..efb26ffd9809 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -44,13 +44,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
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 3777af848a35..1ca94b8f5508 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -339,4 +339,14 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
 #define usbhs_priv_to_dev(priv)		(&priv->pdev->dev)
 #define usbhs_priv_to_lock(priv)	(&priv->lock)
 
+/*
+ * flags
+ */
+#define USBHSF_RUNTIME_PWCTRL	(1 << 0)
+
+#define usbhsc_flags_init(p)   ((p)->flags = 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))
+
 #endif /* RENESAS_USB_DRIVER_H */
-- 
2.16.1


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

* [PATCH v2 09/15] usb: renesas_usbhs: add support for CNEN bit
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (7 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 08/15] usb: renesas_usbhs: move flags macros Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 10/15] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
 drivers/usb/renesas_usbhs/common.c | 6 ++++++
 drivers/usb/renesas_usbhs/common.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index efb26ffd9809..820636fc4dc9 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -116,6 +116,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 (usbhsc_flags_has(priv, USBHSF_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 1ca94b8f5508..211ab8e741be 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 */
@@ -343,6 +344,7 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
  * flags
  */
 #define USBHSF_RUNTIME_PWCTRL	(1 << 0)
+#define USBHSF_HAS_CNEN		(1 << 1) /* Single-ended receiver */
 
 #define usbhsc_flags_init(p)   ((p)->flags = 0)
 #define usbhsc_flags_set(p, b) ((p)->flags |=  (b))
-- 
2.16.1


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

* [PATCH v2 10/15] usb: renesas_usbhs: support byte addressable CFIFO
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (8 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 09/15] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
 drivers/usb/renesas_usbhs/common.h | 1 +
 drivers/usb/renesas_usbhs/fifo.c   | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 211ab8e741be..af4aec703ab1 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -345,6 +345,7 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
  */
 #define USBHSF_RUNTIME_PWCTRL	(1 << 0)
 #define USBHSF_HAS_CNEN		(1 << 1) /* Single-ended receiver */
+#define USBHSF_CFIFO_BYTE_ADDR	(1 << 2) /* Byte addressable */
 
 #define usbhsc_flags_init(p)   ((p)->flags = 0)
 #define usbhsc_flags_set(p, b) ((p)->flags |=  (b))
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 39fa2fc1b8b7..b313ee637e53 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 (usbhsc_flags_has(priv, USBHSF_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
-- 
2.16.1


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

* [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (9 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 10/15] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-10  1:53   ` Chunfeng Yun
  2019-05-10  7:07   ` Geert Uytterhoeven
  2019-05-09 20:11 ` [PATCH v2 12/15] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
                   ` (3 subsequent siblings)
  14 siblings, 2 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
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 | 12 +++++-
 drivers/usb/renesas_usbhs/rza.h    |  1 +
 drivers/usb/renesas_usbhs/rza2.c   | 79 ++++++++++++++++++++++++++++++++++++++
 include/linux/usb/renesas_usbhs.h  |  1 +
 5 files changed, 93 insertions(+), 2 deletions(-)
 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 820636fc4dc9..35d2298c03a0 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -582,6 +582,10 @@ static const struct of_device_id usbhs_of_match[] = {
 		.compatible = "renesas,rza1-usbhs",
 		.data = (void *)USBHS_TYPE_RZA1,
 	},
+	{
+		.compatible = "renesas,rza2-usbhs",
+		.data = (void *)USBHS_TYPE_RZA2,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, usbhs_of_match);
@@ -614,7 +618,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
 	}
 
-	if (dparam->type == USBHS_TYPE_RZA1) {
+	if (dparam->type == USBHS_TYPE_RZA1 ||
+	    dparam->type == USBHS_TYPE_RZA2) {
 		dparam->pipe_configs = usbhsc_new_pipe;
 		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
 	}
@@ -688,6 +693,11 @@ static int usbhs_probe(struct platform_device *pdev)
 	case USBHS_TYPE_RZA1:
 		priv->pfunc = usbhs_rza1_ops;
 		break;
+	case USBHS_TYPE_RZA2:
+		priv->pfunc = usbhs_rza2_ops;
+		usbhsc_flags_set(priv, USBHSF_HAS_CNEN);
+		usbhsc_flags_set(priv, USBHSF_CFIFO_BYTE_ADDR);
+		break;
 	default:
 		if (!info->platform_callback.get_id) {
 			dev_err(&pdev->dev, "no platform callbacks");
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..a1d9eb2d40cf
--- /dev/null
+++ b/drivers/usb/renesas_usbhs/rza2.c
@@ -0,0 +1,79 @@
+// 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);
+
+	if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+		struct phy *phy = phy_get(&pdev->dev, "usb");
+
+		if (IS_ERR(phy))
+			return PTR_ERR(phy);
+
+		priv->phy = phy;
+		return 0;
+	}
+	return -ENXIO;
+}
+
+static int usbhs_rza2_hardware_exit(struct platform_device *pdev)
+{
+	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+
+	if (priv->phy) {
+		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 53924f8e840c..39604c8b1eed 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -196,6 +196,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	[flat|nested] 40+ messages in thread

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

Add support for r7s9210 (RZ/A2M) SoC

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 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..11c99d079dfb 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 r7s72100 (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	[flat|nested] 40+ messages in thread

* [PATCH v2 13/15] ARM: dts: r7s9210: Add USB Host support
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (11 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 12/15] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 14/15] ARM: dts: r7s9210: Add USB Device support Chris Brandt
  2019-05-09 20:11 ` [PATCH v2 15/15] ARM: dts: rza2mevb: Add USB host support Chris Brandt
  14 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
v2:
 * changed to generic name usb@xxx
 * Add space between compatible strings
---
 arch/arm/boot/dts/r7s9210.dtsi | 64 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210.dtsi b/arch/arm/boot/dts/r7s9210.dtsi
index 73041f04fef5..1877871af3fc 100644
--- a/arch/arm/boot/dts/r7s9210.dtsi
+++ b/arch/arm/boot/dts/r7s9210.dtsi
@@ -329,6 +329,70 @@
 			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 0x10>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 61>;
+			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 0x10>;
+			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 60>;
+			power-domains = <&cpg>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
 		sdhi0: sd@e8228000 {
 			compatible = "renesas,sdhi-r7s9210";
 			reg = <0xe8228000 0x8c0>;
-- 
2.16.1


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

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

Add USB Device support for RZ/A2.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
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 1877871af3fc..5ebef1583f56 100644
--- a/arch/arm/boot/dts/r7s9210.dtsi
+++ b/arch/arm/boot/dts/r7s9210.dtsi
@@ -361,6 +361,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>;
@@ -393,6 +405,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	[flat|nested] 40+ messages in thread

* [PATCH v2 15/15] ARM: dts: rza2mevb: Add USB host support
  2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
                   ` (13 preceding siblings ...)
  2019-05-09 20:11 ` [PATCH v2 14/15] ARM: dts: r7s9210: Add USB Device support Chris Brandt
@ 2019-05-09 20:11 ` Chris Brandt
  14 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-09 20:11 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, Sergei Shtylyov, 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>
---
v2:
 * added blank line between nodes
 * removed 'r7s9210-' from patch title
 * removed 'renesas,uses_usb_x1' property
---
 arch/arm/boot/dts/r7s9210-rza2mevb.dts | 37 ++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/arch/arm/boot/dts/r7s9210-rza2mevb.dts b/arch/arm/boot/dts/r7s9210-rza2mevb.dts
index 7da409170db5..c0a4484a0bde 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,28 @@
 	bus-width = <4>;
 	status = "okay";
 };
+
+/* USB-0 as Host */
+/* NOTE: Requires JP3 to be fitted */
+&usb2_phy0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usb0_pins>;
+	dr_mode = "host";
+	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	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-09 20:11 ` [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
@ 2019-05-10  1:53   ` Chunfeng Yun
  2019-05-10 13:10     ` Chris Brandt
  2019-05-10  7:07   ` Geert Uytterhoeven
  1 sibling, 1 reply; 40+ messages in thread
From: Chunfeng Yun @ 2019-05-10  1:53 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Geert Uytterhoeven, Sergei Shtylyov,
	linux-usb, devicetree, linux-renesas-soc

On Thu, 2019-05-09 at 15:11 -0500, Chris Brandt wrote:
> The RZ/A2 is similar to the R-Car Gen3 with some small differences.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
> 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 | 12 +++++-
>  drivers/usb/renesas_usbhs/rza.h    |  1 +
>  drivers/usb/renesas_usbhs/rza2.c   | 79 ++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/renesas_usbhs.h  |  1 +
>  5 files changed, 93 insertions(+), 2 deletions(-)
>  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 820636fc4dc9..35d2298c03a0 100644
> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -582,6 +582,10 @@ static const struct of_device_id usbhs_of_match[] = {
>  		.compatible = "renesas,rza1-usbhs",
>  		.data = (void *)USBHS_TYPE_RZA1,
>  	},
> +	{
> +		.compatible = "renesas,rza2-usbhs",
> +		.data = (void *)USBHS_TYPE_RZA2,
> +	},
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, usbhs_of_match);
> @@ -614,7 +618,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
>  		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
>  	}
>  
> -	if (dparam->type == USBHS_TYPE_RZA1) {
> +	if (dparam->type == USBHS_TYPE_RZA1 ||
> +	    dparam->type == USBHS_TYPE_RZA2) {
>  		dparam->pipe_configs = usbhsc_new_pipe;
>  		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
>  	}
> @@ -688,6 +693,11 @@ static int usbhs_probe(struct platform_device *pdev)
>  	case USBHS_TYPE_RZA1:
>  		priv->pfunc = usbhs_rza1_ops;
>  		break;
> +	case USBHS_TYPE_RZA2:
> +		priv->pfunc = usbhs_rza2_ops;
> +		usbhsc_flags_set(priv, USBHSF_HAS_CNEN);
> +		usbhsc_flags_set(priv, USBHSF_CFIFO_BYTE_ADDR);
> +		break;
>  	default:
>  		if (!info->platform_callback.get_id) {
>  			dev_err(&pdev->dev, "no platform callbacks");
> 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..a1d9eb2d40cf
> --- /dev/null
> +++ b/drivers/usb/renesas_usbhs/rza2.c
> @@ -0,0 +1,79 @@
> +// 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);
> +
> +	if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
no need check it, if it's not enabled, phy_get() will return an error
number.

> +		struct phy *phy = phy_get(&pdev->dev, "usb");
use devm_phy_get??
> +
> +		if (IS_ERR(phy))
> +			return PTR_ERR(phy);
> +
> +		priv->phy = phy;
> +		return 0;
> +	}
> +	return -ENXIO;
> +}
> +
> +static int usbhs_rza2_hardware_exit(struct platform_device *pdev)
> +{
> +	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
> +
> +	if (priv->phy) {
> +		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 53924f8e840c..39604c8b1eed 100644
> --- a/include/linux/usb/renesas_usbhs.h
> +++ b/include/linux/usb/renesas_usbhs.h
> @@ -196,6 +196,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:



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

* Re: [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-09 20:11 ` [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
@ 2019-05-10  1:57   ` Chunfeng Yun
  2019-05-10 13:17     ` Chris Brandt
  2019-05-10  4:17   ` Yoshihiro Shimoda
  1 sibling, 1 reply; 40+ messages in thread
From: Chunfeng Yun @ 2019-05-10  1:57 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Geert Uytterhoeven, Sergei Shtylyov,
	linux-usb, devicetree, linux-renesas-soc

On Thu, 2019-05-09 at 15:11 -0500, Chris Brandt wrote:
> 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>
> ---
> 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..1ebb08f8323f 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -34,6 +34,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)
> @@ -110,6 +111,7 @@ struct rcar_gen3_chan {
>  	bool extcon_host;
>  	bool is_otg_channel;
>  	bool uses_otg_pins;
> +	bool uses_usb_x1;
>  };
>  
>  /*
> @@ -391,6 +393,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(0x00000001, usb2_base + USB2_PHYCLK_CTRL);
                         ^^^^ avoid magic number?
> +
>  	/* Initialize USB2 part */
>  	val = readl(usb2_base + USB2_INT_ENABLE);
>  	val |= USB2_INT_ENABLE_UCOM_INTEN | rphy->int_enable_bits;
> @@ -582,10 +587,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct rcar_gen3_chan *channel;
> +	struct device_node *usb_x1_clk;
>  	struct phy_provider *provider;
>  	struct resource *res;
>  	const struct phy_ops *phy_usb2_ops;
>  	int irq, ret = 0, i;
> +	u32 freq_usb = 0;
>  
>  	if (!dev->of_node) {
>  		dev_err(dev, "This driver needs device tree\n");
> @@ -630,6 +637,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	usb_x1_clk = of_find_node_by_name(NULL, "usb_x1");
> +	if (usb_x1_clk) {
> +		of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
> +		if (freq_usb)
> +			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.



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

* Re: [PATCH v2 08/15] usb: renesas_usbhs: move flags macros
  2019-05-09 20:11 ` [PATCH v2 08/15] usb: renesas_usbhs: move flags macros Chris Brandt
@ 2019-05-10  1:59   ` Chunfeng Yun
  2019-05-10  8:41   ` Sergei Shtylyov
  1 sibling, 0 replies; 40+ messages in thread
From: Chunfeng Yun @ 2019-05-10  1:59 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Geert Uytterhoeven, Sergei Shtylyov,
	linux-usb, devicetree, linux-renesas-soc

On Thu, 2019-05-09 at 15:11 -0500, Chris Brandt wrote:
> Move flags macros to header file so they can be used by other files.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
>  drivers/usb/renesas_usbhs/common.c |  7 -------
>  drivers/usb/renesas_usbhs/common.h | 10 ++++++++++
>  2 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
> index 249fbee97f3f..efb26ffd9809 100644
> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -44,13 +44,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
> diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
> index 3777af848a35..1ca94b8f5508 100644
> --- a/drivers/usb/renesas_usbhs/common.h
> +++ b/drivers/usb/renesas_usbhs/common.h
> @@ -339,4 +339,14 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
>  #define usbhs_priv_to_dev(priv)		(&priv->pdev->dev)
>  #define usbhs_priv_to_lock(priv)	(&priv->lock)
>  
> +/*
> + * flags
> + */
> +#define USBHSF_RUNTIME_PWCTRL	(1 << 0)
BIT(0)?
> +
> +#define usbhsc_flags_init(p)   ((p)->flags = 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))
> +
>  #endif /* RENESAS_USB_DRIVER_H */



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

* RE: [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-09 20:11 ` [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
  2019-05-10  1:57   ` Chunfeng Yun
@ 2019-05-10  4:17   ` Yoshihiro Shimoda
  2019-05-10  6:56     ` Geert Uytterhoeven
  1 sibling, 1 reply; 40+ messages in thread
From: Yoshihiro Shimoda @ 2019-05-10  4:17 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Simon Horman

Hi Chris^[$B$5$s^[(B

Thank you for the patch!

> From: Chris Brandt, Sent: Friday, May 10, 2019 5:12 AM
> 
> 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>
> ---
> 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(+)
<snip>
> @@ -582,10 +587,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct rcar_gen3_chan *channel;
> +	struct device_node *usb_x1_clk;
>  	struct phy_provider *provider;
>  	struct resource *res;
>  	const struct phy_ops *phy_usb2_ops;
>  	int irq, ret = 0, i;
> +	u32 freq_usb = 0;
> 
>  	if (!dev->of_node) {
>  		dev_err(dev, "This driver needs device tree\n");
> @@ -630,6 +637,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>  		}
>  	}
> 
> +	usb_x1_clk = of_find_node_by_name(NULL, "usb_x1");
> +	if (usb_x1_clk) {
> +		of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
> +		if (freq_usb)
> +			channel->uses_usb_x1 = true;
> +	}
> +

We need to call of_node_put(usb_x1_clk); here.

By the way, we can also use devm_clk_get() for it like the following driver:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/renesas/rcar-usb2-clock-sel.c#n135

Best regards,
Yoshihiro Shimoda
>  	/*
>  	 * 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	[flat|nested] 40+ messages in thread

* RE: [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-09 20:11 ` [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
@ 2019-05-10  4:38   ` Yoshihiro Shimoda
  2019-05-10  6:55     ` Geert Uytterhoeven
  0 siblings, 1 reply; 40+ messages in thread
From: Yoshihiro Shimoda @ 2019-05-10  4:38 UTC (permalink / raw)
  To: Chris Brandt, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman
  Cc: Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc, Chris Brandt

Hi Chris-san,

Thank you for the patch!

> From: Chris Brandt, Sent: Friday, May 10, 2019 5:12 AM
> 
> Document the optional renesas,uses_usb_x1 property.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
> 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 | 4 +++-
>  1 file changed, 3 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..79d8360d92e5 100644
> --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> @@ -28,7 +28,9 @@ 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 48MHz USB_X1 input, if a 'usb_x1' clock node exists and is
> +          set to non-zero, the PHY will use the 48MHZ input for the PLL.

I think we need to add clock-names property for usb_x1 at least.
I checked the other doc "renesas,du.txt".
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/display/renesas,du.txt#n31

I think we can reuse it like below:

- clock-names: Name of the clocks. This property is model-dependent.
  - R-Car Gen3 SoCs use a single functional clock. The clock doesn't need to be
    named.
  - RZ/A2 uses a single functional clock as a separate dedicated 48MHz
    USB_X1 input. So, the functional clock must be named "???" and
    the USB_X1 input must be named as "usb_x1".

What do you think? I'm not sure how to be named the functional clock so that
the sample is named as "???".

Best regards,
Yoshihiro Shimoda

>  - #phy-cells: see phy-bindings.txt in the same directory, must be <1> (and
>  	      using <0> is deprecated).
> 
> --
> 2.16.1


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

* Re: [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-10  4:38   ` Yoshihiro Shimoda
@ 2019-05-10  6:55     ` Geert Uytterhoeven
  2019-05-13 21:07       ` Chris Brandt
  0 siblings, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2019-05-10  6:55 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Sergei Shtylyov, linux-usb, devicetree, linux-renesas-soc

Hi Shimoda-san, Chris,

On Fri, May 10, 2019 at 6:38 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> > From: Chris Brandt, Sent: Friday, May 10, 2019 5:12 AM
> >
> > Document the optional renesas,uses_usb_x1 property.
> >
> > Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> > ---
> > 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 | 4 +++-
> >  1 file changed, 3 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..79d8360d92e5 100644
> > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
> > @@ -28,7 +28,9 @@ 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 48MHz USB_X1 input, if a 'usb_x1' clock node exists and is
> > +          set to non-zero, the PHY will use the 48MHZ input for the PLL.
>
> I think we need to add clock-names property for usb_x1 at least.

Indeed. "if a 'usb_x1' clock node exists" is too fragile; better reference
the clock from "clocks".

> I checked the other doc "renesas,du.txt".
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/display/renesas,du.txt#n31
>
> I think we can reuse it like below:
>
> - clock-names: Name of the clocks. This property is model-dependent.
>   - R-Car Gen3 SoCs use a single functional clock. The clock doesn't need to be
>     named.
>   - RZ/A2 uses a single functional clock as a separate dedicated 48MHz

and a separate?

>     USB_X1 input. So, the functional clock must be named "???" and
>     the USB_X1 input must be named as "usb_x1".
>
> What do you think? I'm not sure how to be named the functional clock so that
> the sample is named as "???".

We typically use "fclk" for the functional clock's name.

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-10  4:17   ` Yoshihiro Shimoda
@ 2019-05-10  6:56     ` Geert Uytterhoeven
  0 siblings, 0 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2019-05-10  6:56 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Chris Brandt
  Cc: Sergei Shtylyov, linux-usb, devicetree, linux-renesas-soc,
	Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman

Hi Simoda-san, Chris,

On Fri, May 10, 2019 at 6:17 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> > From: Chris Brandt, Sent: Friday, May 10, 2019 5:12 AM
> >
> > 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>
> > ---
> > v2:
> >  * use 'usb_x1' clock node instead of 'renesas,uses_usb_x1' property
> > ---
> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c | 14 ++++++++++++++

> > @@ -630,6 +637,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> >               }
> >       }
> >
> > +     usb_x1_clk = of_find_node_by_name(NULL, "usb_x1");
> > +     if (usb_x1_clk) {
> > +             of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
> > +             if (freq_usb)
> > +                     channel->uses_usb_x1 = true;
> > +     }
> > +
>
> We need to call of_node_put(usb_x1_clk); here.
>
> By the way, we can also use devm_clk_get() for it like the following driver:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/renesas/rcar-usb2-clock-sel.c#n135

+1

devm_clk_get() and clk_get_rate() is the way to go.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-09 20:11 ` [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
  2019-05-10  1:53   ` Chunfeng Yun
@ 2019-05-10  7:07   ` Geert Uytterhoeven
  2019-05-10  8:16     ` Yoshihiro Shimoda
  1 sibling, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2019-05-10  7:07 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Sergei Shtylyov, USB list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas

Hi Chris,

On Thu, May 9, 2019 at 10:14 PM Chris Brandt <chris.brandt@renesas.com> wrote:
> The RZ/A2 is similar to the R-Car Gen3 with some small differences.
>
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>

Thanks for your patch!

> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c

> @@ -614,7 +618,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
>                 dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
>         }
>
> -       if (dparam->type == USBHS_TYPE_RZA1) {
> +       if (dparam->type == USBHS_TYPE_RZA1 ||
> +           dparam->type == USBHS_TYPE_RZA2) {
>                 dparam->pipe_configs = usbhsc_new_pipe;
>                 dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);

The above two lines are also present in the block for R-Car Gen2/3 above.
Perhaps they can just be moved out, and executed unconditionally?
That leaves R-Car with just the has_usb_dmac feature flag.

BTW, this driver uses a mix of feature checking using USBHS_TYPE_*
enums, and a parameter block/callback struct
(renesas_usbhs_platform_callback).  Perhaps the feature flags can just
be moved to the struct, and the various structs referenced from
of_device_id.data?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* RE: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-10  7:07   ` Geert Uytterhoeven
@ 2019-05-10  8:16     ` Yoshihiro Shimoda
  2019-05-10 11:00       ` Yoshihiro Shimoda
  0 siblings, 1 reply; 40+ messages in thread
From: Yoshihiro Shimoda @ 2019-05-10  8:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Sergei Shtylyov, USB list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas

Hi Geert-san,

> From: Geert Uytterhoeven, Sent: Friday, May 10, 2019 4:07 PM
> 
> Hi Chris,
> 
> On Thu, May 9, 2019 at 10:14 PM Chris Brandt <chris.brandt@renesas.com> wrote:
<snip>
> BTW, this driver uses a mix of feature checking using USBHS_TYPE_*
> enums, and a parameter block/callback struct
> (renesas_usbhs_platform_callback).  Perhaps the feature flags can just
> be moved to the struct, and the various structs referenced from
> of_device_id.data?

Thank you for your comment! I think so. So, I'll make such a patch later.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

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

* Re: [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-09 20:11 ` [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
@ 2019-05-10  8:36   ` Sergei Shtylyov
  2019-05-10 13:55     ` Chris Brandt
  0 siblings, 1 reply; 40+ messages in thread
From: Sergei Shtylyov @ 2019-05-10  8:36 UTC (permalink / raw)
  To: Chris Brandt, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On 09.05.2019 23:11, Chris Brandt wrote:

> 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>
> ---
> v2:
>   * added braces to else statement
>   * check if dr_mode is "host"
> ---
>   drivers/phy/renesas/phy-rcar-gen3-usb2.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index 1ebb08f8323f..5e5e5e938f80 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -391,6 +391,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
>   	struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
>   	struct rcar_gen3_chan *channel = rphy->ch;
>   	void __iomem *usb2_base = channel->base;
> +	enum usb_dr_mode mode;
>   	u32 val;
>   
>   	if (channel->uses_usb_x1)
> @@ -408,6 +409,13 @@ 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 */
> +		mode = usb_get_dr_mode(channel->dev);
> +		if (mode == USB_DR_MODE_HOST)
> +			writel(0x00000000, usb2_base + USB2_COMMCTRL);
> +		else if (mode == USB_DR_MODE_PERIPHERAL)
> +			writel(0x80000000, usb2_base + USB2_COMMCTRL);

    Maybe a *switch* instead?

MBR, Sergei

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

* Re: [PATCH v2 08/15] usb: renesas_usbhs: move flags macros
  2019-05-09 20:11 ` [PATCH v2 08/15] usb: renesas_usbhs: move flags macros Chris Brandt
  2019-05-10  1:59   ` Chunfeng Yun
@ 2019-05-10  8:41   ` Sergei Shtylyov
  2019-05-10 14:00     ` Chris Brandt
  1 sibling, 1 reply; 40+ messages in thread
From: Sergei Shtylyov @ 2019-05-10  8:41 UTC (permalink / raw)
  To: Chris Brandt, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On 09.05.2019 23:11, Chris Brandt wrote:

> Move flags macros to header file so they can be used by other files.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
>   drivers/usb/renesas_usbhs/common.c |  7 -------
>   drivers/usb/renesas_usbhs/common.h | 10 ++++++++++
>   2 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
> index 249fbee97f3f..efb26ffd9809 100644
> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -44,13 +44,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))
>   

    Why leave 3 empty lines?

>   /*
>    * platform call back
[...]

MBR, Sergei

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

* RE: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-10  8:16     ` Yoshihiro Shimoda
@ 2019-05-10 11:00       ` Yoshihiro Shimoda
  2019-05-10 14:20         ` Chris Brandt
  0 siblings, 1 reply; 40+ messages in thread
From: Yoshihiro Shimoda @ 2019-05-10 11:00 UTC (permalink / raw)
  To: Geert Uytterhoeven, Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Sergei Shtylyov, USB list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas

Hi Geert-san, Chris-san,

> From: Yoshihiro Shimoda, Sent: Friday, May 10, 2019 5:16 PM
> 
> Hi Geert-san,
> 
> > From: Geert Uytterhoeven, Sent: Friday, May 10, 2019 4:07 PM
> >
> > Hi Chris,
> >
> > On Thu, May 9, 2019 at 10:14 PM Chris Brandt <chris.brandt@renesas.com> wrote:
> <snip>
> > BTW, this driver uses a mix of feature checking using USBHS_TYPE_*
> > enums, and a parameter block/callback struct
> > (renesas_usbhs_platform_callback).  Perhaps the feature flags can just
> > be moved to the struct, and the various structs referenced from
> > of_device_id.data?
> 
> Thank you for your comment! I think so. So, I'll make such a patch later.

I have submitted such a patch as following:
https://patchwork.kernel.org/patch/10938575/

Since usbhsc_is_multi_clks() uses the type member, each struct also has the type like previous code.

About SoC parameters, I think it is better to add members into struct renesas_usbhs_driver_param like
has_usb_dmac instead of USBHSF_* definitions. In other words, we don't need the patch 08/15 and
patch 09/15 and 10/15 should add each member for it. Chris-san, what do you think?

Best regards,
Yoshihiro Shimoda

> Best regards,
> Yoshihiro Shimoda
> 
> > Gr{oetje,eeting}s,
> >
> >                         Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> >
> > In personal conversations with technical people, I call myself a hacker. But
> > when I'm talking to journalists I just say "programmer" or something like that.
> >                                 -- Linus Torvalds

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

* RE: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-10  1:53   ` Chunfeng Yun
@ 2019-05-10 13:10     ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-10 13:10 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Geert Uytterhoeven, Sergei Shtylyov,
	linux-usb, devicetree, linux-renesas-soc

On Thu, May 09, 2019, Chunfeng Yun wrote:
> > +	if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
> no need check it, if it's not enabled, phy_get() will return an error
> number.

Good point.
Thank you.

Chris

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

* RE: [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock
  2019-05-10  1:57   ` Chunfeng Yun
@ 2019-05-10 13:17     ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-10 13:17 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Yoshihiro Shimoda, Geert Uytterhoeven, Sergei Shtylyov,
	linux-usb, devicetree, linux-renesas-soc

On Thu, May 09, 2019, Chunfeng Yun wrote:
> > +	if (channel->uses_usb_x1)
> > +		writel(0x00000001, usb2_base + USB2_PHYCLK_CTRL);
>                          ^^^^ avoid magic number?

OK.

Chris


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

* RE: [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-10  8:36   ` Sergei Shtylyov
@ 2019-05-10 13:55     ` Chris Brandt
  2019-05-11  7:39       ` Sergei Shtylyov
  0 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-10 13:55 UTC (permalink / raw)
  To: Sergei Shtylyov, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On Fri, May 10, 2019, Sergei Shtylyov wrote:
> > +	} else {
> > +		/* Not OTG, so dr_mode should be set in PHY node */
> > +		mode = usb_get_dr_mode(channel->dev);
> > +		if (mode == USB_DR_MODE_HOST)
> > +			writel(0x00000000, usb2_base + USB2_COMMCTRL);
> > +		else if (mode == USB_DR_MODE_PERIPHERAL)
> > +			writel(0x80000000, usb2_base + USB2_COMMCTRL);
> 
>     Maybe a *switch* instead?

I like that idea because I can get rid of the dr_mode variable.

However...
I just tried it, but if I only have a case for HOST and PERIPHERAL, I 
get this gcc warning:

  warning: enumeration value ‘USB_DR_MODE_UNKNOWN’ not handled in switch [-Wswitch]
  warning: enumeration value ‘USB_DR_MODE_OTG’ not handled in switch [-Wswitch]


So, my code would have to be:

	} else {
		/* Not OTG, so dr_mode should be set in PHY node */
		switch (usb_get_dr_mode(channel->dev)) {
		case USB_DR_MODE_HOST:
			writel(0x00000000, usb2_base + USB2_COMMCTRL);
			break;
		case USB_DR_MODE_PERIPHERAL:
			writel(0x80000000, usb2_base + USB2_COMMCTRL);
			break;
		case USB_DR_MODE_UNKNOWN:
		case USB_DR_MODE_OTG:
			break;
		}
	}

I guess that is still OK.

Chris


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

* RE: [PATCH v2 08/15] usb: renesas_usbhs: move flags macros
  2019-05-10  8:41   ` Sergei Shtylyov
@ 2019-05-10 14:00     ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-10 14:00 UTC (permalink / raw)
  To: Sergei Shtylyov, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On Fri, May 10, 2019, Sergei Shtylyov wrote:
> > -#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))
> >
> 
>     Why leave 3 empty lines?

OK, I'll get rid of 2 of them.

Chris

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

* RE: [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2
  2019-05-10 11:00       ` Yoshihiro Shimoda
@ 2019-05-10 14:20         ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-10 14:20 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Geert Uytterhoeven
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Sergei Shtylyov, USB list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas

Hi Shimodaさん

> From: Yoshihiro Shimoda
> Sent: Friday, May 10, 2019 7:00 AM

> I have submitted such a patch as following:
> https://patchwork.kernel.org/patch/10938575/

OK.
I will rebase my patches on top of your patch.
I will say my patch series depends on your patch.

> About SoC parameters, I think it is better to add members into struct
> renesas_usbhs_driver_param like
> has_usb_dmac instead of USBHSF_* definitions. In other words, we don't
> need the patch 08/15 and
> patch 09/15 and 10/15 should add each member for it. Chris-san, what do
> you think?

I think that is good.

New Patch 08/15:
 * Add to struct renesas_usbhs_driver_param:
      u32 has_runtime_pwctrl:1;
 * Remove USBHSF_*
 * Remove usbhsc_flags_*

New Patch 09/15:
* Add to struct renesas_usbhs_driver_param:
     u32 has_cnen:1;

New Patch 10/15:
* Add to struct renesas_usbhs_driver_param:
     u32 cfifo_byte_addr:1;


Chris


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

* Re: [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-10 13:55     ` Chris Brandt
@ 2019-05-11  7:39       ` Sergei Shtylyov
  2019-05-11 12:05         ` Chris Brandt
  0 siblings, 1 reply; 40+ messages in thread
From: Sergei Shtylyov @ 2019-05-11  7:39 UTC (permalink / raw)
  To: Chris Brandt, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On 10.05.2019 16:55, Chris Brandt wrote:

>>> +	} else {
>>> +		/* Not OTG, so dr_mode should be set in PHY node */
>>> +		mode = usb_get_dr_mode(channel->dev);
>>> +		if (mode == USB_DR_MODE_HOST)
>>> +			writel(0x00000000, usb2_base + USB2_COMMCTRL);
>>> +		else if (mode == USB_DR_MODE_PERIPHERAL)
>>> +			writel(0x80000000, usb2_base + USB2_COMMCTRL);
>>
>>      Maybe a *switch* instead?
> 
> I like that idea because I can get rid of the dr_mode variable.

    Yes. :-)

> However...
> I just tried it, but if I only have a case for HOST and PERIPHERAL, I
> get this gcc warning:
> 
>    warning: enumeration value ‘USB_DR_MODE_UNKNOWN’ not handled in switch [-Wswitch]
>    warning: enumeration value ‘USB_DR_MODE_OTG’ not handled in switch [-Wswitch]
> 
> 
> So, my code would have to be:
> 
> 	} else {
> 		/* Not OTG, so dr_mode should be set in PHY node */
> 		switch (usb_get_dr_mode(channel->dev)) {
> 		case USB_DR_MODE_HOST:
> 			writel(0x00000000, usb2_base + USB2_COMMCTRL);
> 			break;
> 		case USB_DR_MODE_PERIPHERAL:
> 			writel(0x80000000, usb2_base + USB2_COMMCTRL);
> 			break;
> 		case USB_DR_MODE_UNKNOWN:
> 		case USB_DR_MODE_OTG:

    Maybe default: instead?

> 			break;
> 		}
> 	}
> 
> I guess that is still OK.

    Yes. :-)

> Chris

MBR, Sergei

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

* RE: [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG
  2019-05-11  7:39       ` Sergei Shtylyov
@ 2019-05-11 12:05         ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-11 12:05 UTC (permalink / raw)
  To: Sergei Shtylyov, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Yoshihiro Shimoda
  Cc: Geert Uytterhoeven, linux-usb, devicetree, linux-renesas-soc

On Sat, May 11, 2019, Sergei Shtylyov wrote:
> > 		case USB_DR_MODE_UNKNOWN:
> > 		case USB_DR_MODE_OTG:
> 
>     Maybe default: instead?

Yes, using default instead works.

Thank you!

Chris

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

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

On Thu, May 09, 2019 at 03:11:28PM -0500, Chris Brandt wrote:
> Add USB clock node. If present, this clock input must be 48MHz.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>

Thanks,

This looks fine to me but I will wait to see if there are other reviews
before applying.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

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

* Re: [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz USB clock
  2019-05-09 20:11 ` [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz " Chris Brandt
@ 2019-05-13 12:26   ` Simon Horman
  0 siblings, 0 replies; 40+ messages in thread
From: Simon Horman @ 2019-05-13 12:26 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Yoshihiro Shimoda,
	Geert Uytterhoeven, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc

On Thu, May 09, 2019 at 03:11:29PM -0500, Chris Brandt wrote:
> The RZ/A2M EVB has a 48MHz clock attached to USB_X1.
> 
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>

Thanks,

This looks fine to me but I will wait to see if there are other reviews
before applying.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

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

* RE: [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-10  6:55     ` Geert Uytterhoeven
@ 2019-05-13 21:07       ` Chris Brandt
  2019-05-13 21:12         ` Geert Uytterhoeven
  0 siblings, 1 reply; 40+ messages in thread
From: Chris Brandt @ 2019-05-13 21:07 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshihiro Shimoda
  Cc: Rob Herring, Mark Rutland, Greg Kroah-Hartman, Simon Horman,
	Sergei Shtylyov, linux-usb, devicetree, linux-renesas-soc

Hi Geert and Shimoda-san,

On Fri, May 10, 2019, Geert Uytterhoeven wrote:
> > I think we can reuse it like below:
> >
> > - clock-names: Name of the clocks. This property is model-dependent.
> >   - R-Car Gen3 SoCs use a single functional clock. The clock doesn't
> need to be
> >     named.
> >   - RZ/A2 uses a single functional clock as a separate dedicated 48MHz
> 
> and a separate?
> 
> >     USB_X1 input. So, the functional clock must be named "???" and
> >     the USB_X1 input must be named as "usb_x1".
> >
> > What do you think? I'm not sure how to be named the functional clock so
> that
> > the sample is named as "???".
> 
> We typically use "fclk" for the functional clock's name.


Just to make sure I'm following this, here is what you are asking for:

[r7s9210.dtsi]

	usb2_phy1: usb-phy@e821a200 {
		compatible = "renesas,usb2-phy-r7s9210", "renesas,rcar-gen3-usb2-phy";
		reg = <0xe821a200 0x10>;
		interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cpg CPG_MOD 60>, <&usb_x1_clk>;
+		clock-names = "fclk", "usb_x1";
		power-domains = <&cpg>;
		#phy-cells = <0>;
		status = "disabled";


[phy-rcar-gen3-usb2.c]
	usb_x1_clk = devm_clk_get(dev, "usb_x1");
	if (!IS_ERR(usb_x1_clk))
		if (clk_get_rate(usb_x1_clk))
			channel->uses_usb_x1 = true;


And then document this in the bindings, saying that clock-names is 
option if there is only 1 clock (to be backward compatible with existing 
Device Trees.

Is this correct?

Thanks,
Chris


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

* Re: [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-13 21:07       ` Chris Brandt
@ 2019-05-13 21:12         ` Geert Uytterhoeven
  2019-05-13 21:24           ` Chris Brandt
  0 siblings, 1 reply; 40+ messages in thread
From: Geert Uytterhoeven @ 2019-05-13 21:12 UTC (permalink / raw)
  To: Chris Brandt
  Cc: Yoshihiro Shimoda, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc

Hi Chris,

On Mon, May 13, 2019 at 11:07 PM Chris Brandt <Chris.Brandt@renesas.com> wrote:
> On Fri, May 10, 2019, Geert Uytterhoeven wrote:
> > > I think we can reuse it like below:
> > >
> > > - clock-names: Name of the clocks. This property is model-dependent.
> > >   - R-Car Gen3 SoCs use a single functional clock. The clock doesn't
> > need to be
> > >     named.
> > >   - RZ/A2 uses a single functional clock as a separate dedicated 48MHz
> >
> > and a separate?
> >
> > >     USB_X1 input. So, the functional clock must be named "???" and
> > >     the USB_X1 input must be named as "usb_x1".
> > >
> > > What do you think? I'm not sure how to be named the functional clock so
> > that
> > > the sample is named as "???".
> >
> > We typically use "fclk" for the functional clock's name.
>
>
> Just to make sure I'm following this, here is what you are asking for:
>
> [r7s9210.dtsi]
>
>         usb2_phy1: usb-phy@e821a200 {
>                 compatible = "renesas,usb2-phy-r7s9210", "renesas,rcar-gen3-usb2-phy";
>                 reg = <0xe821a200 0x10>;
>                 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
> +               clocks = <&cpg CPG_MOD 60>, <&usb_x1_clk>;
> +               clock-names = "fclk", "usb_x1";
>                 power-domains = <&cpg>;
>                 #phy-cells = <0>;
>                 status = "disabled";
>
>
> [phy-rcar-gen3-usb2.c]
>         usb_x1_clk = devm_clk_get(dev, "usb_x1");
>         if (!IS_ERR(usb_x1_clk)))
>                 if (clk_get_rate(usb_x1_clk))

if (!IS_ERR(usb_x1_clk) && clk_get_rate(usb_x1_clk))

>                         channel->uses_usb_x1 = true;
>
>
> And then document this in the bindings, saying that clock-names is
> option if there is only 1 clock (to be backward compatible with existing

optional

> Device Trees.
>
> Is this correct?

Exactly!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* RE: [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1
  2019-05-13 21:12         ` Geert Uytterhoeven
@ 2019-05-13 21:24           ` Chris Brandt
  0 siblings, 0 replies; 40+ messages in thread
From: Chris Brandt @ 2019-05-13 21:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshihiro Shimoda, Rob Herring, Mark Rutland, Greg Kroah-Hartman,
	Simon Horman, Sergei Shtylyov, linux-usb, devicetree,
	linux-renesas-soc

Hi Geert,

Thank you for the quick reply.


On Mon, May 13, 2019, Geert Uytterhoeven wrote:
> > [phy-rcar-gen3-usb2.c]
> >         usb_x1_clk = devm_clk_get(dev, "usb_x1");
> >         if (!IS_ERR(usb_x1_clk)))
> >                 if (clk_get_rate(usb_x1_clk))
> 
> if (!IS_ERR(usb_x1_clk) && clk_get_rate(usb_x1_clk))

:)


> > Is this correct?
> 
> Exactly!

Thank you!

#I'm trying to avoid a v4


Chris

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

end of thread, back to index

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 20:11 [PATCH v2 00/15] usb: Add host and device support for RZ/A2 Chris Brandt
2019-05-09 20:11 ` [PATCH v2 01/15] ARM: dts: r7s9210: Add USB clock Chris Brandt
2019-05-13 12:25   ` Simon Horman
2019-05-09 20:11 ` [PATCH v2 02/15] ARM: dts: rza2mevb: Add 48MHz " Chris Brandt
2019-05-13 12:26   ` Simon Horman
2019-05-09 20:11 ` [PATCH v2 03/15] phy: renesas: rcar-gen3-usb2: detect usb_x1 clock Chris Brandt
2019-05-10  1:57   ` Chunfeng Yun
2019-05-10 13:17     ` Chris Brandt
2019-05-10  4:17   ` Yoshihiro Shimoda
2019-05-10  6:56     ` Geert Uytterhoeven
2019-05-09 20:11 ` [PATCH v2 04/15] dt-bindings: rcar-gen3-phy-usb2: Document use of usb_x1 Chris Brandt
2019-05-10  4:38   ` Yoshihiro Shimoda
2019-05-10  6:55     ` Geert Uytterhoeven
2019-05-13 21:07       ` Chris Brandt
2019-05-13 21:12         ` Geert Uytterhoeven
2019-05-13 21:24           ` Chris Brandt
2019-05-09 20:11 ` [PATCH v2 05/15] phy: renesas: rcar-gen3-usb2: Check dr_mode when not using OTG Chris Brandt
2019-05-10  8:36   ` Sergei Shtylyov
2019-05-10 13:55     ` Chris Brandt
2019-05-11  7:39       ` Sergei Shtylyov
2019-05-11 12:05         ` Chris Brandt
2019-05-09 20:11 ` [PATCH v2 06/15] dt-bindings: rcar-gen3-phy-usb2: Document dr_mode Chris Brandt
2019-05-09 20:11 ` [PATCH v2 07/15] dt-bindings: rcar-gen3-phy-usb2: Add r7s9210 support Chris Brandt
2019-05-09 20:11 ` [PATCH v2 08/15] usb: renesas_usbhs: move flags macros Chris Brandt
2019-05-10  1:59   ` Chunfeng Yun
2019-05-10  8:41   ` Sergei Shtylyov
2019-05-10 14:00     ` Chris Brandt
2019-05-09 20:11 ` [PATCH v2 09/15] usb: renesas_usbhs: add support for CNEN bit Chris Brandt
2019-05-09 20:11 ` [PATCH v2 10/15] usb: renesas_usbhs: support byte addressable CFIFO Chris Brandt
2019-05-09 20:11 ` [PATCH v2 11/15] usb: renesas_usbhs: Add support for RZ/A2 Chris Brandt
2019-05-10  1:53   ` Chunfeng Yun
2019-05-10 13:10     ` Chris Brandt
2019-05-10  7:07   ` Geert Uytterhoeven
2019-05-10  8:16     ` Yoshihiro Shimoda
2019-05-10 11:00       ` Yoshihiro Shimoda
2019-05-10 14:20         ` Chris Brandt
2019-05-09 20:11 ` [PATCH v2 12/15] dt-bindings: usb: renesas_usbhs: Add support for r7s9210 Chris Brandt
2019-05-09 20:11 ` [PATCH v2 13/15] ARM: dts: r7s9210: Add USB Host support Chris Brandt
2019-05-09 20:11 ` [PATCH v2 14/15] ARM: dts: r7s9210: Add USB Device support Chris Brandt
2019-05-09 20:11 ` [PATCH v2 15/15] ARM: dts: rza2mevb: Add USB host support Chris Brandt

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox