From patchwork Tue Oct 27 01:18:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7492921 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 5752D9F36A for ; Tue, 27 Oct 2015 01:19:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42619208EB for ; Tue, 27 Oct 2015 01:19:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17917208E7 for ; Tue, 27 Oct 2015 01:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752491AbbJ0BS6 (ORCPT ); Mon, 26 Oct 2015 21:18:58 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:7206 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752287AbbJ0BS5 (ORCPT ); Mon, 26 Oct 2015 21:18:57 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 27 Oct 2015 10:18:55 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id A33B13BBE1; Tue, 27 Oct 2015 10:18:55 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 9DD688002E; Tue, 27 Oct 2015 10:18:55 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 98EEB8002D; Tue, 27 Oct 2015 10:18:55 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id LAG01464; Tue, 27 Oct 2015 10:18:55 +0900 X-IronPort-AV: E=Sophos;i="5.20,202,1444662000"; d="scan'";a="198488518" Received: from mail-pu1apc01lp0022.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.22]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 27 Oct 2015 10:18:53 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by TY1PR06MB0926.apcprd06.prod.outlook.com (10.164.99.152) with Microsoft SMTP Server (TLS) id 15.1.306.13; Tue, 27 Oct 2015 01:18:52 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , Yoshihiro Shimoda Subject: [PATCH v4 3/7] usb: host: xhci-plat: add struct xhci_plat_priv Date: Tue, 27 Oct 2015 10:18:26 +0900 Message-ID: <1445908710-5812-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1445908710-5812-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1445908710-5812-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0022.jpnprd01.prod.outlook.com (25.161.225.160) To TY1PR06MB0926.apcprd06.prod.outlook.com (25.164.99.152) X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0926; 2:UvtUjtJwMZ5ELjb5kGblw+Ismdyw6VyLvcWDLvb46gfvmkjjAyMANau1zzhfVag195Oq0L/5qQOq+reZv8uFDzf2zQFrrbl6OSsWiD4JFrBF93BfvZaGgfafWRMM6FvkCFPZLfdUGPKK/VKmSvy3NzMzIfQbHuvkEe4yGqlkjsM=; 3:NWuMQuXogpAMVYJ1Eb1PNlI/3We0UZ72Mu/Qt83v0/S90ffMxb102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xqoQH+1uoPrs93mt8SQdNNNfeFYanc4pwrqjHWZdWf5QW2rbuHgq1U2B+TCWy/8mGiKC8cPbCXiADWy/zFvWhL6x/7OQWfUmOw8f0/cQzJ/piWWEhekX5FC215UnrE0IglTGTGXUA9Mz1ylgRJuzv5uHMUMUKKHl+Ra4yy+7FfQCaC3uLDFqTTY5wmnjXL0BhHu7bRT5LjCnRwc8yYYyuno7Go3sLiQdeVx/OrydmOgYrwQHtXbN07AJtA8DVVl5Q3k+k6ZFVPFwSQMifXB8tmfQO6DLA9It0ogDzl2evwScsM3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(102215026); SRVR:TY1PR06MB0926; BCL:0; PCL:0; RULEID:; SRVR:TY1PR06MB0926; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(199003)(189002)(42382002)(78352002)(5004730100002)(47776003)(2950100001)(5003940100001)(4001430100002)(5007970100001)(40100003)(42186005)(122386002)(36756003)(76506005)(19580405001)(189998001)(106356001)(5001960100002)(33646002)(81156007)(107886002)(575784001)(48376002)(101416001)(105586002)(77096005)(19580395003)(92566002)(87976001)(5001770100001)(97736004)(50466002)(76176999)(50986999)(229853001)(50226001)(66066001)(5008740100001)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR06MB0926; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; TY1PR06MB0926; 23:fSI0W4UY/gS2Mo0go3ExvnGxhF9ig/Pvf/9Elv8TU?= =?us-ascii?Q?lUx5QXbcM5HumxqpVADlcgG1+kDaK/kqhwarIi4MESJll58Mj5TE76xLAb6n?= =?us-ascii?Q?DB33dRe5gmiI4+6c+BmISep91tA5N3LWlZXv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VkjgDRWW8Y1Vi9IIVwkVqnUXShrLd00yWWSmJc0/+aXbnp7SSuhBk?= =?us-ascii?Q?3hI3bhZ+6FkLdpDKIXNtf3+Xwhldn5GAIVBYtNymJ/T7VRCc3QzN75B4/bhw?= =?us-ascii?Q?eFdcIHEOHxRVafGPJ1cMhJ/d6w46p12?= X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0926; 5:oU6eSrnJPh0eSpSSmTK2vTyvDhKtd1Bq6eM0lvrAwyWdXWZMU9GUIrH/dU5HUGrpDfrmF8g8+4gN4jFQsTFAyIQ7oc2cElGt377Cq/QlmJOlcjHrjT0dxH0wB+Nb0psqu1rn0PzyrvKhIf0uVL+hXg==; 24:09YJM36m+aqfid+z0n3fJ1q2y8f1PlgDKyR+rRaf1s0HOEeMkz5iJhYH3FRQEn8f8JUuUwenpCc9RBXTiieVcs1MXEXq3+LhVNHA/7KiXfQ=; 20:3EA1YYLbAbX9ILiGk+yeW9myoQb8W35zP0JZFEZH64KhkuHAPvZ3VnVSpQ4dk2Ce9OkZGSKfixRfCshAkdD6Ka6//XbvowzBM+lty6orbDfqTm5VjvDRL1/+rBHy+CCsHj1EfyIGtqTgL74eI1C9PgfnSC8Djgw+3wSNst/u5Ds= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2015 01:18:52.2897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR06MB0926 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.9 required=5.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, BAYES_00, RCVD_IN_DNSWL_HI, 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 | 73 +++++++++++++++++++++++++++++--------------- drivers/usb/host/xhci-plat.h | 37 ++++++++++++++++++++++ 2 files changed, 85 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 4699c1e..083e77b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -22,6 +22,7 @@ #include #include "xhci.h" +#include "xhci-plat.h" #include "xhci-mvebu.h" #include "xhci-rcar.h" @@ -31,6 +32,7 @@ static int xhci_plat_setup(struct usb_hcd *hcd); static int xhci_plat_start(struct usb_hcd *hcd); static const struct xhci_driver_overrides xhci_plat_overrides __initconst = { + .extra_priv_size = sizeof(struct xhci_plat_priv), .reset = xhci_plat_setup, .start = xhci_plat_start, }; @@ -48,11 +50,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 +63,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; @@ -133,10 +163,17 @@ 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); + 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 */ + *priv = *priv_match; + } + + if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) { ret = xhci_mvebu_mbus_init_quirk(pdev); if (ret) goto disable_clk; @@ -144,7 +181,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, @@ -255,19 +291,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 const struct acpi_device_id usb_xhci_acpi_match[] = { /* XHCI-compliant USB Controller */ { "PNP0D10", }, 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 */