]> www.infradead.org Git - users/hch/misc.git/commitdiff
usb: host: xhci-rcar: Add Renesas RZ/G3E USB3 Host driver support
authorBiju Das <biju.das.jz@bp.renesas.com>
Tue, 16 Sep 2025 15:02:42 +0000 (16:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Sep 2025 10:43:18 +0000 (12:43 +0200)
The USB3.2 Gen2 Host controller (a.k.a USB3HOST), IP found on the RZ/G3E
SoC is similar to R-Car XHCI, but it doesn't require any firmware.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250916150255.4231-7-biju.das.jz@bp.renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/Kconfig
drivers/usb/host/xhci-rcar.c
drivers/usb/host/xhci-rzg3e-regs.h [new file with mode: 0644]

index 109100cc77a32522d5cb7ddbe04d85b102987aa0..c4f17ce5c77b1567d63460f8d41a75baffc9dc4d 100644 (file)
@@ -93,7 +93,7 @@ config USB_XHCI_RCAR
        default ARCH_RENESAS
        help
          Say 'Y' to enable the support for the xHCI host controller
-         found in Renesas R-Car ARM SoCs.
+         found in Renesas R-Car and RZ/G3E alike ARM SoCs.
 
 config USB_XHCI_RZV2M
        bool "xHCI support for Renesas RZ/V2M SoC"
index 6d4662def87fc6c54d332000e682253209b84b63..8a993ee21c879bfbfe4daf938f1c04488132e6fa 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/of.h>
 #include <linux/usb/phy.h>
+#include <linux/reset.h>
 
 #include "xhci.h"
 #include "xhci-plat.h"
 #include "xhci-rcar-regs.h"
+#include "xhci-rzg3e-regs.h"
 #include "xhci-rzv2m.h"
 
 #define XHCI_RCAR_FIRMWARE_NAME_V1     "r8a779x_usb3_v1.dlmem"
@@ -67,6 +69,48 @@ static void xhci_rcar_start(struct usb_hcd *hcd)
        }
 }
 
+static void xhci_rzg3e_start(struct usb_hcd *hcd)
+{
+       u32 int_en;
+
+       if (hcd->regs) {
+               /* Update the controller initial setting */
+               writel(0x03130200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(0));
+               writel(0x00160200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(1));
+               writel(0x03150000, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(2));
+               writel(0x03130200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(3));
+               writel(0x00180000, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(4));
+
+               /* Interrupt Enable */
+               int_en = readl(hcd->regs + RZG3E_USB3_HOST_INTEN);
+               int_en |= RZG3E_USB3_HOST_INTEN_ENA;
+               writel(int_en, hcd->regs + RZG3E_USB3_HOST_INTEN);
+       }
+}
+
+static int xhci_rzg3e_resume(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+       return reset_control_deassert(xhci->reset);
+}
+
+static int xhci_rzg3e_post_resume(struct usb_hcd *hcd)
+{
+       xhci_rzg3e_start(hcd);
+
+       return 0;
+}
+
+static int xhci_rzg3e_suspend(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+       reset_control_assert(xhci->reset);
+
+       return 0;
+}
+
 static int xhci_rcar_download_firmware(struct usb_hcd *hcd)
 {
        struct device *dev = hcd->self.controller;
@@ -190,6 +234,14 @@ static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = {
        .plat_start = xhci_rzv2m_start,
 };
 
+static const struct xhci_plat_priv xhci_plat_renesas_rzg3e = {
+       .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_RESET_ON_RESUME | XHCI_SUSPEND_RESUME_CLKS,
+       .plat_start = xhci_rzg3e_start,
+       .suspend_quirk = xhci_rzg3e_suspend,
+       .resume_quirk = xhci_rzg3e_resume,
+       .post_resume_quirk = xhci_rzg3e_post_resume,
+};
+
 static const struct of_device_id usb_xhci_of_match[] = {
        {
                .compatible = "renesas,xhci-r8a7790",
@@ -206,6 +258,9 @@ static const struct of_device_id usb_xhci_of_match[] = {
        }, {
                .compatible = "renesas,xhci-r8a7796",
                .data = &xhci_plat_renesas_rcar_gen3,
+       }, {
+               .compatible = "renesas,r9a09g047-xhci",
+               .data = &xhci_plat_renesas_rzg3e,
        }, {
                .compatible = "renesas,rcar-gen2-xhci",
                .data = &xhci_plat_renesas_rcar_gen2,
diff --git a/drivers/usb/host/xhci-rzg3e-regs.h b/drivers/usb/host/xhci-rzg3e-regs.h
new file mode 100644 (file)
index 0000000..7a244a4
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __XHCI_RZG3E_H
+#define __XHCI_RZG3E_H
+
+#define RZG3E_USB3_HOST_INTEN          0x1044  /* Interrupt Enable */
+#define RZG3E_USB3_HOST_U3P0PIPESC(x)  (0x10c0 + (x) * 4) /* PIPE Status and Control Register */
+
+#define RZG3E_USB3_HOST_INTEN_XHC      BIT(0)
+#define RZG3E_USB3_HOST_INTEN_HSE      BIT(2)
+#define RZG3E_USB3_HOST_INTEN_ENA      (RZG3E_USB3_HOST_INTEN_XHC | RZG3E_USB3_HOST_INTEN_HSE)
+
+#endif /* __XHCI_RZG3E_H */