From patchwork Tue Mar 26 15:57:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: manjunath.goudar@linaro.org X-Patchwork-Id: 15673 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8F1A423E00 for ; Tue, 26 Mar 2013 15:57:56 +0000 (UTC) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by fiordland.canonical.com (Postfix) with ESMTP id 38898A199F2 for ; Tue, 26 Mar 2013 15:57:56 +0000 (UTC) Received: by mail-vb0-f41.google.com with SMTP id l22so4712090vbn.0 for ; Tue, 26 Mar 2013 08:57:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=53/X07Ewuv7XWP1ChKLM7dgEuDXbNSz8Ms3EC8c+gcc=; b=l33RztqHujdYrTv/ibhJ6uJtPb5Qg0Bg6Ar+GcOa8XL9PHUDl3nieCet8cgk37/OM9 Vp23x+hSf1NMfCX+Fj/F/4j/xMRV1rjXVP79itDL/674GpG488SKKDiT/KsKJW9mZ00B u6leG+OD8dAqgENfyU2Z6mS0mfQxYpzSSjIwuKSniOlvTSgtDJOpwlrSX94iyjJHutAD pdo4ONm34EEdomi+vOrvIzOGA3zK4K+taqTvKHgq+RoFBSeh1I3344HqOeWHg/OCGomU WJBFyHKHyEIPmbwkJDvUn3mPHA4o/gM5vzNbmfG2KqMdrU5JUYVMCLlQP/iatdjDqeOE BAiA== X-Received: by 10.52.233.225 with SMTP id tz1mr17214646vdc.54.1364313475689; Tue, 26 Mar 2013 08:57:55 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp77696ved; Tue, 26 Mar 2013 08:57:55 -0700 (PDT) X-Received: by 10.68.245.202 with SMTP id xq10mr23944291pbc.163.1364313474515; Tue, 26 Mar 2013 08:57:54 -0700 (PDT) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id vf5si10610872pbc.81.2013.03.26.08.57.53 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Mar 2013 08:57:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.192.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) smtp.mail=manjunath.goudar@linaro.org Received: by mail-pd0-f176.google.com with SMTP id r11so557933pdi.35 for ; Tue, 26 Mar 2013 08:57:53 -0700 (PDT) X-Received: by 10.68.242.41 with SMTP id wn9mr23828078pbc.156.1364313473634; Tue, 26 Mar 2013 08:57:53 -0700 (PDT) Received: from localhost.localdomain ([223.229.218.70]) by mx.google.com with ESMTPS id z1sm17959555pbw.19.2013.03.26.08.57.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Mar 2013 08:57:53 -0700 (PDT) From: manjunath.goudar@linaro.org To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org Subject: [V3 4/5] USB: EHCI: make ehci-mv as separate static driver Date: Tue, 26 Mar 2013 21:27:10 +0530 Message-Id: <5151c581.414e440a.3d14.ffffa0f2@mx.google.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1364313431-18170-1-git-send-email-y> References: <1364313431-18170-1-git-send-email-y> X-Gm-Message-State: ALoCoQnHVoxvTlpZGgVKxhV2GVEOXsPXac7JBdJAx5OhCpPUVrgnQ8s6Ae07ChMFrc5Tb/wqkTRl From: Manjunath Goudar Separate the Marvell(including PXA and MMP series) on-chip USB SPH and OTG host controller driver from ehci-hcd host code so that it can be built as a separate driver module. This work is part of enabling multi-platform kernels on ARM; however, note that other changes are still needed before PXA and MMP series can be booted with a multi-platform kernel and an ehci driver that only works on one of them. With the infrastructure added by Alan Stern in patch 3e0232039 "USB: EHCI: prepare to make ehci-hcd a library module", we can avoid this problem by turning a bus glue into a separate module, as we do here for the mv bus glue. In V3: 1.Detail commit message added here,why this patch is required. 2.MODULE_LICENSE is GPL v2. 3.Used .extra_priv_size to eliminate the separate allocation of the ehci_hcd_mv structure. 4.Completely eliminated mv_ehci_reset function below content hcd->has_tt = 1; is moved into the mv_ehci_probe function. 5.Arranged #include's in alphabetical order. In V2: No changes only Cc list changed in this patch. Signed-off-by: Manjunath Goudar Acked-by: Arnd Bergmann Cc: Greg KH Cc: Alan Stern Cc: Eric Miao Cc: Haojian Zhuang Cc: Russell King Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/usb/host/Kconfig | 4 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-hcd.c | 6 +-- drivers/usb/host/ehci-mv.c | 123 ++++++++++++++++--------------------------- 4 files changed, 51 insertions(+), 83 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index d61a3fb..26754d6 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -222,13 +222,15 @@ config USB_EHCI_S5P on-chip EHCI controller. config USB_EHCI_MV - bool "EHCI support for Marvell on-chip controller" + tristate "EHCI support for Marvell on-chip controller" depends on USB_EHCI_HCD && (ARCH_PXA || ARCH_MMP) select USB_EHCI_ROOT_HUB_TT ---help--- Enables support for Marvell (including PXA and MMP series) on-chip USB SPH and OTG controller. SPH is a single port host, and it can only be EHCI host. OTG is controller that can switch to host mode. + Note that there is a separate driver for Marvell's embedded ARM + SoCs, see USB_EHCI_HCD_ORION for those. config USB_W90X900_EHCI bool "W90X900(W90P910) EHCI support" diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 36172b7..e5f380a 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o obj-$(CONFIG_USB_EHCI_HCD_SPEAR) += ehci-spear.o obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o +obj-$(CONFIG_USB_EHCI_MV) += ehci-mv.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 15b298b..1672235 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1318,11 +1318,6 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER ehci_grlib_driver #endif -#ifdef CONFIG_USB_EHCI_MV -#include "ehci-mv.c" -#define PLATFORM_DRIVER ehci_mv_driver -#endif - #ifdef CONFIG_MIPS_SEAD3 #include "ehci-sead3.c" #define PLATFORM_DRIVER ehci_hcd_sead3_driver @@ -1335,6 +1330,7 @@ MODULE_LICENSE ("GPL"); !IS_ENABLED(CONFIG_PLAT_SPEAR) && \ !IS_ENABLED(CONFIG_ARCH_AT91) && \ !IS_ENABLED(CONFIG_USB_EHCI_S5P) && \ + !IS_ENABLED(CONFIG_USB_EHCI_MV) && \ !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) && \ !defined(OF_PLATFORM_DRIVER) && \ diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index 3065809..2669e03 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c @@ -9,19 +9,28 @@ * option) any later version. */ +#include +#include +#include +#include #include #include #include -#include -#include -#include #include +#include +#include +#include + +#include "ehci.h" + +#define DRIVER_DESC "EHCI mv driver" +#define to_mv_ehci(hcd) (struct ehci_hcd_mv *)(hcd_to_ehci(hcd)->priv) #define CAPLENGTH_MASK (0xff) +static const char hcd_name[] = "ehci-mv"; +static struct hc_driver __read_mostly mv_ehci_hc_driver; struct ehci_hcd_mv { - struct usb_hcd *hcd; - /* Which mode does this ehci running OTG/Host ? */ int mode; @@ -75,68 +84,6 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv) ehci_clock_disable(ehci_mv); } -static int mv_ehci_reset(struct usb_hcd *hcd) -{ - struct device *dev = hcd->self.controller; - struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev); - int retval; - - if (ehci_mv == NULL) { - dev_err(dev, "Can not find private ehci data\n"); - return -ENODEV; - } - - hcd->has_tt = 1; - - retval = ehci_setup(hcd); - if (retval) - dev_err(dev, "ehci_setup failed %d\n", retval); - - return retval; -} - -static const struct hc_driver mv_ehci_hc_driver = { - .description = hcd_name, - .product_desc = "Marvell EHCI", - .hcd_priv_size = sizeof(struct ehci_hcd), - - /* - * generic hardware linkage - */ - .irq = ehci_irq, - .flags = HCD_MEMORY | HCD_USB2, - - /* - * basic lifecycle operations - */ - .reset = mv_ehci_reset, - .start = ehci_run, - .stop = ehci_stop, - .shutdown = ehci_shutdown, - - /* - * managing i/o requests and associated device resources - */ - .urb_enqueue = ehci_urb_enqueue, - .urb_dequeue = ehci_urb_dequeue, - .endpoint_disable = ehci_endpoint_disable, - .endpoint_reset = ehci_endpoint_reset, - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, - - /* - * scheduling support - */ - .get_frame_number = ehci_get_frame, - - /* - * root hub support - */ - .hub_status_data = ehci_hub_status_data, - .hub_control = ehci_hub_control, - .bus_suspend = ehci_bus_suspend, - .bus_resume = ehci_bus_resume, -}; - static int mv_ehci_probe(struct platform_device *pdev) { struct mv_usb_platform_data *pdata = pdev->dev.platform_data; @@ -146,7 +93,6 @@ static int mv_ehci_probe(struct platform_device *pdev) struct resource *r; int clk_i, retval = -ENODEV; u32 offset; - size_t size; if (!pdata) { dev_err(&pdev->dev, "missing platform_data\n"); @@ -160,8 +106,7 @@ static int mv_ehci_probe(struct platform_device *pdev) if (!hcd) return -ENOMEM; - size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum; - ehci_mv = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); + ehci_mv = to_mv_ehci(hcd); if (ehci_mv == NULL) { dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n"); retval = -ENOMEM; @@ -170,7 +115,6 @@ static int mv_ehci_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ehci_mv); ehci_mv->pdata = pdata; - ehci_mv->hcd = hcd; ehci_mv->clknum = pdata->clknum; for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) { @@ -235,6 +179,7 @@ static int mv_ehci_probe(struct platform_device *pdev) goto err_disable_clk; } + hcd->has_tt = 1; ehci = hcd_to_ehci(hcd); ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs; @@ -300,8 +245,8 @@ err_put_hcd: static int mv_ehci_remove(struct platform_device *pdev) { - struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); - struct usb_hcd *hcd = ehci_mv->hcd; + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ehci_hcd_mv *ehci_mv = to_mv_ehci(hcd); if (hcd->rh_registered) usb_remove_hcd(hcd); @@ -323,8 +268,6 @@ static int mv_ehci_remove(struct platform_device *pdev) return 0; } -MODULE_ALIAS("mv-ehci"); - static const struct platform_device_id ehci_id_table[] = { {"pxa-u2oehci", PXA_U2OEHCI}, {"pxa-sph", PXA_SPH}, @@ -335,8 +278,7 @@ static const struct platform_device_id ehci_id_table[] = { static void mv_ehci_shutdown(struct platform_device *pdev) { - struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); - struct usb_hcd *hcd = ehci_mv->hcd; + struct usb_hcd *hcd = platform_get_drvdata(pdev); if (!hcd->rh_registered) return; @@ -355,3 +297,30 @@ static struct platform_driver ehci_mv_driver = { }, .id_table = ehci_id_table, }; + +static const struct ehci_driver_overrides mv_overrides __initdata = { + .extra_priv_size = sizeof(struct ehci_hcd_mv), +}; + +static int __init ehci_mv_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + ehci_init_driver(&mv_ehci_hc_driver, &mv_overrides); + return platform_driver_register(&ehci_mv_driver); +} +module_init(ehci_mv_init); + +static void __exit ehci_mv_cleanup(void) +{ + platform_driver_unregister(&ehci_mv_driver); +} +module_exit(ehci_mv_cleanup); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_ALIAS("platform:mv-ehci"); +MODULE_AUTHOR("Chao Xie"); +MODULE_AUTHOR("Neil Zhang"); +MODULE_LICENSE("GPL v2");