All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support
@ 2022-12-12 17:27 Biju Das
  2022-12-12 17:27 ` [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries Biju Das
                   ` (14 more replies)
  0 siblings, 15 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Philipp Zabel,
	Greg Kroah-Hartman, Mathias Nyman, Artur Bujdoso, Felipe Balbi
  Cc: Biju Das, Adam Ford, Geert Uytterhoeven, Yoshihiro Shimoda,
	linux-usb, Fabrizio Castro, linux-renesas-soc

This patch series aims to add USB3.1 HOST, Peri and DRD support
on RZ/V2M EVK platform.

The reset for both host and peri are located in USB3DRD block. The
USB3DRD registers are mapped in the AXI address space of the Peripheral
module.

RZ/V2M is similar to R-Car XHCI but it doesn't require any
firmware.

Patch#16 depend upon [1]
[1] https://lore.kernel.org/linux-renesas-soc/20221209171836.71610-1-biju.das.jz@bp.renesas.com/T/#t


Biju Das (16):
  clk: renesas: r9a09g011: Add USB clock and reset entries
  dt-bindings: usb: Add RZ/V2M USB3DRD binding
  usb: gadget: Add support for RZ/V2M USB3DRD driver
  dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support
  usb: host: xhci-plat: Improve clock handling in probe()
  usb: host: xhci-plat: Add reset support
  xhci: host: Add Renesas RZ/V2M SoC support
  dt-bindings: usb: renesas,usb3-peri: Update reset property
  dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings
  usb: gadget: udc: renesas_usb3: Remove drd_reset handling
  usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M
  arm64: dts: renesas: r9a09g011: Add USB3 DRD and host nodes
  arm64: dts: renesas: r9a09g011: Add USB3 peripheral node
  arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host
  arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral
  arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch

 .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++
 .../bindings/usb/renesas,usb-xhci.yaml        |  41 ++++-
 .../bindings/usb/renesas,usb3-peri.yaml       |  16 +-
 .../boot/dts/renesas/r9a09g011-v2mevk2.dts    |  76 +++++++++
 arch/arm64/boot/dts/renesas/r9a09g011.dtsi    |  46 ++++++
 drivers/clk/renesas/r9a09g011-cpg.c           |  21 +++
 drivers/usb/gadget/udc/Kconfig                |   7 +
 drivers/usb/gadget/udc/Makefile               |   1 +
 drivers/usb/gadget/udc/renesas_usb3.c         |  63 ++++----
 drivers/usb/gadget/udc/rzv2m_usb3drd.c        | 151 ++++++++++++++++++
 drivers/usb/host/Kconfig                      |   9 ++
 drivers/usb/host/Makefile                     |   3 +
 drivers/usb/host/xhci-plat.c                  |  36 ++++-
 drivers/usb/host/xhci-rzv2m.c                 |  38 +++++
 drivers/usb/host/xhci-rzv2m.h                 |  16 ++
 include/linux/soc/renesas/rzv2m_usb3drd.h     |  19 +++
 16 files changed, 615 insertions(+), 51 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
 create mode 100644 drivers/usb/gadget/udc/rzv2m_usb3drd.c
 create mode 100644 drivers/usb/host/xhci-rzv2m.c
 create mode 100644 drivers/usb/host/xhci-rzv2m.h
 create mode 100644 include/linux/soc/renesas/rzv2m_usb3drd.h

-- 
2.25.1


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

* [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-21 14:55   ` Geert Uytterhoeven
  2022-12-12 17:27 ` [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding Biju Das
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Biju Das, Geert Uytterhoeven, linux-renesas-soc, linux-clk,
	Fabrizio Castro

Add USB clock and reset entries to CPG driver.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/clk/renesas/r9a09g011-cpg.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/clk/renesas/r9a09g011-cpg.c b/drivers/clk/renesas/r9a09g011-cpg.c
index b32f82860b2b..40c4c1fd8f07 100644
--- a/drivers/clk/renesas/r9a09g011-cpg.c
+++ b/drivers/clk/renesas/r9a09g011-cpg.c
@@ -23,10 +23,12 @@
 
 #define DIV_A		DDIV_PACK(0x200, 0, 3)
 #define DIV_B		DDIV_PACK(0x204, 0, 2)
+#define DIV_D		DDIV_PACK(0x204, 4, 2)
 #define DIV_E		DDIV_PACK(0x204, 8, 1)
 #define DIV_W		DDIV_PACK(0x328, 0, 3)
 
 #define SEL_B		SEL_PLL_PACK(0x214, 0, 1)
+#define SEL_D		SEL_PLL_PACK(0x214, 1, 1)
 #define SEL_E		SEL_PLL_PACK(0x214, 2, 1)
 #define SEL_W0		SEL_PLL_PACK(0x32C, 0, 1)
 
@@ -50,9 +52,11 @@ enum clk_ids {
 	CLK_PLL4,
 	CLK_DIV_A,
 	CLK_DIV_B,
+	CLK_DIV_D,
 	CLK_DIV_E,
 	CLK_DIV_W,
 	CLK_SEL_B,
+	CLK_SEL_D,
 	CLK_SEL_B_D2,
 	CLK_SEL_E,
 	CLK_SEL_W0,
@@ -81,6 +85,13 @@ static const struct clk_div_table dtable_divb[] = {
 	{0, 0},
 };
 
+static const struct clk_div_table dtable_divd[] = {
+	{0, 1},
+	{1, 2},
+	{2, 4},
+	{0, 0},
+};
+
 static const struct clk_div_table dtable_divw[] = {
 	{0, 6},
 	{1, 7},
@@ -94,6 +105,7 @@ static const struct clk_div_table dtable_divw[] = {
 
 /* Mux clock tables */
 static const char * const sel_b[] = { ".main", ".divb" };
+static const char * const sel_d[] = { ".main", ".divd" };
 static const char * const sel_e[] = { ".main", ".dive" };
 static const char * const sel_w[] = { ".main", ".divw" };
 
@@ -115,10 +127,12 @@ static const struct cpg_core_clk r9a09g011_core_clks[] __initconst = {
 
 	DEF_DIV_RO(".diva",	CLK_DIV_A,	CLK_PLL1,	DIV_A,	dtable_diva),
 	DEF_DIV_RO(".divb",	CLK_DIV_B,	CLK_PLL2_400,	DIV_B,	dtable_divb),
+	DEF_DIV_RO(".divd",	CLK_DIV_D,	CLK_PLL2_200,	DIV_D,	dtable_divd),
 	DEF_DIV_RO(".dive",	CLK_DIV_E,	CLK_PLL2_100,	DIV_E,	NULL),
 	DEF_DIV_RO(".divw",	CLK_DIV_W,	CLK_PLL4,	DIV_W,	dtable_divw),
 
 	DEF_MUX_RO(".selb",	CLK_SEL_B,	SEL_B,		sel_b),
+	DEF_MUX_RO(".seld",	CLK_SEL_D,	SEL_D,		sel_d),
 	DEF_MUX_RO(".sele",	CLK_SEL_E,	SEL_E,		sel_e),
 	DEF_MUX(".selw0",	CLK_SEL_W0,	SEL_W0,		sel_w),
 
@@ -131,6 +145,9 @@ static const struct rzg2l_mod_clk r9a09g011_mod_clks[] __initconst = {
 	DEF_COUPLED("eth_axi",	R9A09G011_ETH0_CLK_AXI,	 CLK_PLL2_200, 0x40c, 8),
 	DEF_COUPLED("eth_chi",	R9A09G011_ETH0_CLK_CHI,	 CLK_PLL2_100, 0x40c, 8),
 	DEF_MOD("eth_clk_gptp",	R9A09G011_ETH0_GPTP_EXT, CLK_PLL2_100, 0x40c, 9),
+	DEF_MOD("usb_aclk_h",	R9A09G011_USB_ACLK_H,	 CLK_SEL_D,    0x40c, 4),
+	DEF_MOD("usb_aclk_p",	R9A09G011_USB_ACLK_P,	 CLK_SEL_D,    0x40c, 5),
+	DEF_MOD("usb_pclk",	R9A09G011_USB_PCLK,	 CLK_SEL_E,    0x40c, 6),
 	DEF_MOD("syc_cnt_clk",	R9A09G011_SYC_CNT_CLK,	 CLK_MAIN_24,  0x41c, 12),
 	DEF_MOD("iic_pclk0",	R9A09G011_IIC_PCLK0,	 CLK_SEL_E,    0x420, 12),
 	DEF_MOD("cperi_grpb",	R9A09G011_CPERI_GRPB_PCLK, CLK_SEL_E,  0x424, 0),
@@ -169,6 +186,10 @@ static const struct rzg2l_mod_clk r9a09g011_mod_clks[] __initconst = {
 
 static const struct rzg2l_reset r9a09g011_resets[] = {
 	DEF_RST(R9A09G011_PFC_PRESETN,		0x600, 2),
+	DEF_RST(R9A09G011_USB_PRESET_N,		0x608, 7),
+	DEF_RST(R9A09G011_USB_DRD_RESET,	0x608, 8),
+	DEF_RST(R9A09G011_USB_ARESETN_P,	0x608, 9),
+	DEF_RST(R9A09G011_USB_ARESETN_H,	0x608, 10),
 	DEF_RST_MON(R9A09G011_ETH0_RST_HW_N,	0x608, 11, 11),
 	DEF_RST_MON(R9A09G011_SYC_RST_N,	0x610, 9,  13),
 	DEF_RST(R9A09G011_TIM_GPB_PRESETN,	0x614, 1),
-- 
2.25.1


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

* [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
  2022-12-12 17:27 ` [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 21:17   ` Rob Herring
  2022-12-13 14:29   ` Rob Herring
  2022-12-12 17:27 ` [PATCH 03/16] usb: gadget: Add support for RZ/V2M USB3DRD driver Biju Das
                   ` (12 subsequent siblings)
  14 siblings, 2 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Greg Kroah-Hartman, linux-usb, devicetree,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml

diff --git a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
new file mode 100644
index 000000000000..0c473c3398b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
@@ -0,0 +1,123 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/renesas,rzv2m-usb3drd.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas RZ/V2M USB 3.1 DRD controller
+
+maintainers:
+  - Biju Das <biju.das.jz@bp.renesas.com>
+
+description: |
+  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
+  * Role swapping function by the ID pin of the Micro-AB receptacle
+  * Battery Charging Specification Revision 1.2
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - renesas,r9a09g011-usb3drd  # RZ/V2M
+          - renesas,r9a09g055-usb3drd  # RZ/V2MA
+      - const: renesas,rzv2m-usb3drd
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Peripheral AXI clock
+      - description: APB clock
+
+  clock-names:
+    items:
+      - const: peri_axi
+      - const: apb
+
+  power-domains:
+    maxItems: 1
+
+  resets:
+    items:
+      - description: DRD reset
+      - description: Peripheral reset
+
+  reset-names:
+    items:
+      - const: drd_reset
+      - const: aresetn_p
+
+  ranges: true
+
+  '#address-cells':
+    enum: [ 1, 2 ]
+
+  '#size-cells':
+    enum: [ 1, 2 ]
+
+  usb3peri:
+    $ref: /schemas/usb/renesas,usb3-peri.yaml
+
+patternProperties:
+  "^usb@[0-9a-f]+$":
+    type: object
+    $ref: renesas,usb-xhci.yaml#
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - power-domains
+  - resets
+  - reset-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/r9a09g011-cpg.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    usb3drd: usb@85070000 {
+        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-usb3drd";
+        reg = <0x85070000 0x1000>;
+        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
+                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
+        clock-names = "peri_axi", "apb";
+        power-domains = <&cpg>;
+        resets = <&cpg R9A09G011_USB_DRD_RESET>,
+                 <&cpg R9A09G011_USB_ARESETN_P>;
+        reset-names = "drd_reset", "aresetn_p";
+        ranges;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        usb3host: usb@85060000 {
+           compatible = "renesas,r9a09g011-xhci",
+                        "renesas,rzv2m-xhci";
+           reg = <0x85060000 0x2000>;
+           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
+           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
+                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
+           clock-names = "host_axi", "reg";
+           power-domains = <&cpg>;
+           resets = <&cpg R9A09G011_USB_ARESETN_H>;
+        };
+
+        usb3peri: usb3peri {
+           compatible = "renesas,r9a09g011-usb3-peri",
+                        "renesas,rzv2m-usb3-peri";
+           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
+                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
+                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
+                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
+           interrupt-names = "all_p", "drd", "bc", "gpi";
+           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
+                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
+           clock-names = "aclk", "reg";
+           power-domains = <&cpg>;
+           resets = <&cpg R9A09G011_USB_ARESETN_P>;
+        };
+    };
-- 
2.25.1


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

* [PATCH 03/16] usb: gadget: Add support for RZ/V2M USB3DRD driver
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
  2022-12-12 17:27 ` [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries Biju Das
  2022-12-12 17:27 ` [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:27 ` [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support Biju Das
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Greg Kroah-Hartman, Geert Uytterhoeven, Magnus Damm,
	Arnd Bergmann, Tony Lindgren, Neal Liu, Randy Dunlap,
	Hans-Christian Noren Egtvedt, linux-usb, linux-renesas-soc,
	Fabrizio Castro

The RZ/V2M USB3.1 Gen1 Interface (USB) composed of a USB3.1 Gen1 Dual Role
Device controller (USB3DRD), a USB3.1 Gen1 Host controller (USB3HOST), a
USB3.1 Gen1 Peripheral controller (USB3PERI).

The reset for both host and peri are located in USB3DRD block. The
USB3DRD registers are mapped in the AXI address space of the Peripheral
module.

Add USB3DRD driver to handle reset for both host and peri modules.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/gadget/udc/Kconfig            |   6 +
 drivers/usb/gadget/udc/Makefile           |   1 +
 drivers/usb/gadget/udc/rzv2m_usb3drd.c    | 151 ++++++++++++++++++++++
 include/linux/soc/renesas/rzv2m_usb3drd.h |  19 +++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/usb/gadget/udc/rzv2m_usb3drd.c
 create mode 100644 include/linux/soc/renesas/rzv2m_usb3drd.h

diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 5756acb07b8d..578a3f209ef6 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -191,6 +191,12 @@ config USB_RENESAS_USBHS_UDC
 	   dynamically linked module called "renesas_usbhs" and force all
 	   gadget drivers to also be dynamically linked.
 
+config USB_RZV2M_USB3DRD
+	depends on ARCH_R9A09G011 || COMPILE_TEST
+	bool
+	default y if USB_XHCI_RZV2M
+	default y if USB_RENESAS_USB3
+
 config USB_RENESAS_USB3
 	tristate 'Renesas USB3.0 Peripheral controller'
 	depends on ARCH_RENESAS || COMPILE_TEST
diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
index 12f9e4c9eb0c..13c2a5422c30 100644
--- a/drivers/usb/gadget/udc/Makefile
+++ b/drivers/usb/gadget/udc/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_USB_TEGRA_XUDC)	+= tegra-xudc.o
 obj-$(CONFIG_USB_M66592)	+= m66592-udc.o
 obj-$(CONFIG_USB_R8A66597)	+= r8a66597-udc.o
 obj-$(CONFIG_USB_RENESAS_USB3)	+= renesas_usb3.o
+obj-$(CONFIG_USB_RZV2M_USB3DRD)	+= rzv2m_usb3drd.o
 obj-$(CONFIG_USB_FSL_QE)	+= fsl_qe_udc.o
 obj-$(CONFIG_USB_S3C_HSUDC)	+= s3c-hsudc.o
 obj-$(CONFIG_USB_LPC32XX)	+= lpc32xx_udc.o
diff --git a/drivers/usb/gadget/udc/rzv2m_usb3drd.c b/drivers/usb/gadget/udc/rzv2m_usb3drd.c
new file mode 100644
index 000000000000..1c9176dff1cb
--- /dev/null
+++ b/drivers/usb/gadget/udc/rzv2m_usb3drd.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas RZ/V2M USB3DRD driver
+ *
+ * Copyright (C) 2022 Renesas Electronics Corporation
+ */
+
+#include <linux/io.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/reset.h>
+
+#define USB_PERI_DRD_CON	0x400
+
+#define USB_PERI_DRD_CON_PERI_RST	BIT(31)
+#define USB_PERI_DRD_CON_HOST_RST	BIT(30)
+#define USB_PERI_DRD_CON_PERI_CON	BIT(24)
+
+struct rzv2m_usb3drd {
+	void __iomem *reg;
+	struct device *dev;
+	struct reset_control *drd_rstc;
+	struct reset_control *usbp_rstc;
+};
+
+static void rzv2m_usb3drd_set_bit(struct rzv2m_usb3drd *usb3, u32 bits,
+				  u32 offs)
+{
+	u32 val = readl(usb3->reg + offs);
+
+	val |= bits;
+	writel(val, usb3->reg + offs);
+}
+
+static void rzv2m_usb3drd_clear_bit(struct rzv2m_usb3drd *usb3, u32 bits,
+				    u32 offs)
+{
+	u32 val = readl(usb3->reg + offs);
+
+	val &= ~bits;
+	writel(val, usb3->reg + offs);
+}
+
+void rzv2m_usb3drd_reset(struct device *dev, bool host)
+{
+	struct rzv2m_usb3drd *usb3 = dev_get_drvdata(dev);
+
+	if (host) {
+		rzv2m_usb3drd_clear_bit(usb3, USB_PERI_DRD_CON_PERI_CON,
+					USB_PERI_DRD_CON);
+		rzv2m_usb3drd_clear_bit(usb3, USB_PERI_DRD_CON_HOST_RST,
+					USB_PERI_DRD_CON);
+		rzv2m_usb3drd_set_bit(usb3, USB_PERI_DRD_CON_PERI_RST,
+				      USB_PERI_DRD_CON);
+	} else {
+		rzv2m_usb3drd_set_bit(usb3, USB_PERI_DRD_CON_PERI_CON,
+				      USB_PERI_DRD_CON);
+		rzv2m_usb3drd_set_bit(usb3, USB_PERI_DRD_CON_HOST_RST,
+				      USB_PERI_DRD_CON);
+		rzv2m_usb3drd_clear_bit(usb3, USB_PERI_DRD_CON_PERI_RST,
+					USB_PERI_DRD_CON);
+	}
+}
+EXPORT_SYMBOL_GPL(rzv2m_usb3drd_reset);
+
+static int rzv2m_usb3drd_remove(struct platform_device *pdev)
+{
+	struct rzv2m_usb3drd *usb3 = platform_get_drvdata(pdev);
+
+	of_platform_depopulate(usb3->dev);
+	pm_runtime_put(usb3->dev);
+	pm_runtime_disable(&pdev->dev);
+	reset_control_assert(usb3->usbp_rstc);
+	reset_control_assert(usb3->drd_rstc);
+
+	return 0;
+}
+
+static int rzv2m_usb3drd_probe(struct platform_device *pdev)
+{
+	struct rzv2m_usb3drd *usb3;
+	int ret;
+
+	usb3 = devm_kzalloc(&pdev->dev, sizeof(*usb3), GFP_KERNEL);
+	if (!usb3)
+		return -ENOMEM;
+
+	usb3->dev = &pdev->dev;
+
+	usb3->reg = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(usb3->reg))
+		return PTR_ERR(usb3->reg);
+
+	platform_set_drvdata(pdev, usb3);
+
+	usb3->drd_rstc = devm_reset_control_get_exclusive(&pdev->dev,
+							  "drd_reset");
+	if (IS_ERR(usb3->drd_rstc))
+		return dev_err_probe(&pdev->dev, PTR_ERR(usb3->drd_rstc),
+				     "failed to get drd reset");
+
+	usb3->usbp_rstc = devm_reset_control_get_optional_shared(&pdev->dev,
+								 "aresetn_p");
+	if (IS_ERR(usb3->usbp_rstc))
+		return dev_err_probe(&pdev->dev, PTR_ERR(usb3->usbp_rstc),
+				     "failed to get peri reset");
+
+	reset_control_deassert(usb3->drd_rstc);
+	reset_control_deassert(usb3->usbp_rstc);
+	pm_runtime_enable(&pdev->dev);
+	ret = pm_runtime_resume_and_get(usb3->dev);
+	if (ret)
+		goto err_rst;
+
+	ret = of_platform_populate(usb3->dev->of_node, NULL, NULL, usb3->dev);
+	if (ret)
+		goto err_pm;
+
+	return 0;
+
+err_pm:
+	pm_runtime_put(usb3->dev);
+
+err_rst:
+	pm_runtime_disable(&pdev->dev);
+	reset_control_assert(usb3->usbp_rstc);
+	reset_control_assert(usb3->drd_rstc);
+	return ret;
+}
+
+static const struct of_device_id rzv2m_usb3drd_of_match[] = {
+	{ .compatible = "renesas,rzv2m-usb3drd", },
+	{ /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, rzv2m_usb3drd_of_match);
+
+static struct platform_driver rzv2m_usb3drd_driver = {
+	.driver = {
+		.name = "rzv2m-usb3drd",
+		.of_match_table = of_match_ptr(rzv2m_usb3drd_of_match),
+	},
+	.probe = rzv2m_usb3drd_probe,
+	.remove = rzv2m_usb3drd_remove,
+};
+module_platform_driver(rzv2m_usb3drd_driver);
+
+MODULE_AUTHOR("Biju Das <biju.das.jz@bp.renesas.com>");
+MODULE_DESCRIPTION("Renesas RZ/V2M USB3DRD driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:rzv2m_usb3drd");
diff --git a/include/linux/soc/renesas/rzv2m_usb3drd.h b/include/linux/soc/renesas/rzv2m_usb3drd.h
new file mode 100644
index 000000000000..87114c81a98e
--- /dev/null
+++ b/include/linux/soc/renesas/rzv2m_usb3drd.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __RZV2M_USB3DRD_H
+#define __RZV2M_USB3DRD_H
+
+#include <linux/types.h>
+
+struct rzv2m_usb3drd {
+	void __iomem *reg;
+	struct device *dev;
+	struct reset_control *rstc;
+};
+
+#if IS_ENABLED(CONFIG_USB_RZV2M_USB3DRD)
+void rzv2m_usb3drd_reset(struct device *dev, bool host);
+#else
+static inline void rzv2m_usb3drd_reset(struct device *dev, bool host) { }
+#endif
+
+#endif /* __RZV2M_USB3DRD_H */
-- 
2.25.1


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

* [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (2 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 03/16] usb: gadget: Add support for RZ/V2M USB3DRD driver Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-16 16:10   ` Rob Herring
  2022-12-12 17:27 ` [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe() Biju Das
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Greg Kroah-Hartman, Lad Prabhakar, Yoshihiro Shimoda,
	linux-usb, devicetree, Geert Uytterhoeven, Fabrizio Castro,
	linux-renesas-soc

Document the RZ/V2M SoC bindings.
The RZ/V2M SoC is a little different to the R-Car implementations.
You can access the registers associated with the currently set DRD mode,
therefore as part of init, we have to set the DRD mode to host.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 .../bindings/usb/renesas,usb-xhci.yaml        | 41 +++++++++++++++++--
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
index 4c5efaf02308..ae678d249785 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
@@ -10,9 +10,6 @@ maintainers:
   - Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
   - Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
 
-allOf:
-  - $ref: "usb-xhci.yaml"
-
 properties:
   compatible:
     oneOf:
@@ -37,6 +34,11 @@ properties:
               - renesas,xhci-r8a77965 # R-Car M3-N
               - renesas,xhci-r8a77990 # R-Car E3
           - const: renesas,rcar-gen3-xhci # R-Car Gen3 and RZ/G2
+      - items:
+          - enum:
+              - renesas,r9a09g011-xhci # RZ/V2M
+              - renesas,r9a09g055-xhci # RZ/V2MA
+          - const: renesas,rzv2m-xhci  # RZ/{V2M, V2MA}
 
   reg:
     maxItems: 1
@@ -45,7 +47,16 @@ properties:
     maxItems: 1
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    items:
+      - description: Main clock for host
+      - description: Register access clock
+
+  clock-names:
+    minItems: 1
+    items:
+      - const: host_axi
+      - const: reg
 
   phys:
     maxItems: 1
@@ -68,6 +79,28 @@ required:
   - power-domains
   - resets
 
+allOf:
+  - $ref: "usb-xhci.yaml"
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - renesas,rzv2m-xhci
+    then:
+      properties:
+        clocks:
+          minItems: 2
+        clock-names:
+          minItems: 2
+      required:
+        - clock-names
+    else:
+      properties:
+        clocks:
+          maxItems: 1
+
 unevaluatedProperties: false
 
 examples:
-- 
2.25.1


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

* [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe()
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (3 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-15 10:13   ` Geert Uytterhoeven
  2022-12-12 17:27 ` [PATCH 06/16] usb: host: xhci-plat: Add reset support Biju Das
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman
  Cc: Biju Das, linux-usb, Geert Uytterhoeven, Fabrizio Castro,
	linux-renesas-soc

It is always better to acquire all the clock resources first and
then do the clock operations.

This patch acquires all the optional clocks first and then calls
corresponding prepare_enable().

There is no functional change.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/host/xhci-plat.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5fb55bf19493..11b3a0d6722d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -257,16 +257,16 @@ static int xhci_plat_probe(struct platform_device *pdev)
 		goto put_hcd;
 	}
 
-	ret = clk_prepare_enable(xhci->reg_clk);
-	if (ret)
-		goto put_hcd;
-
 	xhci->clk = devm_clk_get_optional(&pdev->dev, NULL);
 	if (IS_ERR(xhci->clk)) {
 		ret = PTR_ERR(xhci->clk);
-		goto disable_reg_clk;
+		goto put_hcd;
 	}
 
+	ret = clk_prepare_enable(xhci->reg_clk);
+	if (ret)
+		goto put_hcd;
+
 	ret = clk_prepare_enable(xhci->clk);
 	if (ret)
 		goto disable_reg_clk;
-- 
2.25.1


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

* [PATCH 06/16] usb: host: xhci-plat: Add reset support
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (4 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe() Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-15 10:20   ` Geert Uytterhoeven
  2022-12-12 17:27 ` [PATCH 07/16] xhci: host: Add Renesas RZ/V2M SoC support Biju Das
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Mathias Nyman, Greg Kroah-Hartman, linux-usb,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

Add optional reset support. This is in preparation to adding USB xHCI
support for RZ/V2M SoC.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/host/xhci-plat.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 11b3a0d6722d..c5fc175a5fd1 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/usb/of.h>
+#include <linux/reset.h>
 
 #include "xhci.h"
 #include "xhci-plat.h"
@@ -263,10 +264,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
 		goto put_hcd;
 	}
 
-	ret = clk_prepare_enable(xhci->reg_clk);
+	xhci->reset = devm_reset_control_array_get_optional_shared(&pdev->dev);
+	if (IS_ERR(xhci->reset)) {
+		ret = PTR_ERR(xhci->reset);
+		goto put_hcd;
+	}
+
+	ret = reset_control_deassert(xhci->reset);
 	if (ret)
 		goto put_hcd;
 
+	ret = clk_prepare_enable(xhci->reg_clk);
+	if (ret)
+		goto err_reset;
+
 	ret = clk_prepare_enable(xhci->clk);
 	if (ret)
 		goto disable_reg_clk;
@@ -377,6 +388,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
 disable_reg_clk:
 	clk_disable_unprepare(xhci->reg_clk);
 
+err_reset:
+	reset_control_assert(xhci->reset);
+
 put_hcd:
 	usb_put_hcd(hcd);
 
@@ -412,6 +426,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 
 	clk_disable_unprepare(clk);
 	clk_disable_unprepare(reg_clk);
+	reset_control_assert(xhci->reset);
 	usb_put_hcd(hcd);
 
 	pm_runtime_disable(&dev->dev);
-- 
2.25.1


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

* [PATCH 07/16] xhci: host: Add Renesas RZ/V2M SoC support
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (5 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 06/16] usb: host: xhci-plat: Add reset support Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:27 ` [PATCH 08/16] dt-bindings: usb: renesas,usb3-peri: Update reset property Biju Das
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Artur Bujdoso, Felipe Balbi
  Cc: Biju Das, Tony Lindgren, Arnd Bergmann, Tomer Maimon,
	Juergen Gross, linux-usb, Geert Uytterhoeven, Fabrizio Castro,
	linux-renesas-soc

RZ/V2M is similar to R-Car XHCI but it doesn't require any
firmware, we need to reset the USB Host reset release in DRD Module
before accessing host registers.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/host/Kconfig      |  9 +++++++++
 drivers/usb/host/Makefile     |  3 +++
 drivers/usb/host/xhci-plat.c  | 11 ++++++++++
 drivers/usb/host/xhci-rzv2m.c | 38 +++++++++++++++++++++++++++++++++++
 drivers/usb/host/xhci-rzv2m.h | 16 +++++++++++++++
 5 files changed, 77 insertions(+)
 create mode 100644 drivers/usb/host/xhci-rzv2m.c
 create mode 100644 drivers/usb/host/xhci-rzv2m.h

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 247568bc17a2..4d347b9c9e45 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -95,6 +95,15 @@ config USB_XHCI_RCAR
 	  Say 'Y' to enable the support for the xHCI host controller
 	  found in Renesas R-Car ARM SoCs.
 
+config USB_XHCI_RZV2M
+	tristate "xHCI support for Renesas RZ/V2M SoC"
+	depends on USB_XHCI_PLATFORM
+	depends on ARCH_R9A09G011 || COMPILE_TEST
+	select USB_RZV2M_USB3DRD
+	help
+	  Say 'Y' to enable the support for the xHCI host controller
+	  found in Renesas RZ/V2M SoC.
+
 config USB_XHCI_TEGRA
 	tristate "xHCI support for NVIDIA Tegra SoCs"
 	depends on PHY_TEGRA_XUSB
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 2c8a61be7e46..a0c5e48f6a76 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -28,6 +28,9 @@ endif
 ifneq ($(CONFIG_USB_XHCI_RCAR), )
 	xhci-plat-hcd-y		+= xhci-rcar.o
 endif
+ifneq ($(CONFIG_USB_XHCI_RZV2M), )
+	xhci-plat-hcd-y		+= xhci-rzv2m.o
+endif
 
 ifneq ($(CONFIG_DEBUG_FS),)
 	xhci-hcd-y		+= xhci-debugfs.o
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c5fc175a5fd1..57269f1f318e 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -25,6 +25,7 @@
 #include "xhci-plat.h"
 #include "xhci-mvebu.h"
 #include "xhci-rcar.h"
+#include "xhci-rzv2m.h"
 
 static struct hc_driver __read_mostly xhci_plat_hc_driver;
 
@@ -123,6 +124,13 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
 	SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V3)
 };
 
+static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = {
+	.quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH |
+		  XHCI_SLOW_SUSPEND,
+	.init_quirk = xhci_rzv2m_init_quirk,
+	.plat_start = xhci_rzv2m_start,
+};
+
 static const struct xhci_plat_priv xhci_plat_brcm = {
 	.quirks = XHCI_RESET_ON_RESUME | XHCI_SUSPEND_RESUME_CLKS,
 };
@@ -162,6 +170,9 @@ static const struct of_device_id usb_xhci_of_match[] = {
 	}, {
 		.compatible = "renesas,rcar-gen3-xhci",
 		.data = &xhci_plat_renesas_rcar_gen3,
+	}, {
+		.compatible = "renesas,rzv2m-xhci",
+		.data = &xhci_plat_renesas_rzv2m,
 	}, {
 		.compatible = "brcm,xhci-brcm-v2",
 		.data = &xhci_plat_brcm,
diff --git a/drivers/usb/host/xhci-rzv2m.c b/drivers/usb/host/xhci-rzv2m.c
new file mode 100644
index 000000000000..d022b183daed
--- /dev/null
+++ b/drivers/usb/host/xhci-rzv2m.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * xHCI host controller driver for RZ/V2M
+ *
+ * Copyright (C) 2022 Renesas Electronics Corporation
+ */
+
+#include <linux/soc/renesas/rzv2m_usb3drd.h>
+#include "xhci-plat.h"
+#include "xhci-rzv2m.h"
+
+#define RZV2M_USB3_INTEN	0x1044	/* Interrupt Enable */
+
+#define RZV2M_USB3_INT_XHC_ENA	BIT(0)
+#define RZV2M_USB3_INT_HSE_ENA	BIT(2)
+#define RZV2M_USB3_INT_ENA_VAL	(RZV2M_USB3_INT_XHC_ENA \
+				 | RZV2M_USB3_INT_HSE_ENA)
+
+int xhci_rzv2m_init_quirk(struct usb_hcd *hcd)
+{
+	struct device *dev = hcd->self.controller;
+
+	rzv2m_usb3drd_reset(dev->parent, true);
+
+	return 0;
+}
+
+void xhci_rzv2m_start(struct usb_hcd *hcd)
+{
+	u32 int_en;
+
+	if (hcd->regs) {
+		/* Interrupt Enable */
+		int_en = readl(hcd->regs + RZV2M_USB3_INTEN);
+		int_en |= RZV2M_USB3_INT_ENA_VAL;
+		writel(int_en, hcd->regs + RZV2M_USB3_INTEN);
+	}
+}
diff --git a/drivers/usb/host/xhci-rzv2m.h b/drivers/usb/host/xhci-rzv2m.h
new file mode 100644
index 000000000000..12448b0e8d5b
--- /dev/null
+++ b/drivers/usb/host/xhci-rzv2m.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __XHCI_RZV2M_H
+#define __XHCI_RZV2M_H
+
+#if IS_ENABLED(CONFIG_USB_XHCI_RZV2M)
+void xhci_rzv2m_start(struct usb_hcd *hcd);
+int xhci_rzv2m_init_quirk(struct usb_hcd *hcd);
+#else
+static inline void xhci_rzv2m_start(struct usb_hcd *hcd) {}
+static inline int xhci_rzv2m_init_quirk(struct usb_hcd *hcd)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* __XHCI_RZV2M_H */
-- 
2.25.1


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

* [PATCH 08/16] dt-bindings: usb: renesas,usb3-peri: Update reset property
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (6 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 07/16] xhci: host: Add Renesas RZ/V2M SoC support Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:27 ` [PATCH 09/16] dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings Biju Das
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Greg Kroah-Hartman, Yoshihiro Shimoda, linux-usb,
	devicetree, Geert Uytterhoeven, Fabrizio Castro,
	linux-renesas-soc

On RZ/V2M, USB3DRD module manages the drd_reset. This patch removes
drd_reset from usb3_peri bindings. After this, there is only one
reset and therefore removing reset-names as well.

There is any harm in making such a change as, no users of
renesas,r9a09g011-usb3-peri yet in kernel release.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 .../bindings/usb/renesas,usb3-peri.yaml           | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
index 55dfd121b555..d56cfa8aefa6 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
@@ -71,15 +71,7 @@ properties:
     maxItems: 1
 
   resets:
-    minItems: 1
-    items:
-      - description: Peripheral reset
-      - description: DRD reset
-
-  reset-names:
-    items:
-      - const: aresetn_p
-      - const: drd_reset
+    maxItems: 1
 
   usb-role-switch:
     $ref: /schemas/types.yaml#/definitions/flag
@@ -131,21 +123,16 @@ allOf:
           minItems: 4
         interrupt-names:
           minItems: 4
-        resets:
-          minItems: 2
       required:
         - clock-names
         - interrupt-names
         - resets
-        - reset-names
     else:
       properties:
         clocks:
           maxItems: 1
         interrupts:
           maxItems: 1
-        resets:
-          maxItems: 1
 
 additionalProperties: false
 
-- 
2.25.1


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

* [PATCH 09/16] dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (7 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 08/16] dt-bindings: usb: renesas,usb3-peri: Update reset property Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:27 ` [PATCH 10/16] usb: gadget: udc: renesas_usb3: Remove drd_reset handling Biju Das
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Greg Kroah-Hartman, Yoshihiro Shimoda, linux-usb,
	devicetree, Geert Uytterhoeven, Fabrizio Castro,
	linux-renesas-soc

Document RZ/V2MA usb3-peri bindings. RZ/V2MA usb3-peri is identical
to one found on the RZ/V2M SoC. No driver changes are required as
generic compatible string "renesas,rzv2m-usb3-peri" will be used as
a fallback.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
index d56cfa8aefa6..0ca956a9f5b2 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
@@ -28,6 +28,7 @@ properties:
       - items:
           - enum:
               - renesas,r9a09g011-usb3-peri # RZ/V2M
+              - renesas,r9a09g055-usb3-peri # RZ/V2MA
           - const: renesas,rzv2m-usb3-peri
 
   reg:
-- 
2.25.1


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

* [PATCH 10/16] usb: gadget: udc: renesas_usb3: Remove drd_reset handling
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (8 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 09/16] dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:27 ` [PATCH 11/16] usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M Biju Das
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Greg Kroah-Hartman, Adam Ford, Geert Uytterhoeven,
	Yoshihiro Shimoda, linux-usb, Fabrizio Castro, linux-renesas-soc

As we have now support for DRD reset support in USB3DRD driver,
remove the redundant reset handling from peri module.

This patch drops the unused macros DRD_CON_PERI_RST and DRD_CON_HOST_RST.

Whilst, update reset handling for peripheral reset as per bindings
(ie, as it is a single reset, drop reset names).

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/gadget/udc/renesas_usb3.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 615ba0a6fbee..af29de32e08b 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -20,6 +20,7 @@
 #include <linux/reset.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <linux/soc/renesas/rzv2m_usb3drd.h>
 #include <linux/string.h>
 #include <linux/sys_soc.h>
 #include <linux/uaccess.h>
@@ -136,8 +137,6 @@
 #define USB_STA_VBUS_STA	BIT(0)
 
 /* DRD_CON */
-#define DRD_CON_PERI_RST	BIT(31)		/* rzv2m only */
-#define DRD_CON_HOST_RST	BIT(30)		/* rzv2m only */
 #define DRD_CON_PERI_CON	BIT(24)
 #define DRD_CON_VBOUT		BIT(0)
 
@@ -334,7 +333,6 @@ struct renesas_usb3_priv {
 
 struct renesas_usb3 {
 	void __iomem *reg;
-	struct reset_control *drd_rstc;
 	struct reset_control *usbp_rstc;
 
 	struct usb_gadget gadget;
@@ -682,13 +680,8 @@ static void renesas_usb3_role_work(struct work_struct *work)
 static void usb3_set_mode(struct renesas_usb3 *usb3, bool host)
 {
 	if (usb3->is_rzv2m) {
-		if (host) {
-			usb3_set_bit(usb3, DRD_CON_PERI_RST, USB3_DRD_CON(usb3));
-			usb3_clear_bit(usb3, DRD_CON_HOST_RST, USB3_DRD_CON(usb3));
-		} else {
-			usb3_set_bit(usb3, DRD_CON_HOST_RST, USB3_DRD_CON(usb3));
-			usb3_clear_bit(usb3, DRD_CON_PERI_RST, USB3_DRD_CON(usb3));
-		}
+		rzv2m_usb3drd_reset(usb3_to_dev(usb3)->parent, host);
+		return;
 	}
 
 	if (host)
@@ -2600,7 +2593,6 @@ static int renesas_usb3_remove(struct platform_device *pdev)
 
 	usb_del_gadget_udc(&usb3->gadget);
 	reset_control_assert(usb3->usbp_rstc);
-	reset_control_assert(usb3->drd_rstc);
 	renesas_usb3_dma_free_prd(usb3, &pdev->dev);
 
 	__renesas_usb3_ep_free_request(usb3->ep0_req);
@@ -2873,21 +2865,13 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 		goto err_add_udc;
 	}
 
-	usb3->drd_rstc = devm_reset_control_get_optional_shared(&pdev->dev,
-								"drd_reset");
-	if (IS_ERR(usb3->drd_rstc)) {
-		ret = PTR_ERR(usb3->drd_rstc);
-		goto err_add_udc;
-	}
-
 	usb3->usbp_rstc = devm_reset_control_get_optional_shared(&pdev->dev,
-								 "aresetn_p");
+								 NULL);
 	if (IS_ERR(usb3->usbp_rstc)) {
 		ret = PTR_ERR(usb3->usbp_rstc);
 		goto err_add_udc;
 	}
 
-	reset_control_deassert(usb3->drd_rstc);
 	reset_control_deassert(usb3->usbp_rstc);
 
 	pm_runtime_enable(&pdev->dev);
@@ -2933,7 +2917,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 
 err_reset:
 	reset_control_assert(usb3->usbp_rstc);
-	reset_control_assert(usb3->drd_rstc);
 
 err_add_udc:
 	renesas_usb3_dma_free_prd(usb3, &pdev->dev);
-- 
2.25.1


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

* [PATCH 11/16] usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (9 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 10/16] usb: gadget: udc: renesas_usb3: Remove drd_reset handling Biju Das
@ 2022-12-12 17:27 ` Biju Das
  2022-12-12 17:28 ` [PATCH 13/16] arm64: dts: renesas: r9a09g011: Add USB3 peripheral node Biju Das
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tony Lindgren
  Cc: Biju Das, Arnd Bergmann, Hans-Christian Noren Egtvedt, Neal Liu,
	Randy Dunlap, Yoshihiro Shimoda, Adam Ford, Geert Uytterhoeven,
	linux-usb, Fabrizio Castro, linux-renesas-soc

As RZ/V2M has both HOST and PERI reset module, we need to do reset release
before accessing registers in respective IP module.

This patch adds role switch support for RZ/V2M.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/gadget/udc/Kconfig        |  1 +
 drivers/usb/gadget/udc/renesas_usb3.c | 38 ++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 578a3f209ef6..d7278d67b146 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -201,6 +201,7 @@ config USB_RENESAS_USB3
 	tristate 'Renesas USB3.0 Peripheral controller'
 	depends on ARCH_RENESAS || COMPILE_TEST
 	depends on EXTCON
+	select USB_RZV2M_USB3DRD if ARCH_R9A09G011
 	select USB_ROLE_SWITCH
 	help
 	   Renesas USB3.0 Peripheral controller is a USB peripheral controller
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index af29de32e08b..9ca40b41aa36 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2318,6 +2318,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
 
 	usb3 = gadget_to_renesas_usb3(gadget);
 
+	if (usb3->is_rzv2m && usb3_is_a_device(usb3))
+		return -EBUSY;
+
 	/* hook up the driver */
 	usb3->driver = driver;
 
@@ -2326,6 +2329,10 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
 
 	pm_runtime_get_sync(usb3_to_dev(usb3));
 
+	/* Peripheral Reset */
+	if (usb3->is_rzv2m)
+		rzv2m_usb3drd_reset(usb3_to_dev(usb3)->parent, false);
+
 	renesas_usb3_init_controller(usb3);
 
 	return 0;
@@ -2338,8 +2345,10 @@ static int renesas_usb3_stop(struct usb_gadget *gadget)
 	usb3->softconnect = false;
 	usb3->gadget.speed = USB_SPEED_UNKNOWN;
 	usb3->driver = NULL;
-	renesas_usb3_stop_controller(usb3);
+	if (usb3->is_rzv2m)
+		rzv2m_usb3drd_reset(usb3_to_dev(usb3)->parent, false);
 
+	renesas_usb3_stop_controller(usb3);
 	if (usb3->phy)
 		phy_exit(usb3->phy);
 
@@ -2401,16 +2410,22 @@ static void handle_ext_role_switch_states(struct device *dev,
 		usb3->connection_state = USB_ROLE_NONE;
 		if (cur_role == USB_ROLE_HOST)
 			device_release_driver(host);
-		if (usb3->driver)
+		if (usb3->driver) {
+			if (usb3->is_rzv2m)
+				rzv2m_usb3drd_reset(dev->parent, false);
 			usb3_disconnect(usb3);
+		}
 		usb3_vbus_out(usb3, false);
 		break;
 	case USB_ROLE_DEVICE:
 		if (usb3->connection_state == USB_ROLE_NONE) {
 			usb3->connection_state = USB_ROLE_DEVICE;
 			usb3_set_mode(usb3, false);
-			if (usb3->driver)
+			if (usb3->driver) {
+				if (usb3->is_rzv2m)
+					renesas_usb3_init_controller(usb3);
 				usb3_connect(usb3);
+			}
 		} else if (cur_role == USB_ROLE_HOST)  {
 			device_release_driver(host);
 			usb3_set_mode(usb3, false);
@@ -2421,8 +2436,11 @@ static void handle_ext_role_switch_states(struct device *dev,
 		break;
 	case USB_ROLE_HOST:
 		if (usb3->connection_state == USB_ROLE_NONE) {
-			if (usb3->driver)
+			if (usb3->driver) {
+				if (usb3->is_rzv2m)
+					rzv2m_usb3drd_reset(dev->parent, false);
 				usb3_disconnect(usb3);
+			}
 
 			usb3->connection_state = USB_ROLE_HOST;
 			usb3_set_mode(usb3, true);
@@ -2806,9 +2824,15 @@ static int renesas_usb3_probe(struct platform_device *pdev)
 
 	usb3->is_rzv2m = priv->is_rzv2m;
 
-	usb3->reg = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(usb3->reg))
-		return PTR_ERR(usb3->reg);
+	if (usb3->is_rzv2m) {
+		struct rzv2m_usb3drd *ddata = dev_get_drvdata(pdev->dev.parent);
+
+		usb3->reg = ddata->reg;
+	} else {
+		usb3->reg = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(usb3->reg))
+			return PTR_ERR(usb3->reg);
+	}
 
 	platform_set_drvdata(pdev, usb3);
 	spin_lock_init(&usb3->lock);
-- 
2.25.1


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

* [PATCH 13/16] arm64: dts: renesas: r9a09g011: Add USB3 peripheral node
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (10 preceding siblings ...)
  2022-12-12 17:27 ` [PATCH 11/16] usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M Biju Das
@ 2022-12-12 17:28 ` Biju Das
  2022-12-12 17:28 ` [PATCH 14/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host Biju Das
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, linux-renesas-soc,
	devicetree, Fabrizio Castro

Add USB3 peripheral device node to RZ/V2M SoC dtsi.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 arch/arm64/boot/dts/renesas/r9a09g011.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r9a09g011.dtsi b/arch/arm64/boot/dts/renesas/r9a09g011.dtsi
index bad0b6b4bc3b..48674b948236 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g011.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g011.dtsi
@@ -97,6 +97,22 @@ usb3host: usb@85060000 {
 				power-domains = <&cpg>;
 				status = "disabled";
 			};
+
+			usb3peri: usb3peri {
+				compatible = "renesas,r9a09g011-usb3-peri",
+					     "renesas,rzv2m-usb3-peri";
+				interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
+					     <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
+				interrupt-names = "all_p", "drd", "bc", "gpi";
+				clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
+					 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
+				clock-names = "aclk", "reg";
+				resets = <&cpg R9A09G011_USB_ARESETN_P>;
+				power-domains = <&cpg>;
+				status = "disabled";
+			};
 		};
 
 		avb: ethernet@a3300000 {
-- 
2.25.1


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

* [PATCH 14/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (11 preceding siblings ...)
  2022-12-12 17:28 ` [PATCH 13/16] arm64: dts: renesas: r9a09g011: Add USB3 peripheral node Biju Das
@ 2022-12-12 17:28 ` Biju Das
  2022-12-12 17:28 ` [PATCH 15/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral Biju Das
  2022-12-12 17:28 ` [PATCH 16/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch Biju Das
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, linux-renesas-soc,
	devicetree, Fabrizio Castro

Enable USB3 Host and DRD modules on RZ/V2M EVK.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
index 73d7481b468e..f87302551388 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
@@ -154,6 +154,14 @@ &uart0 {
 	status = "okay";
 };
 
+&usb3drd {
+	status = "okay";
+};
+
+&usb3host {
+	status = "okay";
+};
+
 &wdt0 {
 	status = "okay";
 };
-- 
2.25.1


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

* [PATCH 15/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (12 preceding siblings ...)
  2022-12-12 17:28 ` [PATCH 14/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host Biju Das
@ 2022-12-12 17:28 ` Biju Das
  2022-12-12 17:28 ` [PATCH 16/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch Biju Das
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, linux-renesas-soc,
	devicetree, Fabrizio Castro

Enable USB3 Peripheral module on RZ/V2M EVK.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
index f87302551388..2c051f901ec7 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
@@ -162,6 +162,10 @@ &usb3host {
 	status = "okay";
 };
 
+&usb3peri {
+	status = "okay";
+};
+
 &wdt0 {
 	status = "okay";
 };
-- 
2.25.1


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

* [PATCH 16/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch
  2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
                   ` (13 preceding siblings ...)
  2022-12-12 17:28 ` [PATCH 15/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral Biju Das
@ 2022-12-12 17:28 ` Biju Das
  14 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-12 17:28 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, linux-renesas-soc,
	devicetree, Fabrizio Castro

Enable USB3 role switch on RZ/V2M EVK by linking USB3 peri node
with hd3ss3220 controller node.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
This patch depend upon [1]
[1] https://lore.kernel.org/linux-renesas-soc/20221209171836.71610-1-biju.das.jz@bp.renesas.com/T/#t
---
 .../boot/dts/renesas/r9a09g011-v2mevk2.dts    | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
index 2c051f901ec7..fdf623ca270b 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g011-v2mevk2.dts
@@ -22,6 +22,29 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		data-role = "dual";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				hs_ep: endpoint {
+					remote-endpoint = <&usb3_hs_ep>;
+				};
+			};
+			port@1 {
+				reg = <1>;
+				ss_ep: endpoint {
+					remote-endpoint = <&hd3ss3220_in_ep>;
+				};
+			};
+		};
+	};
+
 	memory@58000000 {
 		device_type = "memory";
 		/*
@@ -59,6 +82,28 @@ &i2c0 {
 	pinctrl-names = "default";
 	clock-frequency = <400000>;
 	status = "okay";
+
+	hd3ss3220@47 {
+		compatible = "ti,hd3ss3220";
+		reg = <0x47>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			port@0 {
+				reg = <0>;
+				hd3ss3220_in_ep: endpoint {
+					remote-endpoint = <&ss_ep>;
+				};
+			};
+			port@1 {
+				reg = <1>;
+				hd3ss3220_out_ep: endpoint {
+					remote-endpoint = <&usb3_role_switch>;
+				};
+			};
+		};
+	};
 };
 
 &i2c2 {
@@ -163,7 +208,26 @@ &usb3host {
 };
 
 &usb3peri {
+	companion = <&usb3host>;
 	status = "okay";
+	usb-role-switch;
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		port@0 {
+			reg = <0>;
+			usb3_hs_ep: endpoint {
+				remote-endpoint = <&hs_ep>;
+			};
+		};
+		port@1 {
+			reg = <1>;
+			usb3_role_switch: endpoint {
+				remote-endpoint = <&hd3ss3220_out_ep>;
+			};
+		};
+	};
 };
 
 &wdt0 {
-- 
2.25.1


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

* Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-12 17:27 ` [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding Biju Das
@ 2022-12-12 21:17   ` Rob Herring
  2022-12-13  6:43     ` Biju Das
  2022-12-13 14:29   ` Rob Herring
  1 sibling, 1 reply; 27+ messages in thread
From: Rob Herring @ 2022-12-12 21:17 UTC (permalink / raw)
  To: Biju Das
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, devicetree, Rob Herring,
	Fabrizio Castro, Krzysztof Kozlowski, linux-renesas-soc,
	linux-usb


On Mon, 12 Dec 2022 17:27:50 +0000, Biju Das wrote:
> Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
>  1 file changed, 123 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb@85070000: usb3peri:resets: [[4294967295, 29]] is too short
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb@85070000: usb3peri: 'reset-names' is a required property
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb@85070000: usb@85060000:compatible: 'oneOf' conditional failed, one must be fixed:
	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a7742', 'renesas,xhci-r8a7743', 'renesas,xhci-r8a7744', 'renesas,xhci-r8a7790', 'renesas,xhci-r8a7791', 'renesas,xhci-r8a7793']
	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a774a1', 'renesas,xhci-r8a774b1', 'renesas,xhci-r8a774c0', 'renesas,xhci-r8a774e1', 'renesas,xhci-r8a7795', 'renesas,xhci-r8a7796', 'renesas,xhci-r8a77961', 'renesas,xhci-r8a77965', 'renesas,xhci-r8a77990']
	'renesas,rcar-gen2-xhci' was expected
	'renesas,rcar-gen3-xhci' was expected
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb@85070000: usb@85060000:clocks: [[4294967295, 1, 34], [4294967295, 1, 36]] is too long
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb@85070000: usb@85060000: Unevaluated properties are not allowed ('clock-names', 'clocks', 'compatible' were unexpected)
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to match any schema with compatible: ['renesas,r9a09g011-xhci', 'renesas,rzv2m-xhci']
Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to match any schema with compatible: ['renesas,r9a09g011-xhci', 'renesas,rzv2m-xhci']
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb3peri: resets: [[4294967295, 29]] is too short
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.example.dtb: usb3peri: 'reset-names' is a required property
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20221212172804.1277751-3-biju.das.jz@bp.renesas.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* RE: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-12 21:17   ` Rob Herring
@ 2022-12-13  6:43     ` Biju Das
  0 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-13  6:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, devicetree, Rob Herring,
	Fabrizio Castro, Krzysztof Kozlowski, linux-renesas-soc,
	linux-usb

Hi Rob,

Looks like I missed to add dependency on later patch[1] on the same series for the below bot errors.

[1]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20221212172804.1277751-9-biju.das.jz@bp.renesas.com/

[2]
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20221212172804.1277751-5-biju.das.jz@bp.renesas.com/

I will send next version by arranging [1] and [2] before this patch.

Cheers,
Biju

> Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> 
> 
> On Mon, 12 Dec 2022 17:27:50 +0000, Biju Das wrote:
> > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> >  1 file changed, 123 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> >
> 
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb3peri:resets: [[4294967295, 29]] is
> too short
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb3peri: 'reset-names' is a required
> property
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000:compatible: 'oneOf'
> conditional failed, one must be fixed:
> 	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a7742',
> 'renesas,xhci-r8a7743', 'renesas,xhci-r8a7744', 'renesas,xhci-r8a7790',
> 'renesas,xhci-r8a7791', 'renesas,xhci-r8a7793']
> 	'renesas,r9a09g011-xhci' is not one of ['renesas,xhci-r8a774a1',
> 'renesas,xhci-r8a774b1', 'renesas,xhci-r8a774c0', 'renesas,xhci-r8a774e1',
> 'renesas,xhci-r8a7795', 'renesas,xhci-r8a7796', 'renesas,xhci-r8a77961',
> 'renesas,xhci-r8a77965', 'renesas,xhci-r8a77990']
> 	'renesas,rcar-gen2-xhci' was expected
> 	'renesas,rcar-gen3-xhci' was expected
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000:clocks: [[4294967295, 1,
> 34], [4294967295, 1, 36]] is too long
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb@85070000: usb@85060000: Unevaluated properties
> are not allowed ('clock-names', 'clocks', 'compatible' were unexpected)
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to
> match any schema with compatible: ['renesas,r9a09g011-xhci',
> 'renesas,rzv2m-xhci']
> Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb:0:0: /example-0/usb@85070000/usb@85060000: failed to
> match any schema with compatible: ['renesas,r9a09g011-xhci',
> 'renesas,rzv2m-xhci']
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb3peri: resets: [[4294967295, 29]] is too short
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,rzv2m-
> usb3drd.example.dtb: usb3peri: 'reset-names' is a required property
> 	From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/usb/renesas,usb3-peri.yaml
> 
> doc reference errors (make refcheckdocs):
> 
> See
> https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwor
> k.ozlabs.org%2Fproject%2Fdevicetree-
> bindings%2Fpatch%2F20221212172804.1277751-3-
> biju.das.jz%40bp.renesas.com&amp;data=05%7C01%7Cbiju.das.jz%40bp.renesas.c
> om%7C847aa4858e704c2d03a708dadc864f81%7C53d82571da1947e49cb4625a166a4a2a%7
> C0%7C0%7C638064766653956032%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC
> JQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2F
> uKtm48%2Bzxnx0ha2ddRFLUNiYFXtesrXOIPt46UhJ7c%3D&amp;reserved=0
> 
> The base for the series is generally the latest rc1. A different
> dependency should be noted in *this* patch.
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
> 
> pip3 install dtschema --upgrade
> 
> Please check and re-submit after running the above command yourself. Note
> that DT_SCHEMA_FILES can be set to your schema file to speed up checking
> your schema. However, it must be unset to test all examples with your
> schema.


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

* Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-12 17:27 ` [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding Biju Das
  2022-12-12 21:17   ` Rob Herring
@ 2022-12-13 14:29   ` Rob Herring
  2022-12-13 15:01     ` Biju Das
  1 sibling, 1 reply; 27+ messages in thread
From: Rob Herring @ 2022-12-13 14:29 UTC (permalink / raw)
  To: Biju Das
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, linux-usb, devicetree,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
>  1 file changed, 123 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> 
> diff --git a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> new file mode 100644
> index 000000000000..0c473c3398b3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> @@ -0,0 +1,123 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/usb/renesas,rzv2m-usb3drd.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Renesas RZ/V2M USB 3.1 DRD controller
> +
> +maintainers:
> +  - Biju Das <biju.das.jz@bp.renesas.com>
> +
> +description: |
> +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> +  * Role swapping function by the ID pin of the Micro-AB receptacle
> +  * Battery Charging Specification Revision 1.2
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> +      - const: renesas,rzv2m-usb3drd
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    items:
> +      - description: Peripheral AXI clock
> +      - description: APB clock
> +
> +  clock-names:
> +    items:
> +      - const: peri_axi
> +      - const: apb
> +
> +  power-domains:
> +    maxItems: 1
> +
> +  resets:
> +    items:
> +      - description: DRD reset
> +      - description: Peripheral reset
> +
> +  reset-names:
> +    items:
> +      - const: drd_reset
> +      - const: aresetn_p
> +
> +  ranges: true
> +
> +  '#address-cells':
> +    enum: [ 1, 2 ]
> +
> +  '#size-cells':
> +    enum: [ 1, 2 ]
> +
> +  usb3peri:
> +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> +
> +patternProperties:
> +  "^usb@[0-9a-f]+$":
> +    type: object
> +    $ref: renesas,usb-xhci.yaml#
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - power-domains
> +  - resets
> +  - reset-names
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    usb3drd: usb@85070000 {
> +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-usb3drd";
> +        reg = <0x85070000 0x1000>;
> +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +        clock-names = "peri_axi", "apb";
> +        power-domains = <&cpg>;
> +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> +                 <&cpg R9A09G011_USB_ARESETN_P>;
> +        reset-names = "drd_reset", "aresetn_p";
> +        ranges;
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +
> +        usb3host: usb@85060000 {
> +           compatible = "renesas,r9a09g011-xhci",
> +                        "renesas,rzv2m-xhci";
> +           reg = <0x85060000 0x2000>;
> +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +           clock-names = "host_axi", "reg";
> +           power-domains = <&cpg>;
> +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> +        };
> +
> +        usb3peri: usb3peri {
> +           compatible = "renesas,r9a09g011-usb3-peri",
> +                        "renesas,rzv2m-usb3-peri";
> +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> +           interrupt-names = "all_p", "drd", "bc", "gpi";
> +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> +           clock-names = "aclk", "reg";
> +           power-domains = <&cpg>;
> +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> +        };

The USB device ctrlr doesn't have registers? It looks to me like you've 
created 3 nodes for instantiating drivers rather that because you have 3 
separate h/w blocks. Either you should split this to 2 independent nodes 
or move usb3peri resources to the parent node. That would only be 
interrupts because everything else is already there.

Rob

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

* RE: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-13 14:29   ` Rob Herring
@ 2022-12-13 15:01     ` Biju Das
  2022-12-13 15:54       ` Rob Herring
  0 siblings, 1 reply; 27+ messages in thread
From: Biju Das @ 2022-12-13 15:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, linux-usb, devicetree,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

Hi Rob,

> Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> 
> On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> >  1 file changed, 123 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> >
> > diff --git
> > a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > new file mode 100644
> > index 000000000000..0c473c3398b3
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > @@ -0,0 +1,123 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
> > +---
> > +
> > +title: Renesas RZ/V2M USB 3.1 DRD controller
> > +
> > +maintainers:
> > +  - Biju Das <biju.das.jz@bp.renesas.com>
> > +
> > +description: |
> > +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> > +  * Role swapping function by the ID pin of the Micro-AB receptacle
> > +  * Battery Charging Specification Revision 1.2
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> > +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> > +      - const: renesas,rzv2m-usb3drd
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    items:
> > +      - description: Peripheral AXI clock
> > +      - description: APB clock
> > +
> > +  clock-names:
> > +    items:
> > +      - const: peri_axi
> > +      - const: apb
> > +
> > +  power-domains:
> > +    maxItems: 1
> > +
> > +  resets:
> > +    items:
> > +      - description: DRD reset
> > +      - description: Peripheral reset
> > +
> > +  reset-names:
> > +    items:
> > +      - const: drd_reset
> > +      - const: aresetn_p
> > +
> > +  ranges: true
> > +
> > +  '#address-cells':
> > +    enum: [ 1, 2 ]
> > +
> > +  '#size-cells':
> > +    enum: [ 1, 2 ]
> > +
> > +  usb3peri:
> > +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> > +
> > +patternProperties:
> > +  "^usb@[0-9a-f]+$":
> > +    type: object
> > +    $ref: renesas,usb-xhci.yaml#
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - power-domains
> > +  - resets
> > +  - reset-names
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > +
> > +    usb3drd: usb@85070000 {
> > +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-
> usb3drd";
> > +        reg = <0x85070000 0x1000>;
> > +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +        clock-names = "peri_axi", "apb";
> > +        power-domains = <&cpg>;
> > +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> > +                 <&cpg R9A09G011_USB_ARESETN_P>;
> > +        reset-names = "drd_reset", "aresetn_p";
> > +        ranges;
> > +        #address-cells = <1>;
> > +        #size-cells = <1>;
> > +
> > +        usb3host: usb@85060000 {
> > +           compatible = "renesas,r9a09g011-xhci",
> > +                        "renesas,rzv2m-xhci";
> > +           reg = <0x85060000 0x2000>;
> > +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +           clock-names = "host_axi", "reg";
> > +           power-domains = <&cpg>;
> > +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> > +        };
> > +
> > +        usb3peri: usb3peri {
> > +           compatible = "renesas,r9a09g011-usb3-peri",
> > +                        "renesas,rzv2m-usb3-peri";
> > +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> > +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> > +           interrupt-names = "all_p", "drd", "bc", "gpi";
> > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > +           clock-names = "aclk", "reg";
> > +           power-domains = <&cpg>;
> > +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> > +        };
> 
> The USB device ctrlr doesn't have registers? It looks to me like you've
> created 3 nodes for instantiating drivers rather that because you have 3
> separate h/w blocks. Either you should split this to 2 independent nodes
> or move usb3peri resources to the parent node. That would only be
> interrupts because everything else is already there.

Address map of USB device controller is 0x85070000-0x85070400
Address map of USB3 DRD is 0x85070400-0x850704FF

The advantage of the current split is that, 

1) With this model, I can use USB3 storage device for booting and mounting rootFS 
as XHCI driver is built-in and USB3 device ctrlr is usually module.

2) To reuse the usb device controller code as much as possible.

If I create 2 independent nodes, then there will be more exported API's
between USB3 peri and USB3 drd driver.

If I move usb3peri resources to the parent node, then I won't be able to
achieve 1)

Please let me know, what is the best way to move forward?

Cheers,
Biju






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

* Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-13 15:01     ` Biju Das
@ 2022-12-13 15:54       ` Rob Herring
  2023-01-11 14:18         ` Biju Das
  0 siblings, 1 reply; 27+ messages in thread
From: Rob Herring @ 2022-12-13 15:54 UTC (permalink / raw)
  To: Biju Das
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, linux-usb, devicetree,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

On Tue, Dec 13, 2022 at 03:01:34PM +0000, Biju Das wrote:
> Hi Rob,
> 
> > Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> > 
> > On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> > > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123 ++++++++++++++++++
> > >  1 file changed, 123 insertions(+)
> > >  create mode 100644
> > > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > >
> > > diff --git
> > > a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > new file mode 100644
> > > index 000000000000..0c473c3398b3
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > @@ -0,0 +1,123 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
> > > +---
> > > +
> > > +title: Renesas RZ/V2M USB 3.1 DRD controller
> > > +
> > > +maintainers:
> > > +  - Biju Das <biju.das.jz@bp.renesas.com>
> > > +
> > > +description: |
> > > +  The RZ/V2{M, MA} USB3.1 DRD module supports the following functions
> > > +  * Role swapping function by the ID pin of the Micro-AB receptacle
> > > +  * Battery Charging Specification Revision 1.2
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> > > +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> > > +      - const: renesas,rzv2m-usb3drd
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  clocks:
> > > +    items:
> > > +      - description: Peripheral AXI clock
> > > +      - description: APB clock
> > > +
> > > +  clock-names:
> > > +    items:
> > > +      - const: peri_axi
> > > +      - const: apb
> > > +
> > > +  power-domains:
> > > +    maxItems: 1
> > > +
> > > +  resets:
> > > +    items:
> > > +      - description: DRD reset
> > > +      - description: Peripheral reset
> > > +
> > > +  reset-names:
> > > +    items:
> > > +      - const: drd_reset
> > > +      - const: aresetn_p
> > > +
> > > +  ranges: true
> > > +
> > > +  '#address-cells':
> > > +    enum: [ 1, 2 ]
> > > +
> > > +  '#size-cells':
> > > +    enum: [ 1, 2 ]
> > > +
> > > +  usb3peri:
> > > +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> > > +
> > > +patternProperties:
> > > +  "^usb@[0-9a-f]+$":
> > > +    type: object
> > > +    $ref: renesas,usb-xhci.yaml#
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - clocks
> > > +  - clock-names
> > > +  - power-domains
> > > +  - resets
> > > +  - reset-names
> > > +
> > > +additionalProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> > > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > > +
> > > +    usb3drd: usb@85070000 {
> > > +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-
> > usb3drd";
> > > +        reg = <0x85070000 0x1000>;
> > > +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +        clock-names = "peri_axi", "apb";
> > > +        power-domains = <&cpg>;
> > > +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> > > +                 <&cpg R9A09G011_USB_ARESETN_P>;
> > > +        reset-names = "drd_reset", "aresetn_p";
> > > +        ranges;
> > > +        #address-cells = <1>;
> > > +        #size-cells = <1>;
> > > +
> > > +        usb3host: usb@85060000 {
> > > +           compatible = "renesas,r9a09g011-xhci",
> > > +                        "renesas,rzv2m-xhci";
> > > +           reg = <0x85060000 0x2000>;
> > > +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +           clock-names = "host_axi", "reg";
> > > +           power-domains = <&cpg>;
> > > +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> > > +        };
> > > +
> > > +        usb3peri: usb3peri {
> > > +           compatible = "renesas,r9a09g011-usb3-peri",
> > > +                        "renesas,rzv2m-usb3-peri";
> > > +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> > > +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> > > +           interrupt-names = "all_p", "drd", "bc", "gpi";
> > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > +           clock-names = "aclk", "reg";
> > > +           power-domains = <&cpg>;
> > > +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> > > +        };
> > 
> > The USB device ctrlr doesn't have registers? It looks to me like you've
> > created 3 nodes for instantiating drivers rather that because you have 3
> > separate h/w blocks. Either you should split this to 2 independent nodes
> > or move usb3peri resources to the parent node. That would only be
> > interrupts because everything else is already there.
> 
> Address map of USB device controller is 0x85070000-0x85070400
> Address map of USB3 DRD is 0x85070400-0x850704FF

Then your DT should reflect that with 'reg' in usb3peri.

Why does the device ctrlr have a DRD interrupt?

> The advantage of the current split is that, 
> 
> 1) With this model, I can use USB3 storage device for booting and mounting rootFS 
> as XHCI driver is built-in and USB3 device ctrlr is usually module.

Sounds like a Linux problem. What does that have to do with the binding?

> 
> 2) To reuse the usb device controller code as much as possible.
> 
> If I create 2 independent nodes, then there will be more exported API's
> between USB3 peri and USB3 drd driver.

Why if that's a common split, then doesn't Linux have a defined 
interface?

There is no reason you can spawn 2 drivers from 1 DT node if that's what 
you need. Describe h/w blocks, not nodes for drivers. Sometimes the h/w 
isn't partitioned just like Linux would like. That's a Linux problem, 
not something to 'fix' in DT.

Rob

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

* Re: [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe()
  2022-12-12 17:27 ` [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe() Biju Das
@ 2022-12-15 10:13   ` Geert Uytterhoeven
  0 siblings, 0 replies; 27+ messages in thread
From: Geert Uytterhoeven @ 2022-12-15 10:13 UTC (permalink / raw)
  To: Biju Das
  Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, Geert Uytterhoeven,
	Fabrizio Castro, linux-renesas-soc

On Mon, Dec 12, 2022 at 6:28 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> It is always better to acquire all the clock resources first and
> then do the clock operations.
>
> This patch acquires all the optional clocks first and then calls
> corresponding prepare_enable().
>
> There is no functional change.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

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] 27+ messages in thread

* Re: [PATCH 06/16] usb: host: xhci-plat: Add reset support
  2022-12-12 17:27 ` [PATCH 06/16] usb: host: xhci-plat: Add reset support Biju Das
@ 2022-12-15 10:20   ` Geert Uytterhoeven
  0 siblings, 0 replies; 27+ messages in thread
From: Geert Uytterhoeven @ 2022-12-15 10:20 UTC (permalink / raw)
  To: Biju Das
  Cc: Philipp Zabel, Mathias Nyman, Greg Kroah-Hartman, linux-usb,
	Fabrizio Castro, linux-renesas-soc, Justin Chen

Hi Biju,

CC Justin

On Mon, Dec 12, 2022 at 6:28 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Add optional reset support. This is in preparation to adding USB xHCI
> support for RZ/V2M SoC.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>\

Thanks for your patch!

> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -19,6 +19,7 @@
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
>  #include <linux/usb/of.h>
> +#include <linux/reset.h>
>
>  #include "xhci.h"
>  #include "xhci-plat.h"
> @@ -263,10 +264,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
>                 goto put_hcd;
>         }
>
> -       ret = clk_prepare_enable(xhci->reg_clk);
> +       xhci->reset = devm_reset_control_array_get_optional_shared(&pdev->dev);
> +       if (IS_ERR(xhci->reset)) {
> +               ret = PTR_ERR(xhci->reset);
> +               goto put_hcd;
> +       }
> +
> +       ret = reset_control_deassert(xhci->reset);
>         if (ret)
>                 goto put_hcd;
>
> +       ret = clk_prepare_enable(xhci->reg_clk);
> +       if (ret)
> +               goto err_reset;
> +
>         ret = clk_prepare_enable(xhci->clk);
>         if (ret)
>                 goto disable_reg_clk;
> @@ -377,6 +388,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  disable_reg_clk:
>         clk_disable_unprepare(xhci->reg_clk);
>
> +err_reset:
> +       reset_control_assert(xhci->reset);
> +
>  put_hcd:
>         usb_put_hcd(hcd);
>
> @@ -412,6 +426,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>
>         clk_disable_unprepare(clk);
>         clk_disable_unprepare(reg_clk);
> +       reset_control_assert(xhci->reset);
>         usb_put_hcd(hcd);
>
>         pm_runtime_disable(&dev->dev);

LGTM, so
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Just wondering if the reset should be (de)asserted in the suspend/resume
path, too.  But that can only affect the Broadcom STB platforms, which
probably don't have the resets property.  I can't check as there no users
in upstream DTS.

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] 27+ messages in thread

* Re: [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support
  2022-12-12 17:27 ` [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support Biju Das
@ 2022-12-16 16:10   ` Rob Herring
  2022-12-16 17:10     ` Biju Das
  0 siblings, 1 reply; 27+ messages in thread
From: Rob Herring @ 2022-12-16 16:10 UTC (permalink / raw)
  To: Biju Das
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, Lad Prabhakar,
	Yoshihiro Shimoda, linux-usb, devicetree, Geert Uytterhoeven,
	Fabrizio Castro, linux-renesas-soc

On Mon, Dec 12, 2022 at 05:27:52PM +0000, Biju Das wrote:
> Document the RZ/V2M SoC bindings.
> The RZ/V2M SoC is a little different to the R-Car implementations.
> You can access the registers associated with the currently set DRD mode,
> therefore as part of init, we have to set the DRD mode to host.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  .../bindings/usb/renesas,usb-xhci.yaml        | 41 +++++++++++++++++--
>  1 file changed, 37 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> index 4c5efaf02308..ae678d249785 100644
> --- a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> +++ b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> @@ -10,9 +10,6 @@ maintainers:
>    - Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>    - Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>  
> -allOf:
> -  - $ref: "usb-xhci.yaml"
> -
>  properties:
>    compatible:
>      oneOf:
> @@ -37,6 +34,11 @@ properties:
>                - renesas,xhci-r8a77965 # R-Car M3-N
>                - renesas,xhci-r8a77990 # R-Car E3
>            - const: renesas,rcar-gen3-xhci # R-Car Gen3 and RZ/G2
> +      - items:
> +          - enum:
> +              - renesas,r9a09g011-xhci # RZ/V2M
> +              - renesas,r9a09g055-xhci # RZ/V2MA
> +          - const: renesas,rzv2m-xhci  # RZ/{V2M, V2MA}
>  
>    reg:
>      maxItems: 1
> @@ -45,7 +47,16 @@ properties:
>      maxItems: 1
>  
>    clocks:
> -    maxItems: 1
> +    minItems: 1
> +    items:
> +      - description: Main clock for host
> +      - description: Register access clock
> +
> +  clock-names:
> +    minItems: 1
> +    items:
> +      - const: host_axi

Drop 'host_'

> +      - const: reg
>  
>    phys:
>      maxItems: 1
> @@ -68,6 +79,28 @@ required:
>    - power-domains
>    - resets
>  
> +allOf:
> +  - $ref: "usb-xhci.yaml"

Drop quotes since you are touching this.

With that,

Reviewed-by: Rob Herring <robh@kernel.org>

> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - renesas,rzv2m-xhci
> +    then:
> +      properties:
> +        clocks:
> +          minItems: 2
> +        clock-names:
> +          minItems: 2
> +      required:
> +        - clock-names
> +    else:
> +      properties:
> +        clocks:
> +          maxItems: 1
> +
>  unevaluatedProperties: false
>  
>  examples:
> -- 
> 2.25.1
> 
> 

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

* RE: [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support
  2022-12-16 16:10   ` Rob Herring
@ 2022-12-16 17:10     ` Biju Das
  0 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2022-12-16 17:10 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, Prabhakar Mahadev Lad,
	Yoshihiro Shimoda, linux-usb, devicetree, Geert Uytterhoeven,
	Fabrizio Castro, linux-renesas-soc

Hi Rob,

> Subject: Re: [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document
> RZ/V2M support
> 
> On Mon, Dec 12, 2022 at 05:27:52PM +0000, Biju Das wrote:
> > Document the RZ/V2M SoC bindings.
> > The RZ/V2M SoC is a little different to the R-Car implementations.
> > You can access the registers associated with the currently set DRD
> > mode, therefore as part of init, we have to set the DRD mode to host.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  .../bindings/usb/renesas,usb-xhci.yaml        | 41 +++++++++++++++++--
> >  1 file changed, 37 insertions(+), 4 deletions(-)
> >
> > diff --git
> > a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> > b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> > index 4c5efaf02308..ae678d249785 100644
> > --- a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> > +++ b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> > @@ -10,9 +10,6 @@ maintainers:
> >    - Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >    - Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> >
> > -allOf:
> > -  - $ref: "usb-xhci.yaml"
> > -
> >  properties:
> >    compatible:
> >      oneOf:
> > @@ -37,6 +34,11 @@ properties:
> >                - renesas,xhci-r8a77965 # R-Car M3-N
> >                - renesas,xhci-r8a77990 # R-Car E3
> >            - const: renesas,rcar-gen3-xhci # R-Car Gen3 and RZ/G2
> > +      - items:
> > +          - enum:
> > +              - renesas,r9a09g011-xhci # RZ/V2M
> > +              - renesas,r9a09g055-xhci # RZ/V2MA
> > +          - const: renesas,rzv2m-xhci  # RZ/{V2M, V2MA}
> >
> >    reg:
> >      maxItems: 1
> > @@ -45,7 +47,16 @@ properties:
> >      maxItems: 1
> >
> >    clocks:
> > -    maxItems: 1
> > +    minItems: 1
> > +    items:
> > +      - description: Main clock for host
> > +      - description: Register access clock
> > +
> > +  clock-names:
> > +    minItems: 1
> > +    items:
> > +      - const: host_axi
> 
> Drop 'host_'

OK.

> 
> > +      - const: reg
> >
> >    phys:
> >      maxItems: 1
> > @@ -68,6 +79,28 @@ required:
> >    - power-domains
> >    - resets
> >
> > +allOf:
> > +  - $ref: "usb-xhci.yaml"
> 
> Drop quotes since you are touching this.

OK, Will fix this.

Cheers,
Biju

> 
> With that,
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> 
> > +
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            enum:
> > +              - renesas,rzv2m-xhci
> > +    then:
> > +      properties:
> > +        clocks:
> > +          minItems: 2
> > +        clock-names:
> > +          minItems: 2
> > +      required:
> > +        - clock-names
> > +    else:
> > +      properties:
> > +        clocks:
> > +          maxItems: 1
> > +
> >  unevaluatedProperties: false
> >
> >  examples:
> > --
> > 2.25.1
> >
> >

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

* Re: [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries
  2022-12-12 17:27 ` [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries Biju Das
@ 2022-12-21 14:55   ` Geert Uytterhoeven
  0 siblings, 0 replies; 27+ messages in thread
From: Geert Uytterhoeven @ 2022-12-21 14:55 UTC (permalink / raw)
  To: Biju Das
  Cc: Michael Turquette, Stephen Boyd, linux-renesas-soc, linux-clk,
	Fabrizio Castro

On Mon, Dec 12, 2022 at 6:28 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Add USB clock and reset entries to CPG driver.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

I couldn't review the clock parents, as that information seems to
be restricted, but the rest LGTM.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-clk-for-v6.3.

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] 27+ messages in thread

* RE: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
  2022-12-13 15:54       ` Rob Herring
@ 2023-01-11 14:18         ` Biju Das
  0 siblings, 0 replies; 27+ messages in thread
From: Biju Das @ 2023-01-11 14:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman, linux-usb, devicetree,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc



> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: 13 December 2022 15:55
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>; Greg Kroah-
> Hartman <gregkh@linuxfoundation.org>; linux-usb@vger.kernel.org;
> devicetree@vger.kernel.org; Geert Uytterhoeven <geert+renesas@glider.be>;
> Fabrizio Castro <fabrizio.castro.jz@renesas.com>; linux-renesas-
> soc@vger.kernel.org
> Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding
> 
> On Tue, Dec 13, 2022 at 03:01:34PM +0000, Biju Das wrote:
> > Hi Rob,
> >
> > > Subject: Re: [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD
> > > binding
> > >
> > > On Mon, Dec 12, 2022 at 05:27:50PM +0000, Biju Das wrote:
> > > > Add device tree bindings for the RZ/V2{M, MA} USB3DRD module.
> > > >
> > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > > ---
> > > >  .../bindings/usb/renesas,rzv2m-usb3drd.yaml   | 123
> ++++++++++++++++++
> > > >  1 file changed, 123 insertions(+)  create mode 100644
> > > > Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > >
> > > > diff --git
> > > > a/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > > b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.yaml
> > > > new file mode 100644
> > > > index 000000000000..0c473c3398b3
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/usb/renesas,rzv2m-usb3drd.
> > > > +++ yaml
> > > > @@ -0,0 +1,123 @@
> > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML
> > > > +1.2
> > > > +---
> > > > +
> > > > +title: Renesas RZ/V2M USB 3.1 DRD controller
> > > > +
> > > > +maintainers:
> > > > +  - Biju Das <biju.das.jz@bp.renesas.com>
> > > > +
> > > > +description: |
> > > > +  The RZ/V2{M, MA} USB3.1 DRD module supports the following
> > > > +functions
> > > > +  * Role swapping function by the ID pin of the Micro-AB
> > > > +receptacle
> > > > +  * Battery Charging Specification Revision 1.2
> > > > +
> > > > +properties:
> > > > +  compatible:
> > > > +    items:
> > > > +      - enum:
> > > > +          - renesas,r9a09g011-usb3drd  # RZ/V2M
> > > > +          - renesas,r9a09g055-usb3drd  # RZ/V2MA
> > > > +      - const: renesas,rzv2m-usb3drd
> > > > +
> > > > +  reg:
> > > > +    maxItems: 1
> > > > +
> > > > +  clocks:
> > > > +    items:
> > > > +      - description: Peripheral AXI clock
> > > > +      - description: APB clock
> > > > +
> > > > +  clock-names:
> > > > +    items:
> > > > +      - const: peri_axi
> > > > +      - const: apb
> > > > +
> > > > +  power-domains:
> > > > +    maxItems: 1
> > > > +
> > > > +  resets:
> > > > +    items:
> > > > +      - description: DRD reset
> > > > +      - description: Peripheral reset
> > > > +
> > > > +  reset-names:
> > > > +    items:
> > > > +      - const: drd_reset
> > > > +      - const: aresetn_p
> > > > +
> > > > +  ranges: true
> > > > +
> > > > +  '#address-cells':
> > > > +    enum: [ 1, 2 ]
> > > > +
> > > > +  '#size-cells':
> > > > +    enum: [ 1, 2 ]
> > > > +
> > > > +  usb3peri:
> > > > +    $ref: /schemas/usb/renesas,usb3-peri.yaml
> > > > +
> > > > +patternProperties:
> > > > +  "^usb@[0-9a-f]+$":
> > > > +    type: object
> > > > +    $ref: renesas,usb-xhci.yaml#
> > > > +
> > > > +required:
> > > > +  - compatible
> > > > +  - reg
> > > > +  - clocks
> > > > +  - clock-names
> > > > +  - power-domains
> > > > +  - resets
> > > > +  - reset-names
> > > > +
> > > > +additionalProperties: false
> > > > +
> > > > +examples:
> > > > +  - |
> > > > +    #include <dt-bindings/clock/r9a09g011-cpg.h>
> > > > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > > > +
> > > > +    usb3drd: usb@85070000 {
> > > > +        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-
> > > usb3drd";
> > > > +        reg = <0x85070000 0x1000>;
> > > > +        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > > +                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > > +        clock-names = "peri_axi", "apb";
> > > > +        power-domains = <&cpg>;
> > > > +        resets = <&cpg R9A09G011_USB_DRD_RESET>,
> > > > +                 <&cpg R9A09G011_USB_ARESETN_P>;
> > > > +        reset-names = "drd_reset", "aresetn_p";
> > > > +        ranges;
> > > > +        #address-cells = <1>;
> > > > +        #size-cells = <1>;
> > > > +
> > > > +        usb3host: usb@85060000 {
> > > > +           compatible = "renesas,r9a09g011-xhci",
> > > > +                        "renesas,rzv2m-xhci";
> > > > +           reg = <0x85060000 0x2000>;
> > > > +           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
> > > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
> > > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > > +           clock-names = "host_axi", "reg";
> > > > +           power-domains = <&cpg>;
> > > > +           resets = <&cpg R9A09G011_USB_ARESETN_H>;
> > > > +        };
> > > > +
> > > > +        usb3peri: usb3peri {
> > > > +           compatible = "renesas,r9a09g011-usb3-peri",
> > > > +                        "renesas,rzv2m-usb3-peri";
> > > > +           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>,
> > > > +                        <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
> > > > +                        <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
> > > > +                        <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
> > > > +           interrupt-names = "all_p", "drd", "bc", "gpi";
> > > > +           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
> > > > +                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
> > > > +           clock-names = "aclk", "reg";
> > > > +           power-domains = <&cpg>;
> > > > +           resets = <&cpg R9A09G011_USB_ARESETN_P>;
> > > > +        };
> > >
> > > The USB device ctrlr doesn't have registers? It looks to me like
> > > you've created 3 nodes for instantiating drivers rather that because
> > > you have 3 separate h/w blocks. Either you should split this to 2
> > > independent nodes or move usb3peri resources to the parent node.
> > > That would only be interrupts because everything else is already there.
> >
> > Address map of USB device controller is 0x85070000-0x85070400 Address
> > map of USB3 DRD is 0x85070400-0x850704FF
> 
> Then your DT should reflect that with 'reg' in usb3peri.

OK will add 'reg' in usb3peri.

> 
> Why does the device ctrlr have a DRD interrupt?

OK, Will move DRD related interrupts from device ctrlr to here.
I have prototyped this as below [1]. Please correct me if you have different opinion.

> 
> > The advantage of the current split is that,
> >
> > 1) With this model, I can use USB3 storage device for booting and
> > mounting rootFS as XHCI driver is built-in and USB3 device ctrlr is
> usually module.
> 
> Sounds like a Linux problem. What does that have to do with the binding?

Ya, Both host and device operation depends upon DRD block. We need to do
Host or device reset release + setting host or device operation in DRD block
before accessing its registers.

> 
> >
> > 2) To reuse the usb device controller code as much as possible.
> >
> > If I create 2 independent nodes, then there will be more exported
> > API's between USB3 peri and USB3 drd driver.
> 
> Why if that's a common split, then doesn't Linux have a defined interface?

If I just create 2 independent nodes for host and device, then I get kernel crash
The reason is , Without reset release and setting host operation in DRD block
We are accessing host registers. The only way to avoid kernel crash is by doing
a hack.
ie, Io remap of that DRD register, configure for host operation and then access
host registers.

> 
> There is no reason you can spawn 2 drivers from 1 DT node if that's what you
> need. Describe h/w blocks, not nodes for drivers. Sometimes the h/w isn't
> partitioned just like Linux would like. That's a Linux problem, not
> something to 'fix' in DT.

I will send next version based on [1], please correct me if you have other suggestion.

Cheers,
Biju

[1]
properties:
  compatible:
    items:
      - enum:
          - renesas,r9a09g011-usb3drd  # RZ/V2M
          - renesas,r9a09g055-usb3drd  # RZ/V2MA
      - const: renesas,rzv2m-usb3drd

  reg:
    maxItems: 1

  interrupts:
    items:
      - description: Dual Role Device (DRD)
      - description: Battery Charging
      - description: Global Purpose Input

  interrupt-names:
    items:
      - const: drd
      - const: bc
      - const: gpi

  clocks:
    items:
      - description: Peripheral AXI clock
      - description: APB clock

  clock-names:
    items:
      - const: axi
      - const: reg

  power-domains:
    maxItems: 1

  resets:
    maxItems: 1

  ranges: true

  '#address-cells':
    enum: [ 1, 2 ]

  '#size-cells':
    enum: [ 1, 2 ]

patternProperties:
  "^usb3peri@[0-9a-f]+$":
    type: object
    $ref: /schemas/usb/renesas,usb3-peri.yaml

  "^usb@[0-9a-f]+$":
    type: object
    $ref: renesas,usb-xhci.yaml#

required:
  - compatible
  - reg
  - interrupts
  - interrupt-names
  - clocks
  - clock-names
  - power-domains
  - resets

additionalProperties: false

examples:
  - |
    #include <dt-bindings/clock/r9a09g011-cpg.h>
    #include <dt-bindings/interrupt-controller/arm-gic.h>

    usb3drd: usb@85070400 {
        compatible = "renesas,r9a09g011-usb3drd", "renesas,rzv2m-usb3drd";
        reg = <0x85070400 0x100>;
        interrupts = <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>;
        interrupt-names = "drd", "bc", "gpi";
        clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
                 <&cpg CPG_MOD R9A09G011_USB_PCLK>;
        clock-names = "axi", "reg";
        power-domains = <&cpg>;
        resets = <&cpg R9A09G011_USB_DRD_RESET>;
        ranges;
        #address-cells = <1>;
        #size-cells = <1>;

        usb3host: usb@85060000 {
           compatible = "renesas,r9a09g011-xhci",
                        "renesas,rzv2m-xhci";
           reg = <0x85060000 0x2000>;
           interrupts = <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>;
           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_H>,
                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
           clock-names = "axi", "reg";
           power-domains = <&cpg>;
           resets = <&cpg R9A09G011_USB_ARESETN_H>;
        };

        usb3peri: usb3peri@85070000 {
           compatible = "renesas,r9a09g011-usb3-peri",
                        "renesas,rzv2m-usb3-peri";
           reg = <0x85070000 0x400>;
           interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
           clocks = <&cpg CPG_MOD R9A09G011_USB_ACLK_P>,
                    <&cpg CPG_MOD R9A09G011_USB_PCLK>;
           clock-names = "axi", "reg";
           power-domains = <&cpg>;
           resets = <&cpg R9A09G011_USB_ARESETN_P>;
        };
    };

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

end of thread, other threads:[~2023-01-11 14:18 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 17:27 [PATCH 00/16] ADD USB3.1 HOST, Peri and DRD support Biju Das
2022-12-12 17:27 ` [PATCH 01/16] clk: renesas: r9a09g011: Add USB clock and reset entries Biju Das
2022-12-21 14:55   ` Geert Uytterhoeven
2022-12-12 17:27 ` [PATCH 02/16] dt-bindings: usb: Add RZ/V2M USB3DRD binding Biju Das
2022-12-12 21:17   ` Rob Herring
2022-12-13  6:43     ` Biju Das
2022-12-13 14:29   ` Rob Herring
2022-12-13 15:01     ` Biju Das
2022-12-13 15:54       ` Rob Herring
2023-01-11 14:18         ` Biju Das
2022-12-12 17:27 ` [PATCH 03/16] usb: gadget: Add support for RZ/V2M USB3DRD driver Biju Das
2022-12-12 17:27 ` [PATCH 04/16] dt-bindings: usb: renesas,usb-xhci: Document RZ/V2M support Biju Das
2022-12-16 16:10   ` Rob Herring
2022-12-16 17:10     ` Biju Das
2022-12-12 17:27 ` [PATCH 05/16] usb: host: xhci-plat: Improve clock handling in probe() Biju Das
2022-12-15 10:13   ` Geert Uytterhoeven
2022-12-12 17:27 ` [PATCH 06/16] usb: host: xhci-plat: Add reset support Biju Das
2022-12-15 10:20   ` Geert Uytterhoeven
2022-12-12 17:27 ` [PATCH 07/16] xhci: host: Add Renesas RZ/V2M SoC support Biju Das
2022-12-12 17:27 ` [PATCH 08/16] dt-bindings: usb: renesas,usb3-peri: Update reset property Biju Das
2022-12-12 17:27 ` [PATCH 09/16] dt-bindings: usb: renesas,usb3-peri: Document RZ/V2MA bindings Biju Das
2022-12-12 17:27 ` [PATCH 10/16] usb: gadget: udc: renesas_usb3: Remove drd_reset handling Biju Das
2022-12-12 17:27 ` [PATCH 11/16] usb: gadget: udc: renesas_usb3: Add role switch support for RZ/V2M Biju Das
2022-12-12 17:28 ` [PATCH 13/16] arm64: dts: renesas: r9a09g011: Add USB3 peripheral node Biju Das
2022-12-12 17:28 ` [PATCH 14/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 DRD and Host Biju Das
2022-12-12 17:28 ` [PATCH 15/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 Peripheral Biju Das
2022-12-12 17:28 ` [PATCH 16/16] arm64: dts: renesas: rzv2mevk2: Enable USB3 role switch Biju Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.