From patchwork Mon Oct 26 08:12:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7486021 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 15DA29F36A for ; Mon, 26 Oct 2015 08:13:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB37F20651 for ; Mon, 26 Oct 2015 08:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC590206B6 for ; Mon, 26 Oct 2015 08:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752964AbbJZINM (ORCPT ); Mon, 26 Oct 2015 04:13:12 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:16853 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753379AbbJZINI (ORCPT ); Mon, 26 Oct 2015 04:13:08 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 26 Oct 2015 17:13:07 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id D80E448010; Mon, 26 Oct 2015 17:13:07 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id CC0D38002F; Mon, 26 Oct 2015 17:13:07 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id C85E88002D; Mon, 26 Oct 2015 17:13:07 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id TAY29415; Mon, 26 Oct 2015 17:13:07 +0900 X-IronPort-AV: E=Sophos;i="5.20,200,1444662000"; d="scan'";a="198436156" Received: from mail-sg2apc01lp0245.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.245]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 26 Oct 2015 17:13:06 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by SIXPR06MB0921.apcprd06.prod.outlook.com (10.162.173.13) with Microsoft SMTP Server (TLS) id 15.1.306.13; Mon, 26 Oct 2015 08:13:04 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , Yoshihiro Shimoda Subject: [PATCH v3 3/7] usb: host: xhci-plat: add struct xhci_plat_priv Date: Mon, 26 Oct 2015 17:12:31 +0900 Message-ID: <1445847155-5468-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1445847155-5468-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1445847155-5468-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0019.apcprd02.prod.outlook.com (25.163.104.157) To SIXPR06MB0921.apcprd06.prod.outlook.com (25.162.173.13) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0921; 2:bmWTSJ+VvEz9fCrKrbCvkprqYqmZ0qvZ4z+qK1VWp1Q1w0Jyd+CJPKP9TjEiIwM0cC3cTqclQhYgaX6bFk2QcGkqtV+8fg3wqVfpYADdkLnhBb+Kuoa34iNytRd8bWpIRou3jHlJ2xmlis6vudPTY9QaPT6z/qUxPY+EI+BlRNo=; 3:rcNPWq9EcpEnMM8aPbnZePRYiRFHA54KUppgKCDzRyB+gVtN5o//2/RIyZO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zbJQJsEnYkUWlvqWvjSBt2C1R/YPdbPnsRXD2sGGAHMXlw3tEiy+LFs1q7yR1Lu9RO7/ME8Qnn8bShQE4sxBYwZb/JH9XEgyGzzJI64mfJTIAs+DF4B9iY1mghSLNOyWMmjYp/V4TQZz4nHg6SDDZ99ixXMUBlr17vuBgUksOdJFt7MwELGgOlik/aukJ2CACJPxGgGU2pG5cyH8Whrxobw3es4CBnue+C7Kn4bKvI25TqAVXb7XTGvGhJQ8GpjZVV7RKz9Fkx5roSXaJimdOSIaOMBWnus4YLH3wuGq2RWF5bV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(102215026); SRVR:SIXPR06MB0921; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB0921; X-Forefront-PRVS: 0741C77572 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(979002)(6069001)(6009001)(199003)(189002)(66066001)(107886002)(229853001)(106356001)(40100003)(5001770100001)(5001960100002)(5008740100001)(87976001)(81156007)(5001920100001)(5003940100001)(97736004)(575784001)(189998001)(47776003)(92566002)(105586002)(33646002)(76176999)(76506005)(42382002)(122386002)(77096005)(42186005)(50466002)(50986999)(101416001)(48376002)(36756003)(2950100001)(19580395003)(78352002)(5004730100002)(19580405001)(4001430100002)(50226001)(5007970100001)(2004002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB0921; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB0921; 23:OOduVrynujXifpHzI98atSgLfRQ+ARyrY5pGMnhFM?= =?us-ascii?Q?J4309BVmIbhIRzX5dpYWYkmLoYnNYYzFQTLmqg/RSW2pnfHr1OsBS+IyFVNn?= =?us-ascii?Q?I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zjLJTgrlr4uHXUWl5N?= =?us-ascii?Q?3zC6xNH3Rbh++uivBwPYGNoVAl5/Yo0GtbEgOVy7lHZnnl78n+uewOx2JmJr?= =?us-ascii?Q?1x+d7ElqHqfESNecDRUQZoWitkhDk4UnIQYRoC2gTBKyXcqR9y2apIPQhIkj?= =?us-ascii?Q?Ll/vt2QIpdoRt/n1SbGEskOIOx0FAvgmxreUGfxTDtPlqo5pvwkEACe/yRx3?= =?us-ascii?Q?o6nXHGrFQfdrhucTIYMPC07APYhCQa2UvXr0DLeeyMI2gc/Y4euoatS7t9MZ?= =?us-ascii?Q?LSsz7E7LZCclKLbGDZXdWYbAS7tY4Qq1MiwT1v/?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0921; 5:Zys25gJER8mERBK+Kn/wsq3xo/rWkhKWkhZnwCXJcSckeVSJrYudTReYaEbjFNM0B2XJs26D6B7cA/BffIU3KIOcfmoPnM+8t3M9Qqm4XRagOg1+hKqnNYuWTjgXhEGBRal1gVDPHceQPiXWhMZqmg==; 24:DjUVgiwlwLakhGpO/awx/XnItbOKO4933+3vpftDUv1sjiaZ+EzEcXS7mOOHgnlwQjSW0M7ibMslRwQ2knU/ZiNpdZHYEq6dDVSmv1cAaOw=; 20:w7KwZaDDEkDqkmdjdclPGh7ShfsIkcxlRtkTswPO9qsoML7D8ksaxGwFM6ww0qXLp+El1XyA0JgNe04z5tvlqXVnJMCOZ28crFglCi0ZYE+WGhwWsqtgPXTUbvzG8s/YXNN9v+PrEKsvD0KH1cXfmK7eXcz9Apl6fP47wbAiHrA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2015 08:13:04.5667 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0921 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 */