Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754812AbcC1GzS (ORCPT ); Mon, 28 Mar 2016 02:55:18 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:50777 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753303AbcC1GzL convert rfc822-to-8bit (ORCPT ); Mon, 28 Mar 2016 02:55:11 -0400 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="207606919" From: Yoshihiro Shimoda To: Peter Griffin , Felipe Balbi CC: Gregory CLEMENT , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "mathias.nyman@intel.com" , "gregkh@linuxfoundation.org" , "lee.jones@linaro.org" , "linux-usb@vger.kernel.org" , "maxime.coquelin@st.com" , "patrice.chotard@st.com" , "stable@vger.kernel.org" , "felipe.balbi@linux.intel.com" Subject: RE: [PATCH] usb: host: xhci-plat: Make enum xhci_plat_type start at a non zero value Thread-Topic: [PATCH] usb: host: xhci-plat: Make enum xhci_plat_type start at a non zero value Thread-Index: AQHRhqUk2AuaCYdOEkKU6KPUcWimcp9qYdwAgAACe6SAAApMAIABAtoAgAL7jXA= Date: Mon, 28 Mar 2016 06:55:03 +0000 Message-ID: References: <1458917188-28452-1-git-send-email-peter.griffin@linaro.org> <87mvpm8pfl.fsf@ti.com> <87mvpmlc5e.fsf@free-electrons.com> <87io0a8nbd.fsf@ti.com> <20160326091050.GA7793@griffinp-ThinkPad-X1-Carbon-2nd> In-Reply-To: <20160326091050.GA7793@griffinp-ThinkPad-X1-Carbon-2nd> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: 74067948-47f4-43c8-5f52-08d356d5e3fa x-microsoft-exchange-diagnostics: 1;SG2PR06MB0917;5:c2o+GPRAns4ULjmdC7hUAQZpNe5v0c8HXQTvh3jnwUv5/1L+oKBVMW9P//YAslWi6sAySeJZxqdAF3ipIW9cNF9RGCua3VkO9UdedE5nBm2ATLc7yoGeRTBVMvoOn+cEwUEvA86oGEtNmuU3Uv/CDA==;24:gtghp00DSTwYEO7m+K6+X/B0AKfvBhxu9v38Z2Pu/1Bpqo3UiK1x6soPPdMj91XCrZKFwnKcRPt3N5KRjia604pbhcL44A0QYp2jFyvJSlo=;20:JGdVe03BWYhlUK5hPjB9WGXE8yidWbqn0/S8GIhEH1H3gIWe6ar6Uf88cAGp6DbcjhF9o5uug8yqI5FIrMqRKGxVqCdnvUEtcuDvmUv6AwbTJdIOLiBoXlUkBM48lFoEajPWP8Xlw68Rpkh3MpLTBRO4VnCajevtO46f+oudLCg= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:SG2PR06MB0917;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; x-forefront-prvs: 0895DF8FFD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(5003600100002)(5004730100002)(2906002)(5001770100001)(2900100001)(122556002)(87936001)(189998001)(586003)(345774005)(86362001)(92566002)(77096005)(2950100001)(3846002)(6116002)(81166005)(1220700001)(74316001)(3280700002)(5008740100001)(3660700001)(1096002)(11100500001)(76176999)(106116001)(54356999)(50986999)(33656002)(76576001)(66066001)(93886004);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0917;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2016 06:55:04.0981 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0917 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7079 Lines: 230 Hi, > Sent: Saturday, March 26, 2016 6:11 PM < snip > > > ps: there might be bugs there, but it's a holiday and I really shouldn't > > be spending time on this right now ;-) > > I'm also off on holiday now until Sunday 10th April... yay :-) > > > > Anyway, have fun testing. Let me know if it doesn't work. > > I only have access to STi platforms which were broken by this change. > Not any of the platforms which rely on the functionality which > was introduced (although I can't see any reason why your patch wouldn't work). > > Maybe Yoshihiro (on CC) could test this on the Renesas platforms and confirm? Thank you for sending the email to me on CC. I tested Felipe's patch on Renesas platfroms (R-Car Gen2 and Gen3) and I fixed the patch like the following. However, my fixes patch might need to clean the code up more. Changes from Felipe's patch: - Change function names of xhci_rcar_init_quirk() to xhci_rcar_setup_quirk() - Add setup_quirk() member and use it for rcar's function. - Some minor fixes. --- diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c index 1eefc98..1ea6c18 100644 --- a/drivers/usb/host/xhci-mvebu.c +++ b/drivers/usb/host/xhci-mvebu.c @@ -41,8 +41,9 @@ static void xhci_mvebu_mbus_config(void __iomem *base, } } -int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev) +int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) { + struct platform_device *pdev = to_platform_device(hcd->self.controller); struct resource *res; void __iomem *base; const struct mbus_dram_target_info *dram; diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d39d6bf..d28513a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -47,43 +47,57 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |= XHCI_PLAT; } +static void xhci_priv_plat_start(struct usb_hcd *hcd) +{ + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + + if (priv->plat_start) + priv->plat_start(hcd); +} + +static int xhci_priv_setup_quirk(struct usb_hcd *hcd) +{ + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + + if (!priv->setup_quirk) + return 0; + + return priv->setup_quirk(hcd); +} + /* called during probe() after chip reset completes */ static int xhci_plat_setup(struct usb_hcd *hcd) { int ret; - if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) || - xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) { - ret = xhci_rcar_init_quirk(hcd); - if (ret) - return ret; - } + ret = xhci_priv_setup_quirk(hcd); + if (ret) + return ret; return xhci_gen_setup(hcd, xhci_plat_quirks); } static int xhci_plat_start(struct usb_hcd *hcd) { - if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) || - xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3)) - xhci_rcar_start(hcd); - + xhci_priv_plat_start(hcd); return xhci_run(hcd); } #ifdef CONFIG_OF static const struct xhci_plat_priv xhci_plat_marvell_armada = { - .type = XHCI_PLAT_TYPE_MARVELL_ARMADA, + .init_quirk = xhci_mvebu_mbus_init_quirk, }; static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { - .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V1, + .setup_quirk = xhci_rcar_setup_quirk, + .plat_start = xhci_rcar_start, }; static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { - .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3, .firmware_name = XHCI_RCAR_FIRMWARE_NAME_V2, + .setup_quirk = xhci_rcar_setup_quirk, + .plat_start = xhci_rcar_start, }; static const struct of_device_id usb_xhci_of_match[] = { @@ -119,6 +133,7 @@ static int xhci_plat_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct usb_xhci_pdata *pdata = dev_get_platdata(&pdev->dev); + struct xhci_plat_priv *priv; const struct of_device_id *match; const struct hc_driver *driver; struct xhci_hcd *xhci; @@ -178,18 +193,18 @@ static int xhci_plat_probe(struct platform_device *pdev) } xhci = hcd_to_xhci(hcd); + priv = hcd_to_xhci_priv(hcd); match = of_match_node(usb_xhci_of_match, node); if (match) { const struct xhci_plat_priv *priv_match = match->data; - struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); /* Just copy data for now */ if (priv_match) *priv = *priv_match; } - if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) { - ret = xhci_mvebu_mbus_init_quirk(pdev); + if (priv->init_quirk) { + ret = priv->init_quirk(pdev); if (ret) goto disable_clk; } diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index 5a2e2e3..1d86d6d 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h @@ -13,27 +13,13 @@ #include "xhci.h" /* for hcd_to_xhci() */ -enum xhci_plat_type { - XHCI_PLAT_TYPE_MARVELL_ARMADA, - XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, - XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3, -}; - struct xhci_plat_priv { - enum xhci_plat_type type; const char *firmware_name; + void (*plat_start)(struct usb_hcd *); + int (*init_quirk)(struct platform_device *pdev); + int (*setup_quirk)(struct usb_hcd *); }; #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv) -static inline bool xhci_plat_type_is(struct usb_hcd *hcd, - enum xhci_plat_type type) -{ - struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); - - if (priv && priv->type == type) - return true; - else - return false; -} #endif /* _XHCI_PLAT_H */ diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index 623100e..7b2800c 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -81,11 +81,13 @@ void xhci_rcar_start(struct usb_hcd *hcd) u32 temp; if (hcd->regs != NULL) { + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + /* Interrupt Enable */ temp = readl(hcd->regs + RCAR_USB3_INT_ENA); temp |= RCAR_USB3_INT_ENA_VAL; writel(temp, hcd->regs + RCAR_USB3_INT_ENA); - if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2)) + if (!strcmp(priv->firmware_name, XHCI_RCAR_FIRMWARE_NAME_V1)) xhci_rcar_start_gen2(hcd); } } @@ -154,7 +156,7 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) } /* This function needs to initialize a "phy" of usb before */ -int xhci_rcar_init_quirk(struct usb_hcd *hcd) +int xhci_rcar_setup_quirk(struct usb_hcd *hcd) { /* If hcd->regs is NULL, we don't just call the following function */ if (!hcd->regs) diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h index 2941a25..05cd539 100644 --- a/drivers/usb/host/xhci-rcar.h +++ b/drivers/usb/host/xhci-rcar.h @@ -16,13 +16,13 @@ #if IS_ENABLED(CONFIG_USB_XHCI_RCAR) void xhci_rcar_start(struct usb_hcd *hcd); -int xhci_rcar_init_quirk(struct usb_hcd *hcd); +int xhci_rcar_setup_quirk(struct usb_hcd *hcd); #else static inline void xhci_rcar_start(struct usb_hcd *hcd) { } -static inline int xhci_rcar_init_quirk(struct usb_hcd *hcd) +static inline int xhci_rcar_setup_quirk(struct usb_hcd *hcd) { return 0; }