From patchwork Wed Oct 7 11:38:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7344541 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9D6B29F302 for ; Wed, 7 Oct 2015 11:39:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AFE1206DE for ; Wed, 7 Oct 2015 11:39:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96B3B205EF for ; Wed, 7 Oct 2015 11:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753245AbbJGLj0 (ORCPT ); Wed, 7 Oct 2015 07:39:26 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:64075 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752469AbbJGLjY (ORCPT ); Wed, 7 Oct 2015 07:39:24 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 07 Oct 2015 20:39:22 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 9620E45A9B; Wed, 7 Oct 2015 20:39:22 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 835178002E; Wed, 7 Oct 2015 20:39:22 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 7C97E8002D; Wed, 7 Oct 2015 20:39:22 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id WAE16206; Wed, 7 Oct 2015 20:39:22 +0900 X-IronPort-AV: E=Sophos;i="5.17,648,1437404400"; d="scan'208";a="195945254" Received: from mail-hk2apc01lp0212.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.212]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Oct 2015 20:39:21 +0900 Received: from SG2PR06MB0917.apcprd06.prod.outlook.com (10.162.200.158) by SG2PR06MB1197.apcprd06.prod.outlook.com (10.169.58.155) with Microsoft SMTP Server (TLS) id 15.1.286.20; Wed, 7 Oct 2015 11:39:20 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by SG2PR06MB0917.apcprd06.prod.outlook.com (10.162.200.158) with Microsoft SMTP Server (TLS) id 15.1.293.16; Wed, 7 Oct 2015 11:39:19 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , Yoshihiro Shimoda Subject: [PATCH v2 2/6] usb: host: xhci-plat: add struct xhci_plat_priv Date: Wed, 7 Oct 2015 20:38:54 +0900 Message-ID: <1444217938-4668-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1444217938-4668-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1444217938-4668-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0009.jpnprd01.prod.outlook.com (25.161.131.147) To SG2PR06MB0917.apcprd06.prod.outlook.com (25.162.200.158) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0917; 2:5iR3q6GB8OxjJB4aVh1UzKr21/7WRYDesZhzDxUAYh4jtx8Ripe7ARLX5v8ji4MHx3wx0KZWlt24BPFhTKZgAo4E71jy0fM+oS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cRfVhKymFMgsut3II6ER4knFh2qWVMTzaQu2PuCzVUY; 4:6IFiIqkGjTT+1KH+TGCw0d3uMEhbrw29Jy3YQcLZuj9O68pq/8/+PeqFCcqPSnxjfx95JjE7LRGVvmi3qEiVGTe3eaa6kntnnzynOWJg4dMzP1FQPgdRM3eeGzF5qmpE7JiYWlDVBGlNI/tjd1FBfNZebLHJeUdB+PRo8fXTDxlsIfR+0T1TVwJoVgZM4eZ3supooksz03kRx1i6yPXmsvNKZCZpNS7Yi8nc4nW5qfo8LFKqWlEfURV5YcV7ICo7wX8fLDUZU0EExDCvBeWkv5sHvqyR0izsLmhMHhmyd5tnjGkM85KRYrIL9jqE6JmaTCqTd4ugQgOaEq4kom/qcSM5hZRy11tghBx6EVeGnuU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001); SRVR:SG2PR06MB0917; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0917; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(199003)(189002)(87976001)(50466002)(101416001)(47776003)(64706001)(5001960100002)(50986999)(33646002)(107886002)(36756003)(77096005)(66066001)(42382002)(76176999)(2950100001)(189998001)(92566002)(50226001)(5004730100002)(5001920100001)(97736004)(5007970100001)(81156007)(5001770100001)(5008740100001)(229853001)(48376002)(42186005)(122386002)(40100003)(5003940100001)(76506005)(78352002)(105586002)(46102003)(19580405001)(19580395003)(106356001)(2004002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0917; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0917; 23:xW/4ETeNXrEgQGjXmm42iOoO43knc2WumtxjQT/6R?= =?us-ascii?Q?wIvu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V3OvS3IYDw?= =?us-ascii?Q?HOhvzcs8noBc701JNAl2evqf6Txema6RGPSCSK3ltsqyxWgYLiq1OYYJoYA6?= =?us-ascii?Q?1tOBCR0ZHICCv7GzbCCTgccS/mNbRt57AlFLeDGMNnn/3Vgsov2AL9o+Ma8x?= =?us-ascii?Q?1B0qHR3VfFDdx7PcDhAeczPeCazqE03jU1PE3lzto+E0KzYPlml9XFgE1iNJ?= =?us-ascii?Q?8wlgrmgAWLtYBIXvE8gIY+ds1KYhQKN9LzmLr5SiyREFxcf/TidUkQo1dW/q?= =?us-ascii?Q?vq/2gDspCfLapjOGTKfI5yylTfIHE1gYjFI?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0917; 5:oZmbe+4slxRmmiSkBz009gcL4iZR321BJKfhVx/Bu9PB/77tlmPq3IsrwIjyGbA3buF38TOJ2VnVDReFS9invBVuD2cogTQwKV24g0g/UAeLXeGcHNO9ZjJ98SMzw6PwJtIudRXibSkwY60zWEwGWw==; 24:9khUzavit0ryo2TZdQkRO7j0A24Dn8+F73vH8em+gn5BFdVNXR22+860dAaRhhuCPRaLcsiuGQQgo/qH/X2BKW3tQvXa5B0YfzKbKMG0qys=; 20:+JmdDGJY1+gSWcO43DMI7uBGR3TOMNry3LIyzT35o821ngS1Up1L50OAuIaoPPw4eq+JC7jVY3A3rt2zTnYw/a7NMsefeNPGQ36notXHOfoys6xG9+kp0iTc2qqsTKp6svQG5AvsqszLh2oXrvnhinKJ+zdAHYJP72lsqs1tiC8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2015 11:39:19.6812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0917 X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1197; 2:01GYd9t2AjcGD8zwRVnd8wZB9WobPG77aOH0+TQU0wY54tRfjnXJ8Wtuo/KHClmtCOaKFMxHiUwcR3PReBmHWkRCV81Bc+RgupA9YxL1JgRFyyPD8bQpQ4oeKnBlP7YEu682SVKssNV9ZA1vqEj1lvnnTYGaf/Eqk5IFNUkXFgg=; 23:VMEc9lpMKk6HwzvF2tjNzVUSmgECWnKSCbdQA4i1u/nzcaDfEOlimHLvAsnsMwP/QpypkrZg9ouL7oHK+/S1lFo0P8WmmGqmFUiGD8IxqrU+tBgxLsI1TXWI1NPWxJB/JNFt7a4w88o88UaBDt5MWiGmnGs4jMW4YcmS9bpE85mOkHKa/f5LyHidZoKeVJdR X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds struct xhci_plat_priv to simplify the code to match platform specific variables. For now, this patch adds a member "type" in the structure. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/host/xhci-plat.c | 66 +++++++++++++++++++++++++++----------------- drivers/usb/host/xhci-plat.h | 37 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 drivers/usb/host/xhci-plat.h diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 890ad9d..4a974b7 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -21,6 +21,7 @@ #include #include "xhci.h" +#include "xhci-plat.h" #include "xhci-mvebu.h" #include "xhci-rcar.h" @@ -48,11 +49,9 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) /* called during probe() after chip reset completes */ static int xhci_plat_setup(struct usb_hcd *hcd) { - struct device_node *of_node = hcd->self.controller->of_node; int ret; - if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") || - of_device_is_compatible(of_node, "renesas,xhci-r8a7791")) { + if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2)) { ret = xhci_rcar_init_quirk(hcd); if (ret) return ret; @@ -63,19 +62,49 @@ static int xhci_plat_setup(struct usb_hcd *hcd) static int xhci_plat_start(struct usb_hcd *hcd) { - struct device_node *of_node = hcd->self.controller->of_node; - - if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") || - of_device_is_compatible(of_node, "renesas,xhci-r8a7791")) + if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2)) xhci_rcar_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, +}; + +static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = { + .type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, +}; + +static const struct of_device_id usb_xhci_of_match[] = { + { + .compatible = "generic-xhci", + }, { + .compatible = "xhci-platform", + }, { + .compatible = "marvell,armada-375-xhci", + .data = &xhci_plat_marvell_armada, + }, { + .compatible = "marvell,armada-380-xhci", + .data = &xhci_plat_marvell_armada, + }, { + .compatible = "renesas,xhci-r8a7790", + .data = &xhci_plat_renesas_rcar_gen2, + }, { + .compatible = "renesas,xhci-r8a7791", + .data = &xhci_plat_renesas_rcar_gen2, + }, { + }, +}; +MODULE_DEVICE_TABLE(of, usb_xhci_of_match); +#endif + 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); + const struct of_device_id *match; const struct hc_driver *driver; struct xhci_hcd *xhci; struct resource *res; @@ -127,10 +156,11 @@ static int xhci_plat_probe(struct platform_device *pdev) goto put_hcd; } - if (of_device_is_compatible(pdev->dev.of_node, - "marvell,armada-375-xhci") || - of_device_is_compatible(pdev->dev.of_node, - "marvell,armada-380-xhci")) { + xhci = hcd_to_xhci(hcd); + match = of_match_node(usb_xhci_of_match, node); + xhci->priv = match ? match->data : NULL; + + if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) { ret = xhci_mvebu_mbus_init_quirk(pdev); if (ret) goto disable_clk; @@ -138,7 +168,6 @@ static int xhci_plat_probe(struct platform_device *pdev) device_wakeup_enable(hcd->self.controller); - xhci = hcd_to_xhci(hcd); xhci->clk = clk; xhci->main_hcd = hcd; xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, @@ -249,19 +278,6 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { #define DEV_PM_OPS NULL #endif /* CONFIG_PM */ -#ifdef CONFIG_OF -static const struct of_device_id usb_xhci_of_match[] = { - { .compatible = "generic-xhci" }, - { .compatible = "xhci-platform" }, - { .compatible = "marvell,armada-375-xhci"}, - { .compatible = "marvell,armada-380-xhci"}, - { .compatible = "renesas,xhci-r8a7790"}, - { .compatible = "renesas,xhci-r8a7791"}, - { }, -}; -MODULE_DEVICE_TABLE(of, usb_xhci_of_match); -#endif - static struct platform_driver usb_xhci_driver = { .probe = xhci_plat_probe, .remove = xhci_plat_remove, diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h new file mode 100644 index 0000000..4479869 --- /dev/null +++ b/drivers/usb/host/xhci-plat.h @@ -0,0 +1,37 @@ +/* + * xhci-plat.h - xHCI host controller driver platform Bus Glue. + * + * Copyright (C) 2015 Renesas Electronics Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#ifndef _XHCI_PLAT_H +#define _XHCI_PLAT_H + +#include "xhci.h" /* for hcd_to_xhci() */ + +enum xhci_plat_type { + XHCI_PLAT_TYPE_MARVELL_ARMADA, + XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, +}; + +struct xhci_plat_priv { + enum xhci_plat_type type; +}; + +#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 */