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@linaro.org X-Patchwork-Id: 14715 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 A20D923DEA for ; Sun, 10 Feb 2013 18:58:46 +0000 (UTC) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by fiordland.canonical.com (Postfix) with ESMTP id 43EA8A19547 for ; Sun, 10 Feb 2013 18:58:46 +0000 (UTC) Received: by mail-vb0-f54.google.com with SMTP id l1so3378101vba.13 for ; Sun, 10 Feb 2013 10:58:45 -0800 (PST) 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=9lLUBIXhMbE6t3sMoczCYpuoC2fEEsEvkUk9d4Rg2Rs=; b=jgCRYikGbciWM1j6bAVb0QQ65r394FOm2ETO6CsOK02bI7spV3q0+SC1uDE1CrawFj TJj9mLiYgcqUErewOhilRIEy/6eEQI5KXaG/AvdggRsnOSPmO3+sLkiATav5atvmYqpI MSSDnceovPDp/Lo3FYClip7QZEkUbLavKflh/jBNydYyREKJdxj42hIcnsLg9PpXPY8C 4U3NNx1nOhLVoCMknvRZte32CJfv0bJOzcmP5om8Le7YFnLpD6+o2pANsaX5aO3j5fbn Spy5PguOFUPL0TMtmwA0TbMc66DHzco93d0hCHYLFZcCYEG36gWqOf10iSjeZyTOGqRX XMiw== X-Received: by 10.58.8.82 with SMTP id p18mr15544422vea.54.1360522725703; Sun, 10 Feb 2013 10:58:45 -0800 (PST) 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.252.8 with SMTP id zo8csp63520vec; Sun, 10 Feb 2013 10:58:45 -0800 (PST) X-Received: by 10.68.212.65 with SMTP id ni1mr12881019pbc.160.1360522724543; Sun, 10 Feb 2013 10:58:44 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id f4si47940566pav.294.2013.02.10.10.58.44 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 10 Feb 2013 10:58:44 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.220.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.46 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-pa0-f46.google.com with SMTP id kp14so2757842pab.19 for ; Sun, 10 Feb 2013 10:58:44 -0800 (PST) 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 Cc: linux-arm-kernel@lists.infradead.org, patches@linaro.org, stern@rowland.harvard.edu, arnd@linaro.org, gregkh@linuxfoundation.org, Manjunath Goudar , Deepak Saxena , Greg KH , Viresh Kumar , Shiraz Hashim , spear-devel@list.st.com 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: ALoCoQmzJ7ay7U6U2ZWy0fEiMmG14FBze6rAAwetZ9wp1h875jLYYx/3iaAut3eSpBxBfxo0Ix5h 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");