From patchwork Thu Apr 18 07:17:47 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: 16185 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6330223974 for ; Thu, 18 Apr 2013 07:18:45 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id w16sf4123053vbb.6 for ; Thu, 18 Apr 2013 00:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=CHu1RmA/kLWvYyuSahiPfgolLHZCBC5Ms78aJBtzf3M=; b=FU5tC+2cK4ppo5RhrH238Z0ao/M9vVi0QNPPAB8TPu+AjfMEjf94qVdmJPAQYMSgto HFYzLHTINvLC0xX9vaFx0/Ds5TmvxHS4OzPzgwSILi0OqLnTuOynszUuQKgyf9pgjCEF 7E4cuLkjnyWjBrn48nwBn9oJzQe/16EGTVThydXp6aq9WC/WjgZir+dppjcNGm/61HG1 q8rv/H2/GGS83MYBBwQpDxadAr0gshnvCK6ICc0aGl4wbWI5C3O7g0EOQiwYVG0paAPE lfOn54gi0NUR64WmafM4wnHTwwoqI4uSW6EEM0Nb7LLasAONRq3BFehCzuxqCB43ff+s y01Q== X-Received: by 10.224.217.195 with SMTP id hn3mr7232607qab.5.1366269488515; Thu, 18 Apr 2013 00:18:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.131 with SMTP id ea3ls1318060qeb.20.gmail; Thu, 18 Apr 2013 00:18:08 -0700 (PDT) X-Received: by 10.59.4.101 with SMTP id cd5mr7444659ved.14.1366269488150; Thu, 18 Apr 2013 00:18:08 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id cs9si6012327vdc.12.2013.04.18.00.18.08 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 00:18:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id gf12so2115364vcb.4 for ; Thu, 18 Apr 2013 00:18:08 -0700 (PDT) X-Received: by 10.52.163.231 with SMTP id yl7mr6263264vdb.57.1366269487976; Thu, 18 Apr 2013 00:18:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp109370veb; Thu, 18 Apr 2013 00:18:07 -0700 (PDT) X-Received: by 10.68.25.233 with SMTP id f9mr528043pbg.118.1366269486820; Thu, 18 Apr 2013 00:18:06 -0700 (PDT) Received: from mail-pb0-x229.google.com (mail-pb0-x229.google.com [2607:f8b0:400e:c01::229]) by mx.google.com with ESMTPS id xw2si8283265pbb.312.2013.04.18.00.18.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 00:18:06 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c01::229 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=2607:f8b0:400e:c01::229; Received: by mail-pb0-f41.google.com with SMTP id ma3so47pbc.28 for ; Thu, 18 Apr 2013 00:18:06 -0700 (PDT) X-Received: by 10.68.228.2 with SMTP id se2mr12549456pbc.76.1366269486364; Thu, 18 Apr 2013 00:18:06 -0700 (PDT) Received: from manjunath-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPS id ad7sm8899735pbd.14.2013.04.18.00.18.03 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 00:18:05 -0700 (PDT) From: Manjunath Goudar To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org Subject: [RFC PATCH 2/2] USB: OHCI: make ohci-exynos a separate driver Date: Thu, 18 Apr 2013 12:47:47 +0530 Message-Id: <1366269467-15778-3-git-send-email-manjunath.goudar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366269467-15778-1-git-send-email-manjunath.goudar@linaro.org> References: <1366269467-15778-1-git-send-email-manjunath.goudar@linaro.org> X-Gm-Message-State: ALoCoQk8y0ivTLDN33CQ2NH5GAIq3LUlgUrtL8jLlG8Lv+iRixUTvxTrm3qb89UIP/U8HdgzFpVR X-Original-Sender: manjunath.goudar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Separate the Samsung OHCI EXYNOS host controller driver from ohci-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 EXYNOS can be booted with a multi-platform kernel. We currently expect those to get merged for 3.11. Signed-off-by: Manjunath Goudar Cc: Arnd Bergmann Cc: Jingoo Han Cc: Kukjin Kim Cc: Greg KH Cc: Alan Stern Cc: linux-usb@vger.kernel.org --- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-exynos.c | 161 +++++++++++++++++++--------------------- drivers/usb/host/ohci-hcd.c | 5 -- 4 files changed, 80 insertions(+), 89 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index bbf1907..42ce228 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -445,7 +445,7 @@ config USB_OHCI_SH If you use the PCI OHCI controller, this option is not necessary. config USB_OHCI_EXYNOS - boolean "OHCI support for Samsung EXYNOS SoC Series" + tristate "OHCI support for Samsung EXYNOS SoC Series" depends on USB_OHCI_HCD && ARCH_EXYNOS help Enable support for the Samsung Exynos SOC's on-chip OHCI controller. diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index a20a8d9..f148671 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o obj-$(CONFIG_USB_OHCI_PCI) += ohci-pci.o +obj-$(CONFIG_USB_OHCI_EXYNOS) += ohci-exynos.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index e3b7e85..f671f56 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -12,41 +12,35 @@ */ #include +#include +#include +#include +#include #include #include #include +#include +#include #include #include +#include #include +#include "ohci.h" + +#define DRIVER_DESC "OHCI exynos driver" + +static const char hcd_name[] = "ohci-exynos"; +static struct hc_driver __read_mostly exynos_ohci_hc_driver; + struct exynos_ohci_hcd { - struct device *dev; - struct usb_hcd *hcd; struct clk *clk; struct usb_phy *phy; struct usb_otg *otg; struct exynos4_ohci_platdata *pdata; }; -static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci) -{ - struct platform_device *pdev = to_platform_device(exynos_ohci->dev); - - if (exynos_ohci->phy) - usb_phy_init(exynos_ohci->phy); - else if (exynos_ohci->pdata->phy_init) - exynos_ohci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); -} - -static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci) -{ - struct platform_device *pdev = to_platform_device(exynos_ohci->dev); - - if (exynos_ohci->phy) - usb_phy_shutdown(exynos_ohci->phy); - else if (exynos_ohci->pdata->phy_exit) - exynos_ohci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); -} +#define to_exynos_ohci(hcd) (struct exynos_ohci_hcd *)(hcd_to_ohci(hcd)->priv) static int ohci_exynos_reset(struct usb_hcd *hcd) { @@ -71,34 +65,6 @@ static int ohci_exynos_start(struct usb_hcd *hcd) return 0; } -static const struct hc_driver exynos_ohci_hc_driver = { - .description = hcd_name, - .product_desc = "EXYNOS OHCI Host Controller", - .hcd_priv_size = sizeof(struct ohci_hcd), - - .irq = ohci_irq, - .flags = HCD_MEMORY|HCD_USB11, - - .reset = ohci_exynos_reset, - .start = ohci_exynos_start, - .stop = ohci_stop, - .shutdown = ohci_shutdown, - - .get_frame_number = ohci_get_frame, - - .urb_enqueue = ohci_urb_enqueue, - .urb_dequeue = ohci_urb_dequeue, - .endpoint_disable = ohci_endpoint_disable, - - .hub_status_data = ohci_hub_status_data, - .hub_control = ohci_hub_control, -#ifdef CONFIG_PM - .bus_suspend = ohci_bus_suspend, - .bus_resume = ohci_bus_resume, -#endif - .start_port_reset = ohci_start_port_reset, -}; - static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32); static int exynos_ohci_probe(struct platform_device *pdev) @@ -122,11 +88,13 @@ static int exynos_ohci_probe(struct platform_device *pdev) if (!pdev->dev.coherent_dma_mask) pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); - exynos_ohci = devm_kzalloc(&pdev->dev, sizeof(struct exynos_ohci_hcd), - GFP_KERNEL); - if (!exynos_ohci) + hcd = usb_create_hcd(&exynos_ohci_hc_driver, + &pdev->dev, dev_name(&pdev->dev)); + if (!hcd) { + dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; - + } + exynos_ohci = to_exynos_ohci(hcd); phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(phy)) { /* Fallback to pdata */ @@ -141,16 +109,6 @@ static int exynos_ohci_probe(struct platform_device *pdev) exynos_ohci->otg = phy->otg; } - exynos_ohci->dev = &pdev->dev; - - hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!hcd) { - dev_err(&pdev->dev, "Unable to create HCD\n"); - return -ENOMEM; - } - - exynos_ohci->hcd = hcd; exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost"); if (IS_ERR(exynos_ohci->clk)) { @@ -187,10 +145,12 @@ static int exynos_ohci_probe(struct platform_device *pdev) } if (exynos_ohci->otg) - exynos_ohci->otg->set_host(exynos_ohci->otg, - &exynos_ohci->hcd->self); + exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); - exynos_ohci_phy_enable(exynos_ohci); + if (exynos_ohci->phy) + usb_phy_init(exynos_ohci->phy); + else if (exynos_ohci->pdata->phy_init) + exynos_ohci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); ohci = hcd_to_ohci(hcd); ohci_hcd_init(ohci); @@ -201,12 +161,15 @@ static int exynos_ohci_probe(struct platform_device *pdev) goto fail_add_hcd; } - platform_set_drvdata(pdev, exynos_ohci); + platform_set_drvdata(pdev, hcd); return 0; fail_add_hcd: - exynos_ohci_phy_disable(exynos_ohci); + if (exynos_ohci->phy) + usb_phy_shutdown(exynos_ohci->phy); + else if (exynos_ohci->pdata->phy_exit) + exynos_ohci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); fail_io: clk_disable_unprepare(exynos_ohci->clk); fail_clk: @@ -216,16 +179,19 @@ fail_clk: static int exynos_ohci_remove(struct platform_device *pdev) { - struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); - struct usb_hcd *hcd = exynos_ohci->hcd; + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); usb_remove_hcd(hcd); if (exynos_ohci->otg) exynos_ohci->otg->set_host(exynos_ohci->otg, - &exynos_ohci->hcd->self); + &hcd->self); - exynos_ohci_phy_disable(exynos_ohci); + if (exynos_ohci->phy) + usb_phy_shutdown(exynos_ohci->phy); + else if (exynos_ohci->pdata->phy_exit) + exynos_ohci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); clk_disable_unprepare(exynos_ohci->clk); @@ -236,8 +202,7 @@ static int exynos_ohci_remove(struct platform_device *pdev) static void exynos_ohci_shutdown(struct platform_device *pdev) { - struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); - struct usb_hcd *hcd = exynos_ohci->hcd; + struct usb_hcd *hcd = platform_get_drvdata(pdev); if (hcd->driver->shutdown) hcd->driver->shutdown(hcd); @@ -246,9 +211,10 @@ static void exynos_ohci_shutdown(struct platform_device *pdev) #ifdef CONFIG_PM static int exynos_ohci_suspend(struct device *dev) { - struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); - struct usb_hcd *hcd = exynos_ohci->hcd; + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + struct platform_device *pdev = to_platform_device(dev); unsigned long flags; int rc = 0; @@ -268,10 +234,12 @@ static int exynos_ohci_suspend(struct device *dev) clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); if (exynos_ohci->otg) - exynos_ohci->otg->set_host(exynos_ohci->otg, - &exynos_ohci->hcd->self); + exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); - exynos_ohci_phy_disable(exynos_ohci); + if (exynos_ohci->phy) + usb_phy_shutdown(exynos_ohci->phy); + else if (exynos_ohci->pdata->phy_exit) + exynos_ohci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); clk_disable_unprepare(exynos_ohci->clk); @@ -283,16 +251,20 @@ fail: static int exynos_ohci_resume(struct device *dev) { - struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); - struct usb_hcd *hcd = exynos_ohci->hcd; + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); + struct platform_device *pdev = to_platform_device(dev); clk_prepare_enable(exynos_ohci->clk); if (exynos_ohci->otg) exynos_ohci->otg->set_host(exynos_ohci->otg, - &exynos_ohci->hcd->self); + &hcd->self); - exynos_ohci_phy_enable(exynos_ohci); + if (exynos_ohci->phy) + usb_phy_init(exynos_ohci->phy); + else if (exynos_ohci->pdata->phy_init) + exynos_ohci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); ohci_resume(hcd, false); @@ -303,6 +275,12 @@ static int exynos_ohci_resume(struct device *dev) #define exynos_ohci_resume NULL #endif +static const struct ohci_driver_overrides exynos_overrides = { + .extra_priv_size = sizeof(struct exynos_ohci_hcd), + .reset = ohci_exynos_reset, + .start = ohci_exynos_start, +}; + static const struct dev_pm_ops exynos_ohci_pm_ops = { .suspend = exynos_ohci_suspend, .resume = exynos_ohci_resume, @@ -327,6 +305,23 @@ static struct platform_driver exynos_ohci_driver = { .of_match_table = of_match_ptr(exynos_ohci_match), } }; +static int __init ehci_exynos_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + ohci_init_driver(&exynos_ohci_hc_driver, &exynos_overrides); + return platform_driver_register(&exynos_ohci_driver); +} +module_init(ehci_exynos_init); + +static void __exit ehci_exynos_cleanup(void) +{ + platform_driver_unregister(&exynos_ohci_driver); +} +module_exit(ehci_exynos_cleanup); MODULE_ALIAS("platform:exynos-ohci"); MODULE_AUTHOR("Jingoo Han "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 3d624c2..8881e1a 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1152,11 +1152,6 @@ MODULE_LICENSE ("GPL"); #define S3C2410_PLATFORM_DRIVER ohci_hcd_s3c2410_driver #endif -#ifdef CONFIG_USB_OHCI_EXYNOS -#include "ohci-exynos.c" -#define EXYNOS_PLATFORM_DRIVER exynos_ohci_driver -#endif - #ifdef CONFIG_USB_OHCI_HCD_OMAP1 #include "ohci-omap.c" #define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver