2022-12-13 13:53:51

by Herve Codina

[permalink] [raw]
Subject: [PATCH v4 0/5] Add the Renesas USBF controller support

Hi,

This series add support for the Renesas USBF controller (USB Device
Controller) available in the Renesas RZ/N1 SoC.

Based on previous iteration:
https://lore.kernel.org/all/[email protected]/
The 'depends-on' property was removed.

Patches 1, 3, 4 and 5 are related to the USBF controller with a new
binding definition, the driver itself and myself as a maintainer
of this controller.

Patch 2 handles h2mode in sysctrl.

Hope that this v4 can lead to some feedbacks on the USB device
controller itself (patch 3).

Best regards,
Herve Codina

Changes v3 -> v4:
- v3 patches 1, 2, 3 and 4 removed

- Patch 1 (v3 patch 5)
Remove 'depends-on' property

- Patch 2 (v3 patch 6)
Add 'Reviewed-by: Geert Uytterhoeven <[email protected]>'

- Patch 3 (v3 patch 7)
Fix warning raised by the kernel test robot

- Patch 4 (v3 patch 8)
Remove 'depends-on' property
add 'Reviewed-by: Geert Uytterhoeven <[email protected]>'

- Patch 5 (v3 patch 9)
No changes

Changes v2 -> v3:
- v2 Patches 1, 2 and 3 removed.

- Patches 1, 2, 3 and 4 (new patches)

- Patch 5 (v2 patch 4):
Add 'depends-on' property
Removed redundant 'binding' word

- Patch 6 (new patch)

- Patch 7 (v2 patch 5)
Removed h2mode checking. This check is no more needed and the API no more
available.

- Patch 8 (v2 patch 6)
Add 'depends-on' property

- Patch 9 (v2 patch 7)
Fix file name

Changes v1 -> v2:
- Patch 1:
Rename r9a06g032_sysctrl_get_usb_h2mode to r9a06g032_sysctrl_get_usb_role
and return USB_ROLE_{HOST,DEVICE} or an error code.
Reword commit log

- Patches 2 and 3:
No changes. Some previous feedbacks still need to be taken into account
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

- Patch 4:
Rename file from renesas,usbf.yaml to renesas,rzn1-usbf.yaml.
Remove 'oneOf'.
Add blank line and line break.
Add 'power-domains'.
Reword commit log

- Patch 5:
Remove clocks handling (handled by runtime PM through the clock domain
pointed by power-domains).
Fix compilation warning raised by the 'kernel test robot'.

- Patch 6:
Add 'power-domains'

- Patch 7:
Add 'Reviewed-by: Geert Uytterhoeven <[email protected]>'


Herve Codina (5):
dt-bindings: usb: add the Renesas RZ/N1 USBF controller
soc: renesas: r9a06g032-sysctrl: Handle h2mode setting based on USBF
presence
usb: gadget: udc: add Renesas RZ/N1 USBF controller support
ARM: dts: r9a06g032: Add the USBF controller node
MAINTAINERS: add the Renesas RZ/N1 USBF controller entry

.../bindings/usb/renesas,rzn1-usbf.yaml | 68 +
MAINTAINERS | 8 +
arch/arm/boot/dts/r9a06g032.dtsi | 12 +
drivers/clk/renesas/r9a06g032-clocks.c | 28 +
drivers/usb/gadget/udc/Kconfig | 11 +
drivers/usb/gadget/udc/Makefile | 1 +
drivers/usb/gadget/udc/renesas_usbf.c | 3420 +++++++++++++++++
7 files changed, 3548 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml
create mode 100644 drivers/usb/gadget/udc/renesas_usbf.c

--
2.38.1


2022-12-13 14:03:09

by Herve Codina

[permalink] [raw]
Subject: [PATCH v4 2/5] soc: renesas: r9a06g032-sysctrl: Handle h2mode setting based on USBF presence

The CFG_USB[H2MODE] allows to switch the USB configuration. The
configuration supported are:
- One host and one device
or
- Two hosts

Set CFG_USB[H2MODE] based on the USBF controller (USB device)
availability.

Signed-off-by: Herve Codina <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---
drivers/clk/renesas/r9a06g032-clocks.c | 28 ++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c
index 1488c9d6e639..8a09ba79b97f 100644
--- a/drivers/clk/renesas/r9a06g032-clocks.c
+++ b/drivers/clk/renesas/r9a06g032-clocks.c
@@ -25,6 +25,8 @@
#include <linux/spinlock.h>
#include <dt-bindings/clock/r9a06g032-sysctrl.h>

+#define R9A06G032_SYSCTRL_USB 0x00
+#define R9A06G032_SYSCTRL_USB_H2MODE (1<<1)
#define R9A06G032_SYSCTRL_DMAMUX 0xA0

struct r9a06g032_gate {
@@ -919,6 +921,29 @@ static void r9a06g032_clocks_del_clk_provider(void *data)
of_clk_del_provider(data);
}

+static void __init r9a06g032_init_h2mode(struct r9a06g032_priv *clocks)
+{
+ struct device_node *usbf_np = NULL;
+ u32 usb;
+
+ while ((usbf_np = of_find_compatible_node(usbf_np, NULL,
+ "renesas,rzn1-usbf"))) {
+ if (of_device_is_available(usbf_np))
+ break;
+ }
+
+ usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB);
+ if (usbf_np) {
+ /* 1 host and 1 device mode */
+ usb &= ~R9A06G032_SYSCTRL_USB_H2MODE;
+ of_node_put(usbf_np);
+ } else {
+ /* 2 hosts mode */
+ usb |= R9A06G032_SYSCTRL_USB_H2MODE;
+ }
+ writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB);
+}
+
static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -948,6 +973,9 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
clocks->reg = of_iomap(np, 0);
if (WARN_ON(!clocks->reg))
return -ENOMEM;
+
+ r9a06g032_init_h2mode(clocks);
+
for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) {
const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i];
const char *parent_name = d->source ?
--
2.38.1

2022-12-13 14:06:14

by Herve Codina

[permalink] [raw]
Subject: [PATCH v4 5/5] MAINTAINERS: add the Renesas RZ/N1 USBF controller entry

After contributing the driver, add myself as the maintainer
for Renesas RZ/N1 USBF controller.

Signed-off-by: Herve Codina <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 886d3f69ee64..1df1f353b884 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17632,6 +17632,14 @@ S: Maintained
F: Documentation/devicetree/bindings/rtc/renesas,rzn1-rtc.yaml
F: drivers/rtc/rtc-rzn1.c

+RENESAS RZ/N1 USBF CONTROLLER DRIVER
+M: Herve Codina <[email protected]>
+L: [email protected]
+L: [email protected]
+S: Maintained
+F: Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml
+F: drivers/usb/gadget/udc/renesas_usbf.c
+
RENESAS R-CAR GEN3 & RZ/N1 NAND CONTROLLER DRIVER
M: Miquel Raynal <[email protected]>
L: [email protected]
--
2.38.1

2022-12-13 14:06:53

by Herve Codina

[permalink] [raw]
Subject: [PATCH v4 4/5] ARM: dts: r9a06g032: Add the USBF controller node

Add the USBF controller available in the r9a06g032 SoC.

Signed-off-by: Herve Codina <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---
arch/arm/boot/dts/r9a06g032.dtsi | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/r9a06g032.dtsi b/arch/arm/boot/dts/r9a06g032.dtsi
index 563024c9a4ae..a4bb069457a3 100644
--- a/arch/arm/boot/dts/r9a06g032.dtsi
+++ b/arch/arm/boot/dts/r9a06g032.dtsi
@@ -117,6 +117,18 @@ dmamux: dma-router@a0 {
};
};

+ udc: usb@4001e000 {
+ compatible = "renesas,r9a06g032-usbf", "renesas,rzn1-usbf";
+ reg = <0x4001e000 0x2000>;
+ interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&sysctrl R9A06G032_HCLK_USBF>,
+ <&sysctrl R9A06G032_HCLK_USBPM>;
+ clock-names = "hclkf", "hclkpm";
+ power-domains = <&sysctrl>;
+ status = "disabled";
+ };
+
pci_usb: pci@40030000 {
compatible = "renesas,pci-r9a06g032", "renesas,pci-rzn1";
device_type = "pci";
--
2.38.1

2022-12-13 14:24:05

by Herve Codina

[permalink] [raw]
Subject: [PATCH v4 1/5] dt-bindings: usb: add the Renesas RZ/N1 USBF controller

The Renesas RZ/N1 USBF controller is an USB2.0 device controller
(UDC) available in the Renesas r9a06g032 SoC (RZ/N1 family).

Signed-off-by: Herve Codina <[email protected]>
---
.../bindings/usb/renesas,rzn1-usbf.yaml | 68 +++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml

diff --git a/Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml b/Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml
new file mode 100644
index 000000000000..b6e84a2a6925
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/renesas,rzn1-usbf.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas RZ/N1 SoCs USBF (USB Function) controller
+
+description: |
+ The Renesas USBF controller is an USB2.0 device
+ controller (UDC).
+
+maintainers:
+ - Herve Codina <[email protected]>
+
+properties:
+ compatible:
+ items:
+ - enum:
+ - renesas,r9a06g032-usbf
+ - const: renesas,rzn1-usbf
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: Internal bus clock (AHB) for Function
+ - description: Internal bus clock (AHB) for Power Management
+
+ clock-names:
+ items:
+ - const: hclkf
+ - const: hclkpm
+
+ power-domains:
+ maxItems: 1
+
+ interrupts:
+ items:
+ - description: The USBF EPC interrupt
+ - description: The USBF AHB-EPC interrupt
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - power-domains
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/clock/r9a06g032-sysctrl.h>
+
+ usb@4001e000 {
+ compatible = "renesas,r9a06g032-usbf", "renesas,rzn1-usbf";
+ reg = <0x4001e000 0x2000>;
+ interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&sysctrl R9A06G032_HCLK_USBF>,
+ <&sysctrl R9A06G032_HCLK_USBPM>;
+ clock-names = "hclkf", "hclkpm";
+ power-domains = <&sysctrl>;
+ };
--
2.38.1

2022-12-14 17:35:14

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] dt-bindings: usb: add the Renesas RZ/N1 USBF controller


On Tue, 13 Dec 2022 14:32:58 +0100, Herve Codina wrote:
> The Renesas RZ/N1 USBF controller is an USB2.0 device controller
> (UDC) available in the Renesas r9a06g032 SoC (RZ/N1 family).
>
> Signed-off-by: Herve Codina <[email protected]>
> ---
> .../bindings/usb/renesas,rzn1-usbf.yaml | 68 +++++++++++++++++++
> 1 file changed, 68 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/usb/renesas,rzn1-usbf.yaml
>

Reviewed-by: Rob Herring <[email protected]>

2022-12-15 10:24:36

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] dt-bindings: usb: add the Renesas RZ/N1 USBF controller

On Tue, Dec 13, 2022 at 2:33 PM Herve Codina <[email protected]> wrote:
> The Renesas RZ/N1 USBF controller is an USB2.0 device controller
> (UDC) available in the Renesas r9a06g032 SoC (RZ/N1 family).
>
> Signed-off-by: Herve Codina <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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