Skip to content

Commit 5db5025

Browse files
bijudasgregkh
authored andcommitted
usb: host: xhci-rcar: Add Renesas RZ/G3E USB3 Host driver support
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>
1 parent 2ef16e4 commit 5db5025

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

drivers/usb/host/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ config USB_XHCI_RCAR
9393
default ARCH_RENESAS
9494
help
9595
Say 'Y' to enable the support for the xHCI host controller
96-
found in Renesas R-Car ARM SoCs.
96+
found in Renesas R-Car and RZ/G3E alike ARM SoCs.
9797

9898
config USB_XHCI_RZV2M
9999
bool "xHCI support for Renesas RZ/V2M SoC"

drivers/usb/host/xhci-rcar.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include <linux/platform_device.h>
1212
#include <linux/of.h>
1313
#include <linux/usb/phy.h>
14+
#include <linux/reset.h>
1415

1516
#include "xhci.h"
1617
#include "xhci-plat.h"
1718
#include "xhci-rcar-regs.h"
19+
#include "xhci-rzg3e-regs.h"
1820
#include "xhci-rzv2m.h"
1921

2022
#define XHCI_RCAR_FIRMWARE_NAME_V1 "r8a779x_usb3_v1.dlmem"
@@ -67,6 +69,48 @@ static void xhci_rcar_start(struct usb_hcd *hcd)
6769
}
6870
}
6971

72+
static void xhci_rzg3e_start(struct usb_hcd *hcd)
73+
{
74+
u32 int_en;
75+
76+
if (hcd->regs) {
77+
/* Update the controller initial setting */
78+
writel(0x03130200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(0));
79+
writel(0x00160200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(1));
80+
writel(0x03150000, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(2));
81+
writel(0x03130200, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(3));
82+
writel(0x00180000, hcd->regs + RZG3E_USB3_HOST_U3P0PIPESC(4));
83+
84+
/* Interrupt Enable */
85+
int_en = readl(hcd->regs + RZG3E_USB3_HOST_INTEN);
86+
int_en |= RZG3E_USB3_HOST_INTEN_ENA;
87+
writel(int_en, hcd->regs + RZG3E_USB3_HOST_INTEN);
88+
}
89+
}
90+
91+
static int xhci_rzg3e_resume(struct usb_hcd *hcd)
92+
{
93+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
94+
95+
return reset_control_deassert(xhci->reset);
96+
}
97+
98+
static int xhci_rzg3e_post_resume(struct usb_hcd *hcd)
99+
{
100+
xhci_rzg3e_start(hcd);
101+
102+
return 0;
103+
}
104+
105+
static int xhci_rzg3e_suspend(struct usb_hcd *hcd)
106+
{
107+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
108+
109+
reset_control_assert(xhci->reset);
110+
111+
return 0;
112+
}
113+
70114
static int xhci_rcar_download_firmware(struct usb_hcd *hcd)
71115
{
72116
struct device *dev = hcd->self.controller;
@@ -190,6 +234,14 @@ static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = {
190234
.plat_start = xhci_rzv2m_start,
191235
};
192236

237+
static const struct xhci_plat_priv xhci_plat_renesas_rzg3e = {
238+
.quirks = XHCI_NO_64BIT_SUPPORT | XHCI_RESET_ON_RESUME | XHCI_SUSPEND_RESUME_CLKS,
239+
.plat_start = xhci_rzg3e_start,
240+
.suspend_quirk = xhci_rzg3e_suspend,
241+
.resume_quirk = xhci_rzg3e_resume,
242+
.post_resume_quirk = xhci_rzg3e_post_resume,
243+
};
244+
193245
static const struct of_device_id usb_xhci_of_match[] = {
194246
{
195247
.compatible = "renesas,xhci-r8a7790",
@@ -206,6 +258,9 @@ static const struct of_device_id usb_xhci_of_match[] = {
206258
}, {
207259
.compatible = "renesas,xhci-r8a7796",
208260
.data = &xhci_plat_renesas_rcar_gen3,
261+
}, {
262+
.compatible = "renesas,r9a09g047-xhci",
263+
.data = &xhci_plat_renesas_rzg3e,
209264
}, {
210265
.compatible = "renesas,rcar-gen2-xhci",
211266
.data = &xhci_plat_renesas_rcar_gen2,

drivers/usb/host/xhci-rzg3e-regs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __XHCI_RZG3E_H
3+
#define __XHCI_RZG3E_H
4+
5+
#define RZG3E_USB3_HOST_INTEN 0x1044 /* Interrupt Enable */
6+
#define RZG3E_USB3_HOST_U3P0PIPESC(x) (0x10c0 + (x) * 4) /* PIPE Status and Control Register */
7+
8+
#define RZG3E_USB3_HOST_INTEN_XHC BIT(0)
9+
#define RZG3E_USB3_HOST_INTEN_HSE BIT(2)
10+
#define RZG3E_USB3_HOST_INTEN_ENA (RZG3E_USB3_HOST_INTEN_XHC | RZG3E_USB3_HOST_INTEN_HSE)
11+
12+
#endif /* __XHCI_RZG3E_H */

0 commit comments

Comments
 (0)