From patchwork Wed Mar 20 12:09:50 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: 15437 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 E40F523E64 for ; Wed, 20 Mar 2013 12:10:15 +0000 (UTC) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by fiordland.canonical.com (Postfix) with ESMTP id 80EA7A19DD1 for ; Wed, 20 Mar 2013 12:10:15 +0000 (UTC) Received: by mail-ve0-f172.google.com with SMTP id cz11so1331648veb.3 for ; Wed, 20 Mar 2013 05:10:15 -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=ckCWrpV7xksg+pzB0goaAyI4Os3/21h4DAjeEF060/o=; b=dmSixofn7LZJC0AnJO8EQo0xC8myiD+dAgmNeFm/xP4AGx1OLAyLOWZ7BVV151oGUa 7mBYFni9b8HdjbPMk8FXjzUrf7IzMxOnI4wPaLJtQRK5Nd6Qa/PC9PTJRx95zBNe9AKd OCRInWzhEBRy5nbw7H2tkLCs8/DJRPBCkcah6sjFZIRkdHsHbgRo8em1/gMklAmPJkPL +c1URgXzh8Meh8FAFfr9/pPVpVdMzcE2f9Om5PDz/gK3aI0f7uMzavfrCWbquwyXk5C4 bPFAWEbW0bLoKbiePzaL3yVsbZ1rQmC+CqOwEnacM9VxyXwls3R3vX8ze99amb4gE4wn LkFA== X-Received: by 10.220.154.199 with SMTP id p7mr7459440vcw.46.1363781414964; Wed, 20 Mar 2013 05:10:14 -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.233.198 with SMTP id ty6csp8141vec; Wed, 20 Mar 2013 05:10:14 -0700 (PDT) X-Received: by 10.68.7.163 with SMTP id k3mr8592361pba.141.1363781413557; Wed, 20 Mar 2013 05:10:13 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id fd8si1736382pad.336.2013.03.20.05.10.13 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 05:10:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 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-f50.google.com with SMTP id up1so1305059pbc.37 for ; Wed, 20 Mar 2013 05:10:13 -0700 (PDT) X-Received: by 10.66.121.169 with SMTP id ll9mr8882740pab.169.1363781413081; Wed, 20 Mar 2013 05:10:13 -0700 (PDT) Received: from manjunath-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPS id rl3sm1918788pbb.28.2013.03.20.05.10.09 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 05:10:12 -0700 (PDT) From: Manjunath Goudar To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org Subject: [PATCH 2/2] USB: EHCI: make ehci-tegra a separate driver Date: Wed, 20 Mar 2013 17:39:50 +0530 Message-Id: <1363781390-13447-3-git-send-email-manjunath.goudar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363781390-13447-1-git-send-email-manjunath.goudar@linaro.org> References: <1363781390-13447-1-git-send-email-manjunath.goudar@linaro.org> X-Gm-Message-State: ALoCoQl/4bOi9MU+gp3I9tSnG8M7gCJB60E6Ff9XEFzenpYZ70WKsyy261mLXu+gBYdDT7mdE+gb Separate the Tegra on-chip 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 Tegra can be booted with a multi-platform kernel. Signed-off-by: Manjunath Goudar Cc: Greg KH Cc: Alan Stern Cc: Grant Likely Cc: Rob Herring Cc: Stephen Warren Cc: Russell King CC: Felipe Balbi Cc: linux-arm-kernel@lists.infradead.org Cc: linux-usb@vger.kernel.org Cc: linux-tegra@vger.kernel.org --- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-hcd.c | 20 +++---- drivers/usb/host/ehci-tegra.c | 113 +++++++++++++++++++-------------------- drivers/usb/otg/ulpi_viewport.c | 2 + 5 files changed, 71 insertions(+), 67 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index fb8d580..7a1a248 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -210,7 +210,7 @@ config USB_EHCI_MSM has an external PHY. config USB_EHCI_TEGRA - boolean "NVIDIA Tegra HCD support" + tristate "NVIDIA Tegra HCD support" depends on USB_EHCI_HCD && ARCH_TEGRA select USB_EHCI_ROOT_HUB_TT help diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 1550a0e..67bea25 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_USB_EHCI_HCD_VT8500) += ehci-vt8500.o obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o obj-$(CONFIG_USB_EHCI_HCD_ORION) += ehci-orion.o +obj-$(CONFIG_USB_EHCI_TEGRA) +=ehci-tegra.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index e01ce1d..8e2691b 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1236,10 +1236,16 @@ void ehci_init_driver(struct hc_driver *drv, *drv = ehci_hc_driver; if (over) { - drv->hcd_priv_size += over->extra_priv_size; - if (over->reset) - drv->reset = over->reset; - } + drv->hcd_priv_size += over->extra_priv_size; + if (over->reset) + drv->reset = over->reset; + if (over->map_urb_for_dma) + drv->map_urb_for_dma = over->map_urb_for_dma; + if (over->unmap_urb_for_dma) + drv->unmap_urb_for_dma = over->unmap_urb_for_dma; + if (over->hub_control) + drv->hub_control = over->hub_control; + } } EXPORT_SYMBOL_GPL(ehci_init_driver); @@ -1294,11 +1300,6 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER ehci_hcd_msp_driver #endif -#ifdef CONFIG_USB_EHCI_TEGRA -#include "ehci-tegra.c" -#define PLATFORM_DRIVER tegra_ehci_driver -#endif - #ifdef CONFIG_SPARC_LEON #include "ehci-grlib.c" #define PLATFORM_DRIVER ehci_grlib_driver @@ -1321,6 +1322,7 @@ MODULE_LICENSE ("GPL"); !IS_ENABLED(CONFIG_USB_EHCI_MSM) && \ !IS_ENABLED(CONFIG_USB_W90X900_EHCI) && \ !IS_ENABLED(CONFIG_PLAT_ORION) && \ + !IS_ENABLED(CONFIG_USB_EHCI_TEGRA) && \ !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) && \ !defined(OF_PLATFORM_DRIVER) && \ diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index d2da0d6..55c908b 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -17,18 +17,27 @@ */ #include +#include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include +#include +#include #include +#include +#include #include +#include +#include #include +#include "ehci.h" + #define TEGRA_USB_BASE 0xC5000000 #define TEGRA_USB2_BASE 0xC5004000 #define TEGRA_USB3_BASE 0xC5008000 @@ -37,9 +46,14 @@ #define TEGRA_USB_PORTSC1 0x184 #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) #define TEGRA_USB_PORTSC1_PHCD (1 << 23) +#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) #define TEGRA_USB_DMA_ALIGN 32 +#define DRIVER_DESC "EHCI Tegra driver" + +static const char hcd_name[] = "tegra-ehci"; + struct tegra_ehci_hcd { struct ehci_hcd *ehci; struct tegra_usb_phy *phy; @@ -268,31 +282,6 @@ static void tegra_ehci_restart(struct usb_hcd *hcd) up_write(&ehci_cf_port_reset_rwsem); } -static void tegra_ehci_shutdown(struct usb_hcd *hcd) -{ - struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); - - /* ehci_shutdown touches the USB controller registers, make sure - * controller has clocks to it */ - if (!tegra->host_resumed) - tegra_ehci_power_up(hcd); - - ehci_shutdown(hcd); -} - -static int tegra_ehci_setup(struct usb_hcd *hcd) -{ - struct ehci_hcd *ehci = hcd_to_ehci(hcd); - - /* EHCI registers start at offset 0x100 */ - ehci->caps = hcd->regs + 0x100; - - /* switch to host mode */ - hcd->has_tt = 1; - - return ehci_setup(hcd); -} - struct dma_aligned_buffer { void *kmalloc_ptr; void *old_xfer_buffer; @@ -372,36 +361,14 @@ static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) free_dma_aligned_buffer(urb); } -static const struct hc_driver tegra_ehci_hc_driver = { - .description = hcd_name, - .product_desc = "Tegra EHCI Host Controller", - .hcd_priv_size = sizeof(struct ehci_hcd), - .flags = HCD_USB2 | HCD_MEMORY, - - /* standard ehci functions */ - .irq = ehci_irq, - .start = ehci_run, - .stop = ehci_stop, - .urb_enqueue = ehci_urb_enqueue, - .urb_dequeue = ehci_urb_dequeue, - .endpoint_disable = ehci_endpoint_disable, - .endpoint_reset = ehci_endpoint_reset, - .get_frame_number = ehci_get_frame, - .hub_status_data = ehci_hub_status_data, - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, - .relinquish_port = ehci_relinquish_port, - .port_handed_over = ehci_port_handed_over, - - /* modified ehci functions for tegra */ - .reset = tegra_ehci_setup, - .shutdown = tegra_ehci_shutdown, +static struct hc_driver __read_mostly tegra_ehci_hc_driver; + +static struct ehci_driver_overrides tegra_overrides __initdata = { + .extra_priv_size = sizeof(struct tegra_ehci_hcd), .map_urb_for_dma = tegra_ehci_map_urb_for_dma, .unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma, - .hub_control = tegra_ehci_hub_control, -#ifdef CONFIG_PM - .bus_suspend = ehci_bus_suspend, - .bus_resume = ehci_bus_resume, -#endif + .hub_control = tegra_ehci_hub_control, + }; static int setup_vbus_gpio(struct platform_device *pdev, @@ -758,7 +725,13 @@ static int tegra_ehci_probe(struct platform_device *pdev) goto fail; } + /* EHCI registers start at offset 0x100 */ + tegra->ehci->caps = hcd->regs + 0x100; + tegra->host_resumed = 1; + + /* switch to host mode */ + hcd->has_tt = 1; tegra->ehci = hcd_to_ehci(hcd); irq = platform_get_irq(pdev, 0); @@ -834,6 +807,10 @@ static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); + /* ehci_shutdown touches the USB controller registers, make sure + * controller has clocks to it */ + if (!tegra->host_resumed) + tegra_ehci_power_up(hcd); if (hcd->driver->shutdown) hcd->driver->shutdown(hcd); } @@ -855,3 +832,25 @@ static struct platform_driver tegra_ehci_driver = { #endif } }; + +static int __init ehci_tegra_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + + ehci_init_driver(&tegra_ehci_hc_driver, &tegra_overrides); + return platform_driver_register(&tegra_ehci_driver); +} +module_init(ehci_tegra_init); + +static void __exit ehci_tegra_cleanup(void) +{ + platform_driver_unregister(&tegra_ehci_driver); +} +module_exit(ehci_tegra_cleanup); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_ALIAS("platform:tegra-ehci"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/usb/otg/ulpi_viewport.c b/drivers/usb/otg/ulpi_viewport.c index c5ba7e5..4442425 100644 --- a/drivers/usb/otg/ulpi_viewport.c +++ b/drivers/usb/otg/ulpi_viewport.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -78,3 +79,4 @@ struct usb_phy_io_ops ulpi_viewport_access_ops = { .read = ulpi_viewport_read, .write = ulpi_viewport_write, }; +EXPORT_SYMBOL_GPL(ulpi_viewport_access_ops);