From patchwork Sun Feb 10 18:58:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manjunath Goudar X-Patchwork-Id: 2122731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 54702DF24C for ; Sun, 10 Feb 2013 19:01:46 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U4c71-0008Qv-0z; Sun, 10 Feb 2013 18:58:51 +0000 Received: from mail-da0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U4c6v-0008Q7-ME for linux-arm-kernel@lists.infradead.org; Sun, 10 Feb 2013 18:58:47 +0000 Received: by mail-da0-f49.google.com with SMTP id t11so2478205daj.36 for ; Sun, 10 Feb 2013 10:58:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=9lLUBIXhMbE6t3sMoczCYpuoC2fEEsEvkUk9d4Rg2Rs=; b=A4e+oxy/uO9efELbHE/cU/0KoY/U3U9U1KHMdpELjCk1vZOFQh+P6Gl4SohIRxgOvg uYlD2vq4Nq7yEhNcIT0Zi2jvgOjEswDeFzlbY7QKDS6BGFrpdVVg9FKH9QwrsQRkCmDB aQd9BeapaWCYuGGDTSNhWks9VFp4QEmPhQnuVcGzExT/a6BA88xEnr0p3vAl8zBwoHEt Xxc8ZR9xQ5F5wnn9azNVS9XK9yqfrdqtEwgj/qARg06H46Ju5ITo09SsSKBdFWIlygpG FqhbFUQn6p1+7AtKRmhBNkpgTUgKKFWmBqda964lsGaFQaVldMHLENYDTa3vOsOzpecG bgaw== X-Received: by 10.68.55.233 with SMTP id v9mr12992424pbp.102.1360522724101; Sun, 10 Feb 2013 10:58:44 -0800 (PST) Received: from localhost.localdomain ([223.239.146.70]) by mx.google.com with ESMTPS id p6sm5157070pbc.39.2013.02.10.10.58.38 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 10 Feb 2013 10:58:43 -0800 (PST) From: manjunath.goudar@linaro.org To: linux-usb@vger.kernel.org Subject: [PATCH 1/8] USB: EHCI: make ehci-spear a separate driver Date: Mon, 11 Feb 2013 00:28:10 +0530 Message-Id: <5117ede3.860e440a.097c.3508@mx.google.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360522697-22902-1-git-send-email-y> References: <1360522697-22902-1-git-send-email-y> X-Gm-Message-State: ALoCoQlTXGiap4WY2QBB1UHNh+nbVVDIhCrxIq/cd6SkCj2NnC8hlOhvG48k3NnNdX055V6LN4fg X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130210_135845_984538_A1A93BD1 X-CRM114-Status: GOOD ( 20.06 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.49 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: patches@linaro.org, gregkh@linuxfoundation.org, Manjunath Goudar , spear-devel@list.st.com, Deepak Saxena , stern@rowland.harvard.edu, Greg KH , Viresh Kumar , arnd@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Manjunath Goudar Separate the Spear host controller driver from ehci-hcd host code into its own driver module. Signed-off-by: Manjunath Goudar Signed-off-by: Deepak Saxena Cc: Greg KH Cc: Alan Stern Cc: Viresh Kumar Cc: Shiraz Hashim Cc: linux-usb@vger.kernel.org Cc: spear-devel@list.st.com --- drivers/usb/host/Kconfig | 8 +++ drivers/usb/host/Makefile | 2 +- drivers/usb/host/ehci-hcd.c | 8 +-- drivers/usb/host/ehci-spear.c | 131 +++++++++++++++++++++-------------------- 4 files changed, 78 insertions(+), 71 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 3a21c5d..15e8032 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -162,6 +162,14 @@ config USB_EHCI_HCD_OMAP Enables support for the on-chip EHCI controller on OMAP3 and later chips. +config USB_EHCI_HCD_SPEAR + tristate "Support for ST SPEAr on-chip EHCI USB controller" + depends on USB_EHCI_HCD && PLAT_SPEAR + default y + ---help--- + Enables support for the on-chip EHCI controller on + ST SPEAr chips. + config USB_EHCI_MSM bool "Support for MSM on-chip EHCI USB controller" depends on USB_EHCI_HCD && ARCH_MSM diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 001fbff..c8fcde9 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -27,7 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o - +obj-$(CONFIG_USB_EHCI_HCD_SPEAR)+= ehci-spear.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b416a3f..be7247b 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1274,7 +1274,7 @@ MODULE_LICENSE ("GPL"); #ifdef CONFIG_PLAT_ORION #include "ehci-orion.c" -#define PLATFORM_DRIVER ehci_orion_driver +#define PLATFORM_DRIVER ehci_orion_driver #endif #ifdef CONFIG_USB_W90X900_EHCI @@ -1297,11 +1297,6 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER vt8500_ehci_driver #endif -#ifdef CONFIG_PLAT_SPEAR -#include "ehci-spear.c" -#define PLATFORM_DRIVER spear_ehci_hcd_driver -#endif - #ifdef CONFIG_USB_EHCI_MSM #include "ehci-msm.c" #define PLATFORM_DRIVER ehci_msm_driver @@ -1347,6 +1342,7 @@ MODULE_LICENSE ("GPL"); !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \ !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \ !defined(PLATFORM_DRIVER) && \ + !IS_ENABLED(CONFIG_PLAT_SPEAR) && \ !defined(PS3_SYSTEM_BUS_DRIVER) && \ !defined(OF_PLATFORM_DRIVER) && \ !defined(XILINX_OF_PLATFORM_DRIVER) diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index 466c1bb..0d9ed11 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c @@ -1,5 +1,5 @@ /* -* Driver for EHCI HCD on SPEAR SOC +* Driver for EHCI HCD on SPEAr SOC * * Copyright (C) 2010 ST Micro Electronics, * Deepak Sikri @@ -12,29 +12,41 @@ */ #include +#include +#include #include +#include +#include #include #include #include +#include +#include -struct spear_ehci { +#include "ehci.h" + +#define DRIVER_DESC "EHCI SPEAr driver" + +static const char hcd_name[] = "ehci-SPEAr"; + +struct SPEAr_ehci { struct ehci_hcd ehci; struct clk *clk; }; -#define to_spear_ehci(hcd) (struct spear_ehci *)hcd_to_ehci(hcd) +#define to_SPEAr_ehci(hcd) (struct SPEAr_ehci *)hcd_to_ehci(hcd) -static void spear_start_ehci(struct spear_ehci *ehci) +static void SPEAr_start_ehci(struct SPEAr_ehci *ehci) { clk_prepare_enable(ehci->clk); } -static void spear_stop_ehci(struct spear_ehci *ehci) +static void SPEAr_stop_ehci(struct SPEAr_ehci *ehci) { clk_disable_unprepare(ehci->clk); } -static int ehci_spear_setup(struct usb_hcd *hcd) +static int ehci_SPEAr_setup(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -43,43 +55,10 @@ static int ehci_spear_setup(struct usb_hcd *hcd) return ehci_setup(hcd); } - -static const struct hc_driver ehci_spear_hc_driver = { - .description = hcd_name, - .product_desc = "SPEAr EHCI", - .hcd_priv_size = sizeof(struct spear_ehci), - - /* generic hardware linkage */ - .irq = ehci_irq, - .flags = HCD_MEMORY | HCD_USB2, - - /* basic lifecycle operations */ - .reset = ehci_spear_setup, - .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, - - /* 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, - .relinquish_port = ehci_relinquish_port, - .port_handed_over = ehci_port_handed_over, - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, -}; +static struct hc_driver __read_mostly ehci_SPEAr_hc_driver; #ifdef CONFIG_PM -static int ehci_spear_drv_suspend(struct device *dev) +static int ehci_SPEAr_drv_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); bool do_wakeup = device_may_wakeup(dev); @@ -87,7 +66,7 @@ static int ehci_spear_drv_suspend(struct device *dev) return ehci_suspend(hcd, do_wakeup); } -static int ehci_spear_drv_resume(struct device *dev) +static int ehci_SPEAr_drv_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); @@ -96,18 +75,18 @@ static int ehci_spear_drv_resume(struct device *dev) } #endif /* CONFIG_PM */ -static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, - ehci_spear_drv_resume); +static SIMPLE_DEV_PM_OPS(ehci_SPEAr_pm_ops, ehci_SPEAr_drv_suspend, + ehci_SPEAr_drv_resume); -static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32); +static u64 SPEAr_ehci_dma_mask = DMA_BIT_MASK(32); -static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) +static int SPEAr_ehci_hcd_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd ; - struct spear_ehci *ehci; + struct SPEAr_ehci *ehci; struct resource *res; struct clk *usbh_clk; - const struct hc_driver *driver = &ehci_spear_hc_driver; + const struct hc_driver *driver = &ehci_SPEAr_hc_driver; int irq, retval; if (usb_disabled()) @@ -125,7 +104,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) * Once we have dma capability bindings this can go away. */ if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &spear_ehci_dma_mask; + pdev->dev.dma_mask = &SPEAr_ehci_dma_mask; usbh_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(usbh_clk)) { @@ -161,10 +140,10 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) goto err_put_hcd; } - ehci = (struct spear_ehci *)hcd_to_ehci(hcd); + ehci = (struct SPEAr_ehci *)hcd_to_ehci(hcd); ehci->clk = usbh_clk; - spear_start_ehci(ehci); + SPEAr_start_ehci(ehci); retval = usb_add_hcd(hcd, irq, IRQF_SHARED); if (retval) goto err_stop_ehci; @@ -172,7 +151,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) return retval; err_stop_ehci: - spear_stop_ehci(ehci); + SPEAr_stop_ehci(ehci); err_put_hcd: usb_put_hcd(hcd); fail: @@ -181,10 +160,10 @@ fail: return retval ; } -static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) +static int SPEAr_ehci_hcd_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); - struct spear_ehci *ehci_p = to_spear_ehci(hcd); + struct SPEAr_ehci *ehci_p = to_SPEAr_ehci(hcd); if (!hcd) return 0; @@ -193,27 +172,51 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) usb_remove_hcd(hcd); if (ehci_p->clk) - spear_stop_ehci(ehci_p); + SPEAr_stop_ehci(ehci_p); usb_put_hcd(hcd); return 0; } -static struct of_device_id spear_ehci_id_table[] = { - { .compatible = "st,spear600-ehci", }, +static struct of_device_id SPEAr_ehci_id_table[] = { + { .compatible = "st,SPEAr600-ehci", }, { }, }; -static struct platform_driver spear_ehci_hcd_driver = { - .probe = spear_ehci_hcd_drv_probe, - .remove = spear_ehci_hcd_drv_remove, +static struct platform_driver SPEAr_ehci_hcd_driver = { + .probe = SPEAr_ehci_hcd_drv_probe, + .remove = SPEAr_ehci_hcd_drv_remove, .shutdown = usb_hcd_platform_shutdown, .driver = { - .name = "spear-ehci", + .name = hcd_name, .bus = &platform_bus_type, - .pm = &ehci_spear_pm_ops, - .of_match_table = of_match_ptr(spear_ehci_id_table), + .pm = &ehci_SPEAr_pm_ops, + .of_match_table = of_match_ptr(SPEAr_ehci_id_table), } }; -MODULE_ALIAS("platform:spear-ehci"); + +static const struct ehci_driver_overrides SPEAr_overrides __initdata = { + .reset = ehci_SPEAr_setup, +}; + +static int __init ehci_SPEAr_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + + ehci_init_driver(&ehci_SPEAr_hc_driver, &SPEAr_overrides); + return platform_driver_register(&SPEAr_ehci_hcd_driver); +} +module_init(ehci_SPEAr_init); + +static void __exit ehci_SPEAr_cleanup(void) +{ + platform_driver_unregister(&SPEAr_ehci_hcd_driver); +} +module_exit(ehci_SPEAr_cleanup); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL");