@@ -222,13 +222,15 @@ config USB_EHCI_S5P
on-chip EHCI controller.
config USB_EHCI_MV
- bool "EHCI support for Marvell on-chip controller"
+ tristate "EHCI support for Marvell on-chip controller"
depends on USB_EHCI_HCD && (ARCH_PXA || ARCH_MMP)
select USB_EHCI_ROOT_HUB_TT
---help---
Enables support for Marvell (including PXA and MMP series) on-chip
USB SPH and OTG controller. SPH is a single port host, and it can
only be EHCI host. OTG is controller that can switch to host mode.
+ Note that there is a separate driver for Marvell's embedded ARM
+ SoCs, see USB_EHCI_HCD_ORION for those.
config USB_W90X900_EHCI
bool "W90X900(W90P910) EHCI support"
@@ -30,6 +30,7 @@ obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
obj-$(CONFIG_USB_EHCI_HCD_SPEAR) += ehci-spear.o
obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
+obj-$(CONFIG_USB_EHCI_MV) += ehci-mv.o
obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
@@ -1318,11 +1318,6 @@ MODULE_LICENSE ("GPL");
#define PLATFORM_DRIVER ehci_grlib_driver
#endif
-#ifdef CONFIG_USB_EHCI_MV
-#include "ehci-mv.c"
-#define PLATFORM_DRIVER ehci_mv_driver
-#endif
-
#ifdef CONFIG_MIPS_SEAD3
#include "ehci-sead3.c"
#define PLATFORM_DRIVER ehci_hcd_sead3_driver
@@ -1335,6 +1330,7 @@ MODULE_LICENSE ("GPL");
!IS_ENABLED(CONFIG_PLAT_SPEAR) && \
!IS_ENABLED(CONFIG_ARCH_AT91) && \
!IS_ENABLED(CONFIG_USB_EHCI_S5P) && \
+ !IS_ENABLED(CONFIG_USB_EHCI_MV) && \
!defined(PLATFORM_DRIVER) && \
!defined(PS3_SYSTEM_BUS_DRIVER) && \
!defined(OF_PLATFORM_DRIVER) && \
@@ -9,19 +9,28 @@
* option) any later version.
*/
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/usb/otg.h>
#include <linux/platform_data/mv_usb.h>
+#include <linux/usb/otg.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
+
+#define DRIVER_DESC "EHCI mv driver"
+#define to_mv_ehci(hcd) (struct ehci_hcd_mv *)(hcd_to_ehci(hcd)->priv)
#define CAPLENGTH_MASK (0xff)
+static const char hcd_name[] = "ehci-mv";
+static struct hc_driver __read_mostly mv_ehci_hc_driver;
struct ehci_hcd_mv {
- struct usb_hcd *hcd;
-
/* Which mode does this ehci running OTG/Host ? */
int mode;
@@ -75,68 +84,6 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
ehci_clock_disable(ehci_mv);
}
-static int mv_ehci_reset(struct usb_hcd *hcd)
-{
- struct device *dev = hcd->self.controller;
- struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev);
- int retval;
-
- if (ehci_mv == NULL) {
- dev_err(dev, "Can not find private ehci data\n");
- return -ENODEV;
- }
-
- hcd->has_tt = 1;
-
- retval = ehci_setup(hcd);
- if (retval)
- dev_err(dev, "ehci_setup failed %d\n", retval);
-
- return retval;
-}
-
-static const struct hc_driver mv_ehci_hc_driver = {
- .description = hcd_name,
- .product_desc = "Marvell EHCI",
- .hcd_priv_size = sizeof(struct ehci_hcd),
-
- /*
- * generic hardware linkage
- */
- .irq = ehci_irq,
- .flags = HCD_MEMORY | HCD_USB2,
-
- /*
- * basic lifecycle operations
- */
- .reset = mv_ehci_reset,
- .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,
- .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-
- /*
- * 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,
-};
-
static int mv_ehci_probe(struct platform_device *pdev)
{
struct mv_usb_platform_data *pdata = pdev->dev.platform_data;
@@ -146,7 +93,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
struct resource *r;
int clk_i, retval = -ENODEV;
u32 offset;
- size_t size;
if (!pdata) {
dev_err(&pdev->dev, "missing platform_data\n");
@@ -160,8 +106,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
if (!hcd)
return -ENOMEM;
- size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum;
- ehci_mv = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+ ehci_mv = to_mv_ehci(hcd);
if (ehci_mv == NULL) {
dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n");
retval = -ENOMEM;
@@ -170,7 +115,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ehci_mv);
ehci_mv->pdata = pdata;
- ehci_mv->hcd = hcd;
ehci_mv->clknum = pdata->clknum;
for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) {
@@ -235,6 +179,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_disable_clk;
}
+ hcd->has_tt = 1;
ehci = hcd_to_ehci(hcd);
ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs;
@@ -300,8 +245,8 @@ err_put_hcd:
static int mv_ehci_remove(struct platform_device *pdev)
{
- struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
- struct usb_hcd *hcd = ehci_mv->hcd;
+ struct usb_hcd *hcd = platform_get_drvdata(pdev);
+ struct ehci_hcd_mv *ehci_mv = to_mv_ehci(hcd);
if (hcd->rh_registered)
usb_remove_hcd(hcd);
@@ -323,8 +268,6 @@ static int mv_ehci_remove(struct platform_device *pdev)
return 0;
}
-MODULE_ALIAS("mv-ehci");
-
static const struct platform_device_id ehci_id_table[] = {
{"pxa-u2oehci", PXA_U2OEHCI},
{"pxa-sph", PXA_SPH},
@@ -335,8 +278,7 @@ static const struct platform_device_id ehci_id_table[] = {
static void mv_ehci_shutdown(struct platform_device *pdev)
{
- struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
- struct usb_hcd *hcd = ehci_mv->hcd;
+ struct usb_hcd *hcd = platform_get_drvdata(pdev);
if (!hcd->rh_registered)
return;
@@ -355,3 +297,30 @@ static struct platform_driver ehci_mv_driver = {
},
.id_table = ehci_id_table,
};
+
+static const struct ehci_driver_overrides mv_overrides __initdata = {
+ .extra_priv_size = sizeof(struct ehci_hcd_mv),
+};
+
+static int __init ehci_mv_init(void)
+{
+ if (usb_disabled())
+ return -ENODEV;
+
+ pr_info("%s: " DRIVER_DESC "\n", hcd_name);
+ ehci_init_driver(&mv_ehci_hc_driver, &mv_overrides);
+ return platform_driver_register(&ehci_mv_driver);
+}
+module_init(ehci_mv_init);
+
+static void __exit ehci_mv_cleanup(void)
+{
+ platform_driver_unregister(&ehci_mv_driver);
+}
+module_exit(ehci_mv_cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_ALIAS("platform:mv-ehci");
+MODULE_AUTHOR("Chao Xie");
+MODULE_AUTHOR("Neil Zhang");
+MODULE_LICENSE("GPL v2");