summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-08-22 16:42:56 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-20 07:07:55 -0400
commit0440fa3d1b4eb3a75b806b6538a3f9547dec4eef (patch)
treeb1385960847485fe4ec4c37bc836d266696e7a7e
parentb32abf8f5d83049fb4576c3edb9f31f3515791a5 (diff)
USB: EHCI: make ehci-mv a separate driver
This is done do that it could be enabled alongside other platform EHCI glue drivers on multiplatform kernels. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/Makefile1
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/host/ehci-mv.c98
4 files changed, 44 insertions, 62 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..16758b12a5e9 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -276,7 +276,7 @@ config USB_EHCI_EXYNOS
276 Enable support for the Samsung Exynos SOC's on-chip EHCI controller. 276 Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
277 277
278config USB_EHCI_MV 278config USB_EHCI_MV
279 bool "EHCI support for Marvell PXA/MMP USB controller" 279 tristate "EHCI support for Marvell PXA/MMP USB controller"
280 depends on (ARCH_PXA || ARCH_MMP) 280 depends on (ARCH_PXA || ARCH_MMP)
281 select USB_EHCI_ROOT_HUB_TT 281 select USB_EHCI_ROOT_HUB_TT
282 ---help--- 282 ---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..84514f71ae44 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o
87obj-$(CONFIG_USB_FSL_USB2) += fsl-mph-dr-of.o 87obj-$(CONFIG_USB_FSL_USB2) += fsl-mph-dr-of.o
88obj-$(CONFIG_USB_EHCI_FSL) += fsl-mph-dr-of.o 88obj-$(CONFIG_USB_EHCI_FSL) += fsl-mph-dr-of.o
89obj-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o 89obj-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o
90obj-$(CONFIG_USB_EHCI_MV) += ehci-mv.o
90obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o 91obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o
91obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o 92obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o
92obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o 93obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 8608ac513fb7..e8d7667828eb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
1286#define PLATFORM_DRIVER ehci_grlib_driver 1286#define PLATFORM_DRIVER ehci_grlib_driver
1287#endif 1287#endif
1288 1288
1289#ifdef CONFIG_USB_EHCI_MV
1290#include "ehci-mv.c"
1291#define PLATFORM_DRIVER ehci_mv_driver
1292#endif
1293
1294static int __init ehci_hcd_init(void) 1289static int __init ehci_hcd_init(void)
1295{ 1290{
1296 int retval = 0; 1291 int retval = 0;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index de764459e05a..77a4ab1dcd07 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -12,12 +12,17 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/usb/otg.h> 13#include <linux/usb/otg.h>
14#include <linux/platform_data/mv_usb.h> 14#include <linux/platform_data/mv_usb.h>
15#include <linux/io.h>
16
17#include <linux/usb/hcd.h>
18
19#include "ehci.h"
15 20
16#define CAPLENGTH_MASK (0xff) 21#define CAPLENGTH_MASK (0xff)
17 22
18struct ehci_hcd_mv { 23#define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
19 struct usb_hcd *hcd;
20 24
25struct ehci_hcd_mv {
21 /* Which mode does this ehci running OTG/Host ? */ 26 /* Which mode does this ehci running OTG/Host ? */
22 int mode; 27 int mode;
23 28
@@ -66,7 +71,7 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
66static int mv_ehci_reset(struct usb_hcd *hcd) 71static int mv_ehci_reset(struct usb_hcd *hcd)
67{ 72{
68 struct device *dev = hcd->self.controller; 73 struct device *dev = hcd->self.controller;
69 struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev); 74 struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
70 int retval; 75 int retval;
71 76
72 if (ehci_mv == NULL) { 77 if (ehci_mv == NULL) {
@@ -83,46 +88,11 @@ static int mv_ehci_reset(struct usb_hcd *hcd)
83 return retval; 88 return retval;
84} 89}
85 90
86static const struct hc_driver mv_ehci_hc_driver = { 91static struct hc_driver __read_mostly ehci_platform_hc_driver;
87 .description = hcd_name, 92
88 .product_desc = "Marvell EHCI", 93static const struct ehci_driver_overrides platform_overrides __initconst = {
89 .hcd_priv_size = sizeof(struct ehci_hcd), 94 .reset = mv_ehci_reset,
90 95 .extra_priv_size = sizeof(struct ehci_hcd_mv),
91 /*
92 * generic hardware linkage
93 */
94 .irq = ehci_irq,
95 .flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
96
97 /*
98 * basic lifecycle operations
99 */
100 .reset = mv_ehci_reset,
101 .start = ehci_run,
102 .stop = ehci_stop,
103 .shutdown = ehci_shutdown,
104
105 /*
106 * managing i/o requests and associated device resources
107 */
108 .urb_enqueue = ehci_urb_enqueue,
109 .urb_dequeue = ehci_urb_dequeue,
110 .endpoint_disable = ehci_endpoint_disable,
111 .endpoint_reset = ehci_endpoint_reset,
112 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
113
114 /*
115 * scheduling support
116 */
117 .get_frame_number = ehci_get_frame,
118
119 /*
120 * root hub support
121 */
122 .hub_status_data = ehci_hub_status_data,
123 .hub_control = ehci_hub_control,
124 .bus_suspend = ehci_bus_suspend,
125 .bus_resume = ehci_bus_resume,
126}; 96};
127 97
128static int mv_ehci_probe(struct platform_device *pdev) 98static int mv_ehci_probe(struct platform_device *pdev)
@@ -143,19 +113,13 @@ static int mv_ehci_probe(struct platform_device *pdev)
143 if (usb_disabled()) 113 if (usb_disabled())
144 return -ENODEV; 114 return -ENODEV;
145 115
146 hcd = usb_create_hcd(&mv_ehci_hc_driver, &pdev->dev, "mv ehci"); 116 hcd = usb_create_hcd(&ehci_platform_hc_driver, &pdev->dev, "mv ehci");
147 if (!hcd) 117 if (!hcd)
148 return -ENOMEM; 118 return -ENOMEM;
149 119
150 ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL); 120 platform_set_drvdata(pdev, hcd);
151 if (ehci_mv == NULL) { 121 ehci_mv = hcd_to_ehci_hcd_mv(hcd);
152 retval = -ENOMEM;
153 goto err_put_hcd;
154 }
155
156 platform_set_drvdata(pdev, ehci_mv);
157 ehci_mv->pdata = pdata; 122 ehci_mv->pdata = pdata;
158 ehci_mv->hcd = hcd;
159 123
160 ehci_mv->clk = devm_clk_get(&pdev->dev, NULL); 124 ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
161 if (IS_ERR(ehci_mv->clk)) { 125 if (IS_ERR(ehci_mv->clk)) {
@@ -262,8 +226,8 @@ err_put_hcd:
262 226
263static int mv_ehci_remove(struct platform_device *pdev) 227static int mv_ehci_remove(struct platform_device *pdev)
264{ 228{
265 struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); 229 struct usb_hcd *hcd = platform_get_drvdata(pdev);
266 struct usb_hcd *hcd = ehci_mv->hcd; 230 struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
267 231
268 if (hcd->rh_registered) 232 if (hcd->rh_registered)
269 usb_remove_hcd(hcd); 233 usb_remove_hcd(hcd);
@@ -295,8 +259,8 @@ static const struct platform_device_id ehci_id_table[] = {
295 259
296static void mv_ehci_shutdown(struct platform_device *pdev) 260static void mv_ehci_shutdown(struct platform_device *pdev)
297{ 261{
298 struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); 262 struct usb_hcd *hcd = platform_get_drvdata(pdev);
299 struct usb_hcd *hcd = ehci_mv->hcd; 263 struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
300 264
301 if (!hcd->rh_registered) 265 if (!hcd->rh_registered)
302 return; 266 return;
@@ -315,3 +279,25 @@ static struct platform_driver ehci_mv_driver = {
315 }, 279 },
316 .id_table = ehci_id_table, 280 .id_table = ehci_id_table,
317}; 281};
282
283static int __init ehci_platform_init(void)
284{
285 if (usb_disabled())
286 return -ENODEV;
287
288 ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
289 return platform_driver_register(&ehci_mv_driver);
290}
291module_init(ehci_platform_init);
292
293static void __exit ehci_platform_cleanup(void)
294{
295 platform_driver_unregister(&ehci_mv_driver);
296}
297module_exit(ehci_platform_cleanup);
298
299MODULE_DESCRIPTION("Marvell EHCI driver");
300MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>");
301MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>");
302MODULE_ALIAS("mv-ehci");
303MODULE_LICENSE("GPL");