6f4ae7b
From 54a419668b0f27b7982807fb2376d237e0a0ce05 Mon Sep 17 00:00:00 2001
6f4ae7b
From: Alan Stern <stern@rowland.harvard.edu>
6f4ae7b
Date: Tue, 12 Mar 2013 10:44:39 +0000
6f4ae7b
Subject: USB: EHCI: split ehci-omap out to a separate driver
6f4ae7b
6f4ae7b
This patch (as1645) converts ehci-omap over to the new "ehci-hcd is a
6f4ae7b
library" approach, so that it can coexist peacefully with other EHCI
6f4ae7b
platform drivers and can make use of the private area allocated at
6f4ae7b
the end of struct ehci_hcd.
6f4ae7b
6f4ae7b
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
6f4ae7b
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6f4ae7b
---
6f4ae7b
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
6f4ae7b
index c59a112..62f4e9a 100644
6f4ae7b
--- a/drivers/usb/host/Kconfig
6f4ae7b
+++ b/drivers/usb/host/Kconfig
6f4ae7b
@@ -155,7 +155,7 @@ config USB_EHCI_MXC
6f4ae7b
 	  Variation of ARC USB block used in some Freescale chips.
6f4ae7b
 
6f4ae7b
 config USB_EHCI_HCD_OMAP
6f4ae7b
-	bool "EHCI support for OMAP3 and later chips"
6f4ae7b
+	tristate "EHCI support for OMAP3 and later chips"
6f4ae7b
 	depends on USB_EHCI_HCD && ARCH_OMAP
6f4ae7b
 	default y
6f4ae7b
 	---help---
6f4ae7b
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
6f4ae7b
index 001fbff..56de410 100644
6f4ae7b
--- a/drivers/usb/host/Makefile
6f4ae7b
+++ b/drivers/usb/host/Makefile
6f4ae7b
@@ -27,6 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
6f4ae7b
 obj-$(CONFIG_USB_EHCI_PCI)	+= ehci-pci.o
6f4ae7b
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)	+= ehci-platform.o
6f4ae7b
 obj-$(CONFIG_USB_EHCI_MXC)	+= ehci-mxc.o
6f4ae7b
+obj-$(CONFIG_USB_EHCI_HCD_OMAP)	+= ehci-omap.o
6f4ae7b
 
6f4ae7b
 obj-$(CONFIG_USB_OXU210HP_HCD)	+= oxu210hp-hcd.o
6f4ae7b
 obj-$(CONFIG_USB_ISP116X_HCD)	+= isp116x-hcd.o
6f4ae7b
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
6f4ae7b
index b416a3f..303b022 100644
6f4ae7b
--- a/drivers/usb/host/ehci-hcd.c
6f4ae7b
+++ b/drivers/usb/host/ehci-hcd.c
6f4ae7b
@@ -1252,11 +1252,6 @@ MODULE_LICENSE ("GPL");
6f4ae7b
 #define PLATFORM_DRIVER		ehci_hcd_sh_driver
6f4ae7b
 #endif
6f4ae7b
 
6f4ae7b
-#ifdef CONFIG_USB_EHCI_HCD_OMAP
6f4ae7b
-#include "ehci-omap.c"
6f4ae7b
-#define        PLATFORM_DRIVER         ehci_hcd_omap_driver
6f4ae7b
-#endif
6f4ae7b
-
6f4ae7b
 #ifdef CONFIG_PPC_PS3
6f4ae7b
 #include "ehci-ps3.c"
6f4ae7b
 #define	PS3_SYSTEM_BUS_DRIVER	ps3_ehci_driver
6f4ae7b
@@ -1346,6 +1341,7 @@ MODULE_LICENSE ("GPL");
6f4ae7b
 	!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
6f4ae7b
 	!IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \
6f4ae7b
 	!IS_ENABLED(CONFIG_USB_EHCI_MXC) && \
6f4ae7b
+	!IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
6f4ae7b
 	!defined(PLATFORM_DRIVER) && \
6f4ae7b
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
6f4ae7b
 	!defined(OF_PLATFORM_DRIVER) && \
6f4ae7b
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
6f4ae7b
index 0555ee4..fa66757 100644
6f4ae7b
--- a/drivers/usb/host/ehci-omap.c
6f4ae7b
+++ b/drivers/usb/host/ehci-omap.c
6f4ae7b
@@ -36,6 +36,9 @@
6f4ae7b
  *	- convert to use hwmod and runtime PM
6f4ae7b
  */
6f4ae7b
 
6f4ae7b
+#include <linux/kernel.h>
6f4ae7b
+#include <linux/module.h>
6f4ae7b
+#include <linux/io.h>
6f4ae7b
 #include <linux/platform_device.h>
6f4ae7b
 #include <linux/slab.h>
6f4ae7b
 #include <linux/usb/ulpi.h>
6f4ae7b
@@ -43,6 +46,10 @@
6f4ae7b
 #include <linux/pm_runtime.h>
6f4ae7b
 #include <linux/gpio.h>
6f4ae7b
 #include <linux/clk.h>
6f4ae7b
+#include <linux/usb.h>
6f4ae7b
+#include <linux/usb/hcd.h>
6f4ae7b
+
6f4ae7b
+#include "ehci.h"
6f4ae7b
 
6f4ae7b
 #include <linux/platform_data/usb-omap.h>
6f4ae7b
 
6f4ae7b
@@ -57,9 +64,11 @@
6f4ae7b
 #define	EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT		8
6f4ae7b
 #define	EHCI_INSNREG05_ULPI_WRDATA_SHIFT		0
6f4ae7b
 
6f4ae7b
-/*-------------------------------------------------------------------------*/
6f4ae7b
+#define DRIVER_DESC "OMAP-EHCI Host Controller driver"
6f4ae7b
 
6f4ae7b
-static const struct hc_driver ehci_omap_hc_driver;
6f4ae7b
+static const char hcd_name[] = "ehci-omap";
6f4ae7b
+
6f4ae7b
+/*-------------------------------------------------------------------------*/
6f4ae7b
 
6f4ae7b
 
6f4ae7b
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
6f4ae7b
@@ -166,6 +175,12 @@ static void disable_put_regulator(
6f4ae7b
 /* configure so an HC device and id are always provided */
6f4ae7b
 /* always called with process context; sleeping is OK */
6f4ae7b
 
6f4ae7b
+static struct hc_driver __read_mostly ehci_omap_hc_driver;
6f4ae7b
+
6f4ae7b
+static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
6f4ae7b
+	.reset =		omap_ehci_init,
6f4ae7b
+};
6f4ae7b
+
6f4ae7b
 /**
6f4ae7b
  * ehci_hcd_omap_probe - initialize TI-based HCDs
6f4ae7b
  *
6f4ae7b
@@ -315,56 +330,33 @@ static struct platform_driver ehci_hcd_omap_driver = {
6f4ae7b
 	/*.suspend		= ehci_hcd_omap_suspend, */
6f4ae7b
 	/*.resume		= ehci_hcd_omap_resume, */
6f4ae7b
 	.driver = {
6f4ae7b
-		.name		= "ehci-omap",
6f4ae7b
+		.name		= hcd_name,
6f4ae7b
 	}
6f4ae7b
 };
6f4ae7b
 
6f4ae7b
 /*-------------------------------------------------------------------------*/
6f4ae7b
 
6f4ae7b
-static const struct hc_driver ehci_omap_hc_driver = {
6f4ae7b
-	.description		= hcd_name,
6f4ae7b
-	.product_desc		= "OMAP-EHCI Host Controller",
6f4ae7b
-	.hcd_priv_size		= sizeof(struct ehci_hcd),
6f4ae7b
-
6f4ae7b
-	/*
6f4ae7b
-	 * generic hardware linkage
6f4ae7b
-	 */
6f4ae7b
-	.irq			= ehci_irq,
6f4ae7b
-	.flags			= HCD_MEMORY | HCD_USB2,
6f4ae7b
-
6f4ae7b
-	/*
6f4ae7b
-	 * basic lifecycle operations
6f4ae7b
-	 */
6f4ae7b
-	.reset			= omap_ehci_init,
6f4ae7b
-	.start			= ehci_run,
6f4ae7b
-	.stop			= ehci_stop,
6f4ae7b
-	.shutdown		= ehci_shutdown,
6f4ae7b
-
6f4ae7b
-	/*
6f4ae7b
-	 * managing i/o requests and associated device resources
6f4ae7b
-	 */
6f4ae7b
-	.urb_enqueue		= ehci_urb_enqueue,
6f4ae7b
-	.urb_dequeue		= ehci_urb_dequeue,
6f4ae7b
-	.endpoint_disable	= ehci_endpoint_disable,
6f4ae7b
-	.endpoint_reset		= ehci_endpoint_reset,
6f4ae7b
+static int __init ehci_omap_init(void)
6f4ae7b
+{
6f4ae7b
+	if (usb_disabled())
6f4ae7b
+		return -ENODEV;
6f4ae7b
 
6f4ae7b
-	/*
6f4ae7b
-	 * scheduling support
6f4ae7b
-	 */
6f4ae7b
-	.get_frame_number	= ehci_get_frame,
6f4ae7b
+	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
6f4ae7b
 
6f4ae7b
-	/*
6f4ae7b
-	 * root hub support
6f4ae7b
-	 */
6f4ae7b
-	.hub_status_data	= ehci_hub_status_data,
6f4ae7b
-	.hub_control		= ehci_hub_control,
6f4ae7b
-	.bus_suspend		= ehci_bus_suspend,
6f4ae7b
-	.bus_resume		= ehci_bus_resume,
6f4ae7b
+	ehci_init_driver(&ehci_omap_hc_driver, &ehci_omap_overrides);
6f4ae7b
+	return platform_driver_register(&ehci_hcd_omap_driver);
6f4ae7b
+}
6f4ae7b
+module_init(ehci_omap_init);
6f4ae7b
 
6f4ae7b
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
6f4ae7b
-};
6f4ae7b
+static void __exit ehci_omap_cleanup(void)
6f4ae7b
+{
6f4ae7b
+	platform_driver_unregister(&ehci_hcd_omap_driver);
6f4ae7b
+}
6f4ae7b
+module_exit(ehci_omap_cleanup);
6f4ae7b
 
6f4ae7b
 MODULE_ALIAS("platform:ehci-omap");
6f4ae7b
 MODULE_AUTHOR("Texas Instruments, Inc.");
6f4ae7b
 MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
6f4ae7b
 
6f4ae7b
+MODULE_DESCRIPTION(DRIVER_DESC);
6f4ae7b
+MODULE_LICENSE("GPL");
6f4ae7b
--
6f4ae7b
cgit v0.9.1