From patchwork Fri Jun 7 06:03:28 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: 17659 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f198.google.com (mail-gg0-f198.google.com [209.85.161.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95D5D25E33 for ; Fri, 7 Jun 2013 06:04:09 +0000 (UTC) Received: by mail-gg0-f198.google.com with SMTP id p4sf1113880ggn.9 for ; Thu, 06 Jun 2013 23:04:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to: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=xIuFKmY5DXU3F2qjOm3kaxDlr+i3O6f3fuDwJPMLkx8=; b=BRFnn6p66BmAmdIeDoJ/SyDOPoi4kpQW4XPSB8CpKSBCOn7KH6vs5z9VR9n3tnazly fQ9bWJz3trOePKxYYV75PcB16UzQXIatGVqToJhFxh1miWhJbD0Nad8khZ1Us2Xio6E5 ygFP32Jpfwb6OK2HtGfxvswRGjzVB7gfIHuBHxvNkbvZsqcAdQmxj7SX6Wh6lqZ2qDYE 5AA/f7XIOaMP2wP3Gt/Tf4zh3zNtu6lSBeNJ7pghz40YGSDJE9KZAypnrGZR++kcuUIK xApYJONy52q4rsBOSSDjfoZzwUdaS6d5/VtfaWoGcAusefmO8QqCjYuLtJV1KAVdHw06 tN+g== X-Received: by 10.224.165.143 with SMTP id i15mr706385qay.0.1370585049128; Thu, 06 Jun 2013 23:04:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.130 with SMTP id p2ls1676821qek.57.gmail; Thu, 06 Jun 2013 23:04:08 -0700 (PDT) X-Received: by 10.220.94.1 with SMTP id x1mr17019186vcm.12.1370585048714; Thu, 06 Jun 2013 23:04:08 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id ef7si42880972vdc.137.2013.06.06.23.04.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Jun 2013 23:04:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 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.175; Received: by mail-vc0-f175.google.com with SMTP id hr11so2500355vcb.20 for ; Thu, 06 Jun 2013 23:04:08 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr19661845vdj.8.1370585048561; Thu, 06 Jun 2013 23:04:08 -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.221.10.206 with SMTP id pb14csp99335vcb; Thu, 6 Jun 2013 23:04:07 -0700 (PDT) X-Received: by 10.66.150.106 with SMTP id uh10mr1194273pab.118.1370585047381; Thu, 06 Jun 2013 23:04:07 -0700 (PDT) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx.google.com with ESMTPS id pt5si745602pac.69.2013.06.06.23.04.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Jun 2013 23:04:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.181 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.192.181; Received: by mail-pd0-f181.google.com with SMTP id 14so1737119pdj.12 for ; Thu, 06 Jun 2013 23:04:06 -0700 (PDT) X-Received: by 10.68.232.136 with SMTP id to8mr42360065pbc.9.1370585046870; Thu, 06 Jun 2013 23:04:06 -0700 (PDT) Received: from localhost.localdomain ([223.239.151.157]) by mx.google.com with ESMTPSA id i16sm1523759pag.18.2013.06.06.23.04.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Jun 2013 23:04:06 -0700 (PDT) From: Manjunath Goudar To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, patches@linaro.org, stern@rowland.harvard.edu, arnd@linaro.org, manjunath.goudar@linaro.org, linaro-dev@lists.linaro.org, Felipe Balbi , Arnd Bergmann , Greg KH Subject: [RFC][PATCH 2/7] USB: OHCI: make ohci-omap a separate driver Date: Fri, 7 Jun 2013 11:33:28 +0530 Message-Id: <1370585013-12809-3-git-send-email-manjunath.goudar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1370585013-12809-1-git-send-email-manjunath.goudar@linaro.org> References: <1370585013-12809-1-git-send-email-manjunath.goudar@linaro.org> X-Gm-Message-State: ALoCoQk8xwWXtp7QNcHPQLKA3oeFd4PE8sny+nXn1jfxDaN2AJ5i3hMyma+BEjWG02rkKfs3zWoj X-Original-Sender: manjunath.goudar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 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 TI OHCI OMAP1/2 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. Signed-off-by: Manjunath Goudar Cc: Felipe Balbi Cc: Arnd Bergmann 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-hcd.c | 20 +----- drivers/usb/host/ohci-omap.c | 142 ++++++++++++++++-------------------------- 4 files changed, 55 insertions(+), 110 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index f827386..744673b 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -397,7 +397,7 @@ config USB_OHCI_HCD if USB_OHCI_HCD config USB_OHCI_HCD_OMAP1 - bool "OHCI support for OMAP1/2 chips" + tristate "OHCI support for OMAP1/2 chips" depends on ARCH_OMAP1 default y ---help--- diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 2a4f11f..1326df2 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o obj-$(CONFIG_USB_OHCI_HCD_PLATFORM) += ohci-platform.o obj-$(CONFIG_USB_OHCI_EXYNOS) += ohci-exynos.o +obj-$(CONFIG_USB_OHCI_HCD_OMAP1) += ohci-omap.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 14962f8..4bfd890 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1178,11 +1178,6 @@ MODULE_LICENSE ("GPL"); #define S3C2410_PLATFORM_DRIVER ohci_hcd_s3c2410_driver #endif -#ifdef CONFIG_USB_OHCI_HCD_OMAP1 -#include "ohci-omap.c" -#define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver -#endif - #ifdef CONFIG_USB_OHCI_HCD_OMAP3 #include "ohci-omap3.c" #define OMAP3_PLATFORM_DRIVER ohci_hcd_omap3_driver @@ -1256,8 +1251,8 @@ MODULE_LICENSE ("GPL"); #if !IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI) && \ !IS_ENABLED(CONFIG_USB_OHCI_HCD_PLATFORM) && \ !IS_ENABLED(CONFIG_USB_OHCI_EXYNOS) && \ + !IS_ENABLED(CONFIG_USB_OHCI_HCD_OMAP1) && \ !defined(PLATFORM_DRIVER) && \ - !defined(OMAP1_PLATFORM_DRIVER) && \ !defined(OMAP3_PLATFORM_DRIVER) && \ !defined(OF_PLATFORM_DRIVER) && \ !defined(SA1111_DRIVER) && \ @@ -1305,12 +1300,6 @@ static int __init ohci_hcd_mod_init(void) goto error_platform; #endif -#ifdef OMAP1_PLATFORM_DRIVER - retval = platform_driver_register(&OMAP1_PLATFORM_DRIVER); - if (retval < 0) - goto error_omap1_platform; -#endif - #ifdef OMAP3_PLATFORM_DRIVER retval = platform_driver_register(&OMAP3_PLATFORM_DRIVER); if (retval < 0) @@ -1424,10 +1413,6 @@ static int __init ohci_hcd_mod_init(void) platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); error_omap3_platform: #endif -#ifdef OMAP1_PLATFORM_DRIVER - platform_driver_unregister(&OMAP1_PLATFORM_DRIVER); - error_omap1_platform: -#endif #ifdef PLATFORM_DRIVER platform_driver_unregister(&PLATFORM_DRIVER); error_platform: @@ -1482,9 +1467,6 @@ static void __exit ohci_hcd_mod_exit(void) #ifdef OMAP3_PLATFORM_DRIVER platform_driver_unregister(&OMAP3_PLATFORM_DRIVER); #endif -#ifdef OMAP1_PLATFORM_DRIVER - platform_driver_unregister(&OMAP1_PLATFORM_DRIVER); -#endif #ifdef PLATFORM_DRIVER platform_driver_unregister(&PLATFORM_DRIVER); #endif diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 8747fa6..eee4b72 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -14,12 +14,21 @@ * This file is licenced under the GPL. */ -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ohci.h" #include #include @@ -42,10 +51,7 @@ #define OMAP1510_LB_MMU_RAM_H 0xfffec234 #define OMAP1510_LB_MMU_RAM_L 0xfffec238 - -#ifndef CONFIG_ARCH_OMAP -#error "This file is OMAP bus glue. CONFIG_OMAP must be defined." -#endif +#define DRIVER_DESC "OHCI OMAP driver" #ifdef CONFIG_TPS65010 #include @@ -71,6 +77,10 @@ static struct clk *usb_dc_ck; static int host_enabled; static int host_initialized; +static const char hcd_name[] = "ohci-omap"; +static struct hc_driver __read_mostly ohci_omap_hc_driver; + + static void omap_ohci_clock_power(int on) { if (on) { @@ -188,7 +198,7 @@ static void start_hnp(struct ohci_hcd *ohci) /*-------------------------------------------------------------------------*/ -static int ohci_omap_init(struct usb_hcd *hcd) +static int ohci_omap_reset(struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct omap_usb_config *config = hcd->self.controller->platform_data; @@ -201,8 +211,14 @@ static int ohci_omap_init(struct usb_hcd *hcd) ohci_to_hcd(ohci)->self.otg_port = config->otg; /* default/minimum OTG power budget: 8 mA */ ohci_to_hcd(ohci)->power_budget = 8; + ohci->hc_control = OHCI_CTRL_RWC; + writel(OHCI_CTRL_RWC, &ohci->regs->control); } + if (config->rwc) { + ohci->hc_control = OHCI_CTRL_RWC; + writel(OHCI_CTRL_RWC, &ohci->regs->control); + } /* boards can use OTG transceivers in non-OTG modes */ need_transceiver = need_transceiver || machine_is_omap_h2() || machine_is_omap_h3(); @@ -238,7 +254,8 @@ static int ohci_omap_init(struct usb_hcd *hcd) omap_1510_local_bus_init(); } - if ((ret = ohci_init(ohci)) < 0) + ret = ohci_setup(hcd); + if (ret < 0) return ret; /* board-specific power switching and overcurrent support */ @@ -281,14 +298,6 @@ static int ohci_omap_init(struct usb_hcd *hcd) return 0; } -static void ohci_omap_stop(struct usb_hcd *hcd) -{ - dev_dbg(hcd->self.controller, "stopping USB Controller\n"); - ohci_stop(hcd); - omap_ohci_clock_power(0); -} - - /*-------------------------------------------------------------------------*/ /** @@ -304,7 +313,6 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, { int retval, irq; struct usb_hcd *hcd = 0; - struct ohci_hcd *ohci; if (pdev->num_resources != 2) { printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", @@ -354,8 +362,7 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, goto err2; } - ohci = hcd_to_ohci(hcd); - ohci_hcd_init(ohci); + ohci_setup(hcd); host_initialized = 0; host_enabled = 1; @@ -418,76 +425,6 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) /*-------------------------------------------------------------------------*/ -static int -ohci_omap_start (struct usb_hcd *hcd) -{ - struct omap_usb_config *config; - struct ohci_hcd *ohci = hcd_to_ohci (hcd); - int ret; - - if (!host_enabled) - return 0; - config = hcd->self.controller->platform_data; - if (config->otg || config->rwc) { - ohci->hc_control = OHCI_CTRL_RWC; - writel(OHCI_CTRL_RWC, &ohci->regs->control); - } - - if ((ret = ohci_run (ohci)) < 0) { - dev_err(hcd->self.controller, "can't start\n"); - ohci_stop (hcd); - return ret; - } - return 0; -} - -/*-------------------------------------------------------------------------*/ - -static const struct hc_driver ohci_omap_hc_driver = { - .description = hcd_name, - .product_desc = "OMAP OHCI", - .hcd_priv_size = sizeof(struct ohci_hcd), - - /* - * generic hardware linkage - */ - .irq = ohci_irq, - .flags = HCD_USB11 | HCD_MEMORY, - - /* - * basic lifecycle operations - */ - .reset = ohci_omap_init, - .start = ohci_omap_start, - .stop = ohci_omap_stop, - .shutdown = ohci_shutdown, - - /* - * managing i/o requests and associated device resources - */ - .urb_enqueue = ohci_urb_enqueue, - .urb_dequeue = ohci_urb_dequeue, - .endpoint_disable = ohci_endpoint_disable, - - /* - * scheduling support - */ - .get_frame_number = ohci_get_frame, - - /* - * root hub support - */ - .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 int ohci_hcd_omap_drv_probe(struct platform_device *dev) { return usb_hcd_omap_probe(&ohci_omap_hc_driver, dev); @@ -553,4 +490,29 @@ static struct platform_driver ohci_hcd_omap_driver = { }, }; +static const struct ohci_driver_overrides omap_overrides __initconst = { + .product_desc = "OMAP OHCI", + .reset = ohci_omap_reset +}; + +static int __init ohci_omap_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + + ohci_init_driver(&ohci_omap_hc_driver, &omap_overrides); + return platform_driver_register(&ohci_hcd_omap_driver); +} +module_init(ohci_omap_init); + +static void __exit ohci_omap_cleanup(void) +{ + platform_driver_unregister(&ohci_hcd_omap_driver); +} +module_exit(ohci_omap_cleanup); + +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_ALIAS("platform:ohci"); +MODULE_LICENSE("GPL");