From: Geert Uytterhoeven Date: Wed, 3 Jun 2026 15:17:10 +0000 (+0200) Subject: usb: host: xhci-rcar: Split R-Car Gen2 and Gen3 .plat_start() handling X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=511e746700ee6e93104d061a87743906128ab709;p=thirdparty%2Flinux.git usb: host: xhci-rcar: Split R-Car Gen2 and Gen3 .plat_start() handling 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 Link: https://patch.msgid.link/d1ee4e1bb9106f8251b061b52948434d560b4675.1780499433.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index d2efc98090ce..d747c0905827 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, };