Re: [PATCH v6 2/2] usb: dwc3: dwc3-generic-plat: Add Renesas R-Car Gen5 DWC3 xHCI USB controller glue

From: Krishna Kurapati

Date: Sat Aug 29 2026 - 12:19:45 EST




On 8/29/2026 12:11 AM, Marek Vasut wrote:
From: Thanh Quan <thanh.quan.xn@xxxxxxxxxxx>

The Renesas R-Car Gen5 SoC contains multiple instances of DWC3 USB
controller with glue logic wrapper around them. Extend the generic
DWC3 platform driver with Renesas R-Car Gen5 glue logic specifics.

Signed-off-by: Thanh Quan <thanh.quan.xn@xxxxxxxxxxx>
Co-developed-by: Marek Vasut <marek.vasut+renesas@xxxxxxxxxxx>
Signed-off-by: Marek Vasut <marek.vasut+renesas@xxxxxxxxxxx>
---

[...]

diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index ca69ac0eb07ce..e8586c40d5006 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -71,6 +71,55 @@ static int dwc3_eic7700_init(struct dwc3_generic *dwc3g)
return 0;
}
+static int dwc3_renesas_rcar_gen5_init(struct dwc3_generic *dwc3g)
+{
+ struct device *dev = dwc3g->dev;
+ struct platform_device *pdev = to_platform_device(dev);
+ enum usb_device_speed speed = usb_get_maximum_speed(dev);
+ bool usb2only = false;
+ void __iomem *glue;
+
+ /* Wireless USB is not supported */
+ if (speed == USB_SPEED_WIRELESS)
+ return dev_err_probe(dev, -EINVAL, "Wireless USB not supported\n");
+
+ /* No USB 3 PHY in DT means this is surely USB 2 controller */
+ if (device_property_match_string(dev, "phy-names", "usb3-phy") < 0)
+ usb2only = true;
+

Why not just set the maximum-speed property to "high-speed" instead of checking for "usb3-phy". That would be more clean.

+ if (speed >= USB_SPEED_LOW && speed <= USB_SPEED_HIGH)
+ usb2only = true;

And this check can be removed as well if we use "maximum-speed" property in DT.

+
+ glue = devm_platform_ioremap_resource_byname(pdev, "glue");
+ if (IS_ERR(glue))
+ return PTR_ERR(glue);
+
+ /*
+ * The datasheet describes initialization procedure without full
+ * information about the registers. Therefore, the source code is
+ * based on the bare metal code shared by the board team.
+ */
+ writew(0x211, glue + 0x26);
+
+ /* USB2 does need additional register programming. */
+ if (!usb2only)
+ return 0;
+
+ writew(0x11, glue + 0x81c);
+ writew(0x0, glue + 0x81a);
+ writew(0x1, glue + 0x802);
+
+ usleep_range(10000, 20000);
+
+ writew(0x0, glue + 0x802);
+ writew(0x1, glue + 0x2a);
+ writew(0x1, glue + 0x81a);
+
+ usleep_range(10000, 20000);
+

Use #defines for register offsets and register values like in dwc3_eic7700_init.

Regards,
Krishna,