From patchwork Sun Mar 17 18:31:40 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: 15394 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 487E923E2C for ; Sun, 17 Mar 2013 18:32:12 +0000 (UTC) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by fiordland.canonical.com (Postfix) with ESMTP id D80C4A1882A for ; Sun, 17 Mar 2013 18:32:11 +0000 (UTC) Received: by mail-vb0-f53.google.com with SMTP id fj18so2869003vbb.26 for ; Sun, 17 Mar 2013 11:32:11 -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=dZ5H7FnXViXzKe7T9oD9OiVOsdAhvUgFJfqA6RD7vUA=; b=Uin9xikhLNDnIVPUg2nzD+VZkxFXYpgdzEQNqd9ESn566njGVWFbM7tcOcGxvQNPJn tgn1dnkQw+T8Z23zNbJKetw7h0YKHu+IE90Q61HH3naQ/GKQbGNawnBfiJUxpZsxcZDz NoV5P62p5aEKmwdsn56c5bDoJDni9oWUtNrHNxBEbclNk6wIhx+WfEhX+Ha36W87ngGo 0UlYKk+ELmqtiD1FjV+2Ivh4mUwnmy4fqGYj8Iz67ysmTcrDjvlm3i/7JM/VkXE7Scft 97ZZqyVYDwXuteTZdHadzqkV1AeFFZpgcRd1i5WiCH77inRMmhPwxBScGOQDQd2mE9iX 23OQ== X-Received: by 10.52.93.235 with SMTP id cx11mr13866895vdb.51.1363545131243; Sun, 17 Mar 2013 11:32:11 -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.58.127.98 with SMTP id nf2csp208093veb; Sun, 17 Mar 2013 11:32:10 -0700 (PDT) X-Received: by 10.66.50.232 with SMTP id f8mr6541151pao.183.1363545130050; Sun, 17 Mar 2013 11:32:10 -0700 (PDT) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by mx.google.com with ESMTPS id xp9si18342925pbc.340.2013.03.17.11.32.09 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Mar 2013 11:32:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.44 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.160.44; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.44 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-pb0-f44.google.com with SMTP id wz12so5808422pbc.17 for ; Sun, 17 Mar 2013 11:32:09 -0700 (PDT) X-Received: by 10.68.190.99 with SMTP id gp3mr29488620pbc.117.1363545129449; Sun, 17 Mar 2013 11:32:09 -0700 (PDT) Received: from localhost.localdomain ([223.239.138.120]) by mx.google.com with ESMTPS id i9sm5187683paa.7.2013.03.17.11.32.06 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Mar 2013 11:32:08 -0700 (PDT) From: Manjunath Goudar To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org Subject: [V3 4/8] USB: EHCI: make ehci-mv as separate static driver Date: Mon, 18 Mar 2013 00:01:40 +0530 Message-Id: <1363545104-1677-5-git-send-email-manjunath.goudar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363545104-1677-1-git-send-email-manjunath.goudar@linaro.org> References: <1363545104-1677-1-git-send-email-manjunath.goudar@linaro.org> X-Gm-Message-State: ALoCoQmqeDjg7nOpKuGRLIxe9bs1UmD6gl2QIe2/jbtX2iL+6D1rD4hIX3GsoL+6gmIEf+PlHIm1 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 | 108 ++++++++++++++++--------------------------- 4 files changed, 46 insertions(+), 73 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..8050590 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c @@ -9,15 +9,25 @@ * 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 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; @@ -75,68 +85,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; @@ -235,6 +183,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; @@ -323,8 +272,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}, @@ -355,3 +302,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");