linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: manjunath.goudar@linaro.org (Manjunath Goudar)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH 7/7] USB: OHCI: make ohci-s3c2410 a separate driver
Date: Fri,  7 Jun 2013 11:33:33 +0530	[thread overview]
Message-ID: <1370585013-12809-8-git-send-email-manjunath.goudar@linaro.org> (raw)
In-Reply-To: <1370585013-12809-1-git-send-email-manjunath.goudar@linaro.org>

Separate the Samsung OHCI S3CXXXX 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 <manjunath.goudar@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>
Cc: linux-usb at vger.kernel.org
---
 drivers/usb/host/Kconfig        |    8 +++
 drivers/usb/host/Makefile       |    1 +
 drivers/usb/host/ohci-hcd.c     |   20 +------
 drivers/usb/host/ohci-s3c2410.c |  116 ++++++++++++++++-----------------------
 4 files changed, 58 insertions(+), 87 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 0aabd84..a863c60 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -411,6 +411,14 @@ config USB_OHCI_HCD_SPEAR
           Enables support for the on-chip OHCI controller on
           ST SPEAr chips.
 
+config USB_OHCI_HCD_S3CXXXX
+        tristate "Support for S3CXXXX on-chip OHCI USB controller"
+        depends on USB_OHCI_HCD && (ARCH_S3C24XX) || (ARCH_S3C64XX)
+        default y
+        ---help---
+          Enables support for the on-chip OHCI controller on
+          S3CXXXX chips.
+
 config USB_OHCI_HCD_AT91
         tristate  "Support for Atmel on-chip OHCI USB controller"
         depends on USB_OHCI_HCD && ARCH_AT91
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 746ffc7..4290701 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_USB_OHCI_HCD_OMAP1)	+= ohci-omap.o
 obj-$(CONFIG_USB_OHCI_HCD_OMAP3)	+= ohci-omap3.o
 obj-$(CONFIG_USB_OHCI_HCD_SPEAR)	+= ohci-spear.o
 obj-$(CONFIG_USB_OHCI_HCD_AT91)	+= ohci-at91.o
+obj-$(CONFIG_USB_OHCI_HCD_S3CXXXX)	+= ohci-s3c2410.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 00409b9..8e5d979 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1173,11 +1173,6 @@ MODULE_LICENSE ("GPL");
 #define SA1111_DRIVER		ohci_hcd_sa1111_driver
 #endif
 
-#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
-#include "ohci-s3c2410.c"
-#define S3C2410_PLATFORM_DRIVER	ohci_hcd_s3c2410_driver
-#endif
-
 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
 #include "ohci-pxa27x.c"
 #define PLATFORM_DRIVER		ohci_hcd_pxa27x_driver
@@ -1240,13 +1235,13 @@ MODULE_LICENSE ("GPL");
 	!IS_ENABLED(CONFIG_USB_OHCI_HCD_OMAP3) && \
 	!IS_ENABLED(CONFIG_USB_OHCI_HCD_SPEAR) && \
 	!IS_ENABLED(CONFIG_USB_OHCI_HCD_AT91) && \
+	!IS_ENABLED(CONFIG_USB_OHCI_HCD_S3CXXXX) && \
 	!defined(PLATFORM_DRIVER) &&	\
 	!defined(OF_PLATFORM_DRIVER) &&	\
 	!defined(SA1111_DRIVER) &&	\
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
 	!defined(SM501_OHCI_DRIVER) && \
 	!defined(TMIO_OHCI_DRIVER) && \
-	!defined(S3C2410_PLATFORM_DRIVER) && \
 	!defined(EP93XX_PLATFORM_DRIVER) && \
 	!defined(NXP_PLATFORM_DRIVER) && \
 	!defined(DAVINCI_PLATFORM_DRIVER)
@@ -1309,12 +1304,6 @@ static int __init ohci_hcd_mod_init(void)
 		goto error_tmio;
 #endif
 
-#ifdef S3C2410_PLATFORM_DRIVER
-	retval = platform_driver_register(&S3C2410_PLATFORM_DRIVER);
-	if (retval < 0)
-		goto error_s3c2410;
-#endif
-
 #ifdef EP93XX_PLATFORM_DRIVER
 	retval = platform_driver_register(&EP93XX_PLATFORM_DRIVER);
 	if (retval < 0)
@@ -1348,10 +1337,6 @@ static int __init ohci_hcd_mod_init(void)
 	platform_driver_unregister(&EP93XX_PLATFORM_DRIVER);
  error_ep93xx:
 #endif
-#ifdef S3C2410_PLATFORM_DRIVER
-	platform_driver_unregister(&S3C2410_PLATFORM_DRIVER);
- error_s3c2410:
-#endif
 #ifdef TMIO_OHCI_DRIVER
 	platform_driver_unregister(&TMIO_OHCI_DRIVER);
  error_tmio:
@@ -1398,9 +1383,6 @@ static void __exit ohci_hcd_mod_exit(void)
 #ifdef EP93XX_PLATFORM_DRIVER
 	platform_driver_unregister(&EP93XX_PLATFORM_DRIVER);
 #endif
-#ifdef S3C2410_PLATFORM_DRIVER
-	platform_driver_unregister(&S3C2410_PLATFORM_DRIVER);
-#endif
 #ifdef TMIO_OHCI_DRIVER
 	platform_driver_unregister(&TMIO_OHCI_DRIVER);
 #endif
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index e125770..14843d2 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -19,14 +19,27 @@
  * This file is licenced under the GPL.
 */
 
-#include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
 #include <linux/platform_data/usb-ohci-s3c2410.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ohci.h"
+
 
 #define valid_port(idx) ((idx) == 1 || (idx) == 2)
 
 /* clock device associated with the hcd */
 
+
+#define DRIVER_DESC "OHCI S3CXXXX driver"
+
+static const char hcd_name[] = "ohci-s3cxxxx";
+
 static struct clk *clk;
 static struct clk *usb_clk;
 
@@ -371,10 +384,9 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
 		goto err_put;
 	}
 
+	ohci_setup(hcd);
 	s3c2410_start_hc(dev, hcd);
 
-	ohci_hcd_init(hcd_to_ohci(hcd));
-
 	retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
 	if (retval != 0)
 		goto err_ioremap;
@@ -391,71 +403,7 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
 
 /*-------------------------------------------------------------------------*/
 
-static int
-ohci_s3c2410_start(struct usb_hcd *hcd)
-{
-	struct ohci_hcd	*ohci = hcd_to_ohci(hcd);
-	int ret;
-
-	ret = ohci_init(ohci);
-	if (ret < 0)
-		return ret;
-
-	ret = ohci_run(ohci);
-	if (ret < 0) {
-		dev_err(hcd->self.controller, "can't start %s\n",
-			hcd->self.bus_name);
-		ohci_stop(hcd);
-		return ret;
-	}
-
-	return 0;
-}
-
-
-static const struct hc_driver ohci_s3c2410_hc_driver = {
-	.description =		hcd_name,
-	.product_desc =		"S3C24XX OHCI",
-	.hcd_priv_size =	sizeof(struct ohci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq =			ohci_irq,
-	.flags =		HCD_USB11 | HCD_MEMORY,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.start =		ohci_s3c2410_start,
-	.stop =			ohci_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_s3c2410_hub_status_data,
-	.hub_control =		ohci_s3c2410_hub_control,
-#ifdef	CONFIG_PM
-	.bus_suspend =		ohci_bus_suspend,
-	.bus_resume =		ohci_bus_resume,
-#endif
-	.start_port_reset =	ohci_start_port_reset,
-};
-
-/* device driver */
+static struct hc_driver __read_mostly ohci_s3c2410_hc_driver;
 
 static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev)
 {
@@ -532,4 +480,36 @@ static struct platform_driver ohci_hcd_s3c2410_driver = {
 	},
 };
 
+static int __init ohci_s3cxxxx_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
+	ohci_init_driver(&ohci_s3c2410_hc_driver, NULL);
+
+	/*
+	* The Samsung HW has some unusual quirks, which require Sumsung-specific
+	* workarounds. We override certain hc_driver functions here to
+	* achieve that. We explicitly do not enhance ohci_driver_overrides to
+	* allow this more easily, since this is an unusual case, and we don't
+	* want to encourage others to override these functions by making it
+	* too easy.
+	*/
+
+	ohci_s3c2410_hc_driver.hub_status_data	= ohci_s3c2410_hub_status_data;
+	ohci_s3c2410_hc_driver.hub_control	= ohci_s3c2410_hub_control;
+
+	return platform_driver_register(&ohci_hcd_s3c2410_driver);
+}
+module_init(ohci_s3cxxxx_init);
+
+static void __exit ohci_s3cxxxx_cleanup(void)
+{
+	platform_driver_unregister(&ohci_hcd_s3c2410_driver);
+}
+module_exit(ohci_s3cxxxx_cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:s3c2410-ohci");
-- 
1.7.9.5

  parent reply	other threads:[~2013-06-07  6:03 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07  6:03 [RFC][PATCH 0/7] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-06-07  6:03 ` [RFC][PATCH 1/7] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-06-07 13:49   ` Arnd Bergmann
2013-06-07 17:20   ` Alan Stern
2013-06-07  6:03 ` [RFC][PATCH 2/7] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-06-07 17:37   ` Alan Stern
2013-06-07  6:03 ` [RFC][PATCH 3/7] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-06-07 13:51   ` Arnd Bergmann
2013-06-07 17:49   ` Alan Stern
2013-06-07  6:03 ` [RFC][PATCH 4/7] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-06-07 10:30   ` Viresh Kumar
2013-06-07 18:34   ` Alan Stern
2013-06-07  6:03 ` [RFC][PATCH 5/7] USB: OHCI: export ohci_hub_control and ohci_hub_status_data Manjunath Goudar
2013-06-07 18:42   ` Alan Stern
2013-06-07  6:03 ` [RFC][PATCH 6/7] USB: OHCI: make ohci-at91 a separate driver Manjunath Goudar
2013-06-07 18:52   ` Alan Stern
2013-06-07  6:03 ` Manjunath Goudar [this message]
2013-06-07 13:56   ` [RFC][PATCH 7/7] USB: OHCI: make ohci-s3c2410 " Arnd Bergmann
2013-06-07 18:54   ` Alan Stern
2013-06-12 15:53 ` [PATCH V2 0/6] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-06-12 15:53   ` [PATCH V2 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-06-18 17:30     ` Alan Stern
2013-06-20  4:10     ` Jingoo Han
2013-06-12 15:53   ` [PATCH V2 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-06-18 17:47     ` Alan Stern
2013-06-18 18:13     ` Alan Stern
2013-06-12 15:53   ` [PATCH V2 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-06-18 18:16     ` Alan Stern
2013-06-12 15:54   ` [PATCH V2 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-06-18 18:23     ` Alan Stern
2013-06-12 15:54   ` [PATCH V2 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-06-19 20:16     ` Alan Stern
2013-06-12 15:54   ` [PATCH V2 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-06-19 20:38     ` Alan Stern
2013-06-25  6:23 ` [PATCH V3 0/6] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-06-25  6:23   ` [PATCH V3 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-06-25  6:23   ` [PATCH V3 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-07-18 15:50     ` Alan Stern
2013-06-25  6:23   ` [PATCH V3 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-06-25 18:14     ` Alan Stern
2013-06-25  6:23   ` [PATCH V3 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-06-25  6:23   ` [PATCH V3 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-07-18 20:51     ` Alan Stern
2013-06-25  6:23   ` [PATCH V3 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-07-18 20:38     ` Alan Stern
2013-07-22  9:19 ` [PATCH 0/6] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-07-22  9:19   ` [PATCH 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-07-22  9:19   ` [PATCH 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-07-23 18:39     ` Alan Stern
2013-07-22  9:19   ` [PATCH 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-07-23 18:43     ` Alan Stern
2013-07-22  9:19   ` [PATCH 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-07-22  9:19   ` [PATCH 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-07-23 18:45     ` Alan Stern
2013-07-22  9:19   ` [PATCH 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-07-23  8:23     ` Tomasz Figa
2013-07-22  9:41   ` [PATCH V4 0/6] USB: OHCI: more bus glues as separate modules manjunath
2013-07-31  6:07 ` Manjunath Goudar
2013-07-31  6:07   ` [PATCH V4 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-07-31  6:08   ` [PATCH V4 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-07-31  6:08   ` [PATCH V4 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-07-31  6:08   ` [PATCH V4 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-07-31  6:08   ` [PATCH V4 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-07-31  6:08   ` [PATCH V4 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-08-10  7:37 ` [PATCH V4 0/6] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-08-10  7:37   ` [PATCH V4 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-08-10 10:53     ` Tomasz Figa
2013-08-12  6:46 ` [PATCH V5 0/6]USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-08-12  6:46   ` [PATCH V5 1/6] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-08-12  6:46   ` [PATCH V5 2/6] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-08-12  6:46   ` [PATCH V5 3/6] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-08-12  6:46   ` [PATCH V5 4/6] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-08-12  6:56     ` Viresh Kumar
2013-08-12 20:20       ` Greg KH
2013-08-12  6:46   ` [PATCH V5 5/6] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-08-12  6:47   ` [PATCH V5 6/6] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-08-17 13:21     ` Tomasz Figa
2013-08-12  6:54   ` [PATCH V5 0/6]USB: OHCI: more bus glues as separate modules Viresh Kumar
2013-09-16 10:10 ` [PATCH V5 0/9] USB: " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 1/9] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 2/9] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 3/9] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 4/9] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 5/9] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 6/9] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 7/9] USB: OHCI: make ohci-nxp " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 8/9] USB: OHCI: make ohci-ep93xx " Manjunath Goudar
2013-09-16 10:10   ` [PATCH V5 9/9] USB: OHCI: make ohci-pxa27x " Manjunath Goudar
2013-09-21 11:08 ` [PATCH V5 0/9] USB: OHCI: more bus glues as separate modules Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 1/9] USB: OHCI: make ohci-exynos a separate driver Manjunath Goudar
2013-09-26 16:50     ` Greg KH
2013-09-21 11:08   ` [PATCH V5 2/9] USB: OHCI: make ohci-omap " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 3/9] USB: OHCI: make ohci-omap3 " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 4/9] USB: OHCI: make ohci-spear " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 5/9] USB: OHCI: make ohci-at91 " Manjunath Goudar
2013-09-23 12:22     ` Nicolas Ferre
2013-09-27 15:10     ` Kevin Hilman
2013-09-27 15:25       ` Greg KH
2013-09-27 15:37         ` Alan Stern
2013-09-27 15:40           ` Greg KH
2013-09-27 15:38       ` Alan Stern
2013-09-21 11:08   ` [PATCH V5 6/9] USB: OHCI: make ohci-s3c2410 " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 7/9] USB: OHCI: make ohci-nxp " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 8/9] USB: OHCI: make ohci-ep93xx " Manjunath Goudar
2013-09-21 11:08   ` [PATCH V5 9/9] USB: OHCI: make ohci-pxa27x " Manjunath Goudar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370585013-12809-8-git-send-email-manjunath.goudar@linaro.org \
    --to=manjunath.goudar@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).