]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: host: xhci-rcar: Split R-Car Gen2 and Gen3 .plat_start() handling
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 3 Jun 2026 15:17:10 +0000 (17:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jun 2026 17:23:37 +0000 (19:23 +0200)
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>
Link: https://patch.msgid.link/d1ee4e1bb9106f8251b061b52948434d560b4675.1780499433.git.geert+renesas@glider.be
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-rcar.c

index d2efc98090ce0053692f9e8711da519083e8e22e..d747c0905827661ecf8bd466a6e87643528876b3 100644 (file)
 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,
 };