* [PATCH 1/2] usb: host: xhci-rcar: Remove SET_XHCI_PLAT_PRIV_FOR_RCAR() macro
2026-06-03 15:17 [PATCH 0/2] usb: host: xhci-rcar: Avoid repeated matching Geert Uytterhoeven
@ 2026-06-03 15:17 ` Geert Uytterhoeven
2026-06-03 15:17 ` [PATCH 2/2] usb: host: xhci-rcar: Split R-Car Gen2 and Gen3 .plat_start() handling Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-06-03 15:17 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Yoshihiro Shimoda,
Wolfram Sang
Cc: linux-usb, linux-renesas-soc, Geert Uytterhoeven
The SET_XHCI_PLAT_PRIV_FOR_RCAR() macro does not add much value (there
are only two users), and stands in the way of handling differences
between R-Car Gen2 and Gen3. Remove it.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/usb/host/xhci-rcar.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index 8a993ee21c879bfb..d2efc98090ce0053 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -213,19 +213,20 @@ static int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
* long delay for the handshake of STS_HALT is neeed in xhci_suspend()
* by using the XHCI_SLOW_SUSPEND quirk.
*/
-#define SET_XHCI_PLAT_PRIV_FOR_RCAR(firmware) \
- .firmware_name = firmware, \
- .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND, \
- .init_quirk = xhci_rcar_init_quirk, \
- .plat_start = xhci_rcar_start, \
- .resume_quirk = xhci_rcar_resume_quirk,
-
static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
- SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V1)
+ .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
+ .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND,
+ .init_quirk = xhci_rcar_init_quirk,
+ .plat_start = xhci_rcar_start,
+ .resume_quirk = xhci_rcar_resume_quirk,
};
static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
- SET_XHCI_PLAT_PRIV_FOR_RCAR(XHCI_RCAR_FIRMWARE_NAME_V3)
+ .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V3,
+ .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND,
+ .init_quirk = xhci_rcar_init_quirk,
+ .plat_start = xhci_rcar_start,
+ .resume_quirk = xhci_rcar_resume_quirk,
};
static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] usb: host: xhci-rcar: Split R-Car Gen2 and Gen3 .plat_start() handling
2026-06-03 15:17 [PATCH 0/2] usb: host: xhci-rcar: Avoid repeated matching Geert Uytterhoeven
2026-06-03 15:17 ` [PATCH 1/2] usb: host: xhci-rcar: Remove SET_XHCI_PLAT_PRIV_FOR_RCAR() macro Geert Uytterhoeven
@ 2026-06-03 15:17 ` Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2026-06-03 15:17 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Yoshihiro Shimoda,
Wolfram Sang
Cc: linux-usb, linux-renesas-soc, Geert Uytterhoeven
Currently, R-Car Gen2 and Gen3 share the same .plat_start() callback.
However, this single callback performs different operations, after
checking the XHCI's controller compatible value.
Avoid repeated checking of compatible values and reduce kernel size by
splitting this method in two separate functions. Update
xhci_rcar_resume_quirk() to dispatch to the correct method by calling it
through the .plat_start() function pointer, too.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/usb/host/xhci-rcar.c | 53 ++++++++++++++++--------------------
1 file changed, 24 insertions(+), 29 deletions(-)
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index d2efc98090ce0053..d747c0905827661e 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -32,29 +32,6 @@
MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V1);
MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V3);
-static void xhci_rcar_start_gen2(struct usb_hcd *hcd)
-{
- /* LCLK Select */
- writel(RCAR_USB3_LCLK_ENA_VAL, hcd->regs + RCAR_USB3_LCLK);
- /* USB3.0 Configuration */
- writel(RCAR_USB3_CONF1_VAL, hcd->regs + RCAR_USB3_CONF1);
- writel(RCAR_USB3_CONF2_VAL, hcd->regs + RCAR_USB3_CONF2);
- writel(RCAR_USB3_CONF3_VAL, hcd->regs + RCAR_USB3_CONF3);
- /* USB3.0 Polarity */
- writel(RCAR_USB3_RX_POL_VAL, hcd->regs + RCAR_USB3_RX_POL);
- writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL);
-}
-
-static int xhci_rcar_is_gen2(struct device *dev)
-{
- struct device_node *node = dev->of_node;
-
- return of_device_is_compatible(node, "renesas,xhci-r8a7790") ||
- of_device_is_compatible(node, "renesas,xhci-r8a7791") ||
- of_device_is_compatible(node, "renesas,xhci-r8a7793") ||
- of_device_is_compatible(node, "renesas,rcar-gen2-xhci");
-}
-
static void xhci_rcar_start(struct usb_hcd *hcd)
{
u32 temp;
@@ -64,8 +41,23 @@ static void xhci_rcar_start(struct usb_hcd *hcd)
temp = readl(hcd->regs + RCAR_USB3_INT_ENA);
temp |= RCAR_USB3_INT_ENA_VAL;
writel(temp, hcd->regs + RCAR_USB3_INT_ENA);
- if (xhci_rcar_is_gen2(hcd->self.controller))
- xhci_rcar_start_gen2(hcd);
+ }
+}
+
+static void xhci_rcar_gen2_start(struct usb_hcd *hcd)
+{
+ if (hcd->regs != NULL) {
+ xhci_rcar_start(hcd);
+
+ /* LCLK Select */
+ writel(RCAR_USB3_LCLK_ENA_VAL, hcd->regs + RCAR_USB3_LCLK);
+ /* USB3.0 Configuration */
+ writel(RCAR_USB3_CONF1_VAL, hcd->regs + RCAR_USB3_CONF1);
+ writel(RCAR_USB3_CONF2_VAL, hcd->regs + RCAR_USB3_CONF2);
+ writel(RCAR_USB3_CONF3_VAL, hcd->regs + RCAR_USB3_CONF3);
+ /* USB3.0 Polarity */
+ writel(RCAR_USB3_RX_POL_VAL, hcd->regs + RCAR_USB3_RX_POL);
+ writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL);
}
}
@@ -192,13 +184,16 @@ static int xhci_rcar_init_quirk(struct usb_hcd *hcd)
static int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
{
+ struct xhci_plat_priv *priv;
int ret;
ret = xhci_rcar_download_firmware(hcd);
- if (!ret)
- xhci_rcar_start(hcd);
+ if (ret)
+ return ret;
- return ret;
+ priv = hcd_to_xhci_priv(hcd);
+ priv->plat_start(hcd);
+ return 0;
}
/*
@@ -217,7 +212,7 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
.firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1,
.quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND,
.init_quirk = xhci_rcar_init_quirk,
- .plat_start = xhci_rcar_start,
+ .plat_start = xhci_rcar_gen2_start,
.resume_quirk = xhci_rcar_resume_quirk,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread