diff options
author | Manjunath Goudar <manjunath.goudar@linaro.org> | 2013-04-02 12:24:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-08 12:35:22 -0400 |
commit | 7675d6ba436f8439fc524ee0b42dc562cb1bc74e (patch) | |
tree | 96f73354c755b827e473479064f847ff02855764 | |
parent | a76dd463c58efa5dfd72c3dd41f5a76b196f7ab1 (diff) |
USB: EHCI: make ehci-spear a separate driver
Separate the SPEAr host controller driver from ehci-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;
however, note that other changes are still needed before SPEAr can be
booted with a multi-platform kernel, but they are queued in the
arm-soc tree for 3.10.
With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the SPEAr bus glue.
In V4 (arnd):
- renamed all 'struct spear_ehci' pointers from 'ehci' to the
less ambiguous 'sehci'.
- folded trivial spear_start_ehci/spear_stop_ehci functions into
callers.
- brought back initialization of ehci->caps.
In V3:
- Detailed commit message added here about why this patch is required.
- Eliminated ehci_spear_setup routine because hcd registers can
be directly set in the spear_ehci_hcd_drv_probe function.
- spear_overrides struct initialized.
- Converted to using .extra_priv_size for allocating spear_ehci,
and updated all users of that structure.
- to_spear_ehci() macro modified for spear_ehci.
In V2:
- Replaced spear as SPEAr everywhere, leaving functions/variables/config options.
Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.linux@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Shiraz Hashim <shiraz.hashim@st.com>
Cc: spear-devel@list.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/host/Kconfig | 8 | ||||
-rw-r--r-- | drivers/usb/host/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/ehci-spear.c | 115 |
4 files changed, 61 insertions, 69 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index c49a0b5da1f4..ae2c747b6e17 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -174,6 +174,14 @@ config USB_EHCI_HCD_ORION | |||
174 | on Marvell's mobile PXA and MMP SoC, see "EHCI support for | 174 | on Marvell's mobile PXA and MMP SoC, see "EHCI support for |
175 | Marvell PXA/MMP USB controller" for those. | 175 | Marvell PXA/MMP USB controller" for those. |
176 | 176 | ||
177 | config USB_EHCI_HCD_SPEAR | ||
178 | tristate "Support for ST SPEAr on-chip EHCI USB controller" | ||
179 | depends on USB_EHCI_HCD && PLAT_SPEAR | ||
180 | default y | ||
181 | ---help--- | ||
182 | Enables support for the on-chip EHCI controller on | ||
183 | ST SPEAr chips. | ||
184 | |||
177 | config USB_EHCI_MSM | 185 | config USB_EHCI_MSM |
178 | bool "Support for MSM on-chip EHCI USB controller" | 186 | bool "Support for MSM on-chip EHCI USB controller" |
179 | depends on USB_EHCI_HCD && ARCH_MSM | 187 | depends on USB_EHCI_HCD && ARCH_MSM |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 9492f50ea2f8..3e02471e0f50 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -29,6 +29,7 @@ obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o | |||
29 | obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o | 29 | obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o |
30 | obj-$(CONFIG_USB_EHCI_HCD_OMAP) += ehci-omap.o | 30 | obj-$(CONFIG_USB_EHCI_HCD_OMAP) += ehci-omap.o |
31 | obj-$(CONFIG_USB_EHCI_HCD_ORION) += ehci-orion.o | 31 | obj-$(CONFIG_USB_EHCI_HCD_ORION) += ehci-orion.o |
32 | obj-$(CONFIG_USB_EHCI_HCD_SPEAR) += ehci-spear.o | ||
32 | 33 | ||
33 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o | 34 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o |
34 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o | 35 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 1f97268bb5d6..c8c70a1fabc4 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1264,11 +1264,6 @@ MODULE_LICENSE ("GPL"); | |||
1264 | #define PLATFORM_DRIVER ehci_octeon_driver | 1264 | #define PLATFORM_DRIVER ehci_octeon_driver |
1265 | #endif | 1265 | #endif |
1266 | 1266 | ||
1267 | #ifdef CONFIG_PLAT_SPEAR | ||
1268 | #include "ehci-spear.c" | ||
1269 | #define PLATFORM_DRIVER spear_ehci_hcd_driver | ||
1270 | #endif | ||
1271 | |||
1272 | #ifdef CONFIG_USB_EHCI_MSM | 1267 | #ifdef CONFIG_USB_EHCI_MSM |
1273 | #include "ehci-msm.c" | 1268 | #include "ehci-msm.c" |
1274 | #define PLATFORM_DRIVER ehci_msm_driver | 1269 | #define PLATFORM_DRIVER ehci_msm_driver |
@@ -1315,6 +1310,7 @@ MODULE_LICENSE ("GPL"); | |||
1315 | !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \ | 1310 | !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \ |
1316 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \ | 1311 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \ |
1317 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_ORION) && \ | 1312 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_ORION) && \ |
1313 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_SPEAR) && \ | ||
1318 | !defined(PLATFORM_DRIVER) && \ | 1314 | !defined(PLATFORM_DRIVER) && \ |
1319 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ | 1315 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ |
1320 | !defined(OF_PLATFORM_DRIVER) && \ | 1316 | !defined(OF_PLATFORM_DRIVER) && \ |
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index 210bb676f22f..61ecfb3d52f5 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for EHCI HCD on SPEAR SOC | 2 | * Driver for EHCI HCD on SPEAr SOC |
3 | * | 3 | * |
4 | * Copyright (C) 2010 ST Micro Electronics, | 4 | * Copyright (C) 2010 ST Micro Electronics, |
5 | * Deepak Sikri <deepak.sikri@st.com> | 5 | * Deepak Sikri <deepak.sikri@st.com> |
@@ -12,71 +12,30 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/dma-mapping.h> | ||
16 | #include <linux/io.h> | ||
15 | #include <linux/jiffies.h> | 17 | #include <linux/jiffies.h> |
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
16 | #include <linux/of.h> | 20 | #include <linux/of.h> |
17 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
18 | #include <linux/pm.h> | 22 | #include <linux/pm.h> |
23 | #include <linux/usb.h> | ||
24 | #include <linux/usb/hcd.h> | ||
19 | 25 | ||
20 | struct spear_ehci { | 26 | #include "ehci.h" |
21 | struct ehci_hcd ehci; | ||
22 | struct clk *clk; | ||
23 | }; | ||
24 | |||
25 | #define to_spear_ehci(hcd) (struct spear_ehci *)hcd_to_ehci(hcd) | ||
26 | 27 | ||
27 | static void spear_start_ehci(struct spear_ehci *ehci) | 28 | #define DRIVER_DESC "EHCI SPEAr driver" |
28 | { | ||
29 | clk_prepare_enable(ehci->clk); | ||
30 | } | ||
31 | 29 | ||
32 | static void spear_stop_ehci(struct spear_ehci *ehci) | 30 | static const char hcd_name[] = "SPEAr-ehci"; |
33 | { | ||
34 | clk_disable_unprepare(ehci->clk); | ||
35 | } | ||
36 | 31 | ||
37 | static int ehci_spear_setup(struct usb_hcd *hcd) | 32 | struct spear_ehci { |
38 | { | 33 | struct clk *clk; |
39 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 34 | }; |
40 | |||
41 | /* registers start at offset 0x0 */ | ||
42 | ehci->caps = hcd->regs; | ||
43 | 35 | ||
44 | return ehci_setup(hcd); | 36 | #define to_spear_ehci(hcd) (struct spear_ehci *)(hcd_to_ehci(hcd)->priv) |
45 | } | ||
46 | 37 | ||
47 | static const struct hc_driver ehci_spear_hc_driver = { | 38 | static struct hc_driver __read_mostly ehci_spear_hc_driver; |
48 | .description = hcd_name, | ||
49 | .product_desc = "SPEAr EHCI", | ||
50 | .hcd_priv_size = sizeof(struct spear_ehci), | ||
51 | |||
52 | /* generic hardware linkage */ | ||
53 | .irq = ehci_irq, | ||
54 | .flags = HCD_MEMORY | HCD_USB2, | ||
55 | |||
56 | /* basic lifecycle operations */ | ||
57 | .reset = ehci_spear_setup, | ||
58 | .start = ehci_run, | ||
59 | .stop = ehci_stop, | ||
60 | .shutdown = ehci_shutdown, | ||
61 | |||
62 | /* managing i/o requests and associated device resources */ | ||
63 | .urb_enqueue = ehci_urb_enqueue, | ||
64 | .urb_dequeue = ehci_urb_dequeue, | ||
65 | .endpoint_disable = ehci_endpoint_disable, | ||
66 | .endpoint_reset = ehci_endpoint_reset, | ||
67 | |||
68 | /* scheduling support */ | ||
69 | .get_frame_number = ehci_get_frame, | ||
70 | |||
71 | /* root hub support */ | ||
72 | .hub_status_data = ehci_hub_status_data, | ||
73 | .hub_control = ehci_hub_control, | ||
74 | .bus_suspend = ehci_bus_suspend, | ||
75 | .bus_resume = ehci_bus_resume, | ||
76 | .relinquish_port = ehci_relinquish_port, | ||
77 | .port_handed_over = ehci_port_handed_over, | ||
78 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
79 | }; | ||
80 | 39 | ||
81 | #ifdef CONFIG_PM_SLEEP | 40 | #ifdef CONFIG_PM_SLEEP |
82 | static int ehci_spear_drv_suspend(struct device *dev) | 41 | static int ehci_spear_drv_suspend(struct device *dev) |
@@ -104,7 +63,7 @@ static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32); | |||
104 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | 63 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) |
105 | { | 64 | { |
106 | struct usb_hcd *hcd ; | 65 | struct usb_hcd *hcd ; |
107 | struct spear_ehci *ehci; | 66 | struct spear_ehci *sehci; |
108 | struct resource *res; | 67 | struct resource *res; |
109 | struct clk *usbh_clk; | 68 | struct clk *usbh_clk; |
110 | const struct hc_driver *driver = &ehci_spear_hc_driver; | 69 | const struct hc_driver *driver = &ehci_spear_hc_driver; |
@@ -161,10 +120,13 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
161 | goto err_put_hcd; | 120 | goto err_put_hcd; |
162 | } | 121 | } |
163 | 122 | ||
164 | ehci = (struct spear_ehci *)hcd_to_ehci(hcd); | 123 | sehci = to_spear_ehci(hcd); |
165 | ehci->clk = usbh_clk; | 124 | sehci->clk = usbh_clk; |
125 | |||
126 | /* registers start at offset 0x0 */ | ||
127 | hcd_to_ehci(hcd)->caps = hcd->regs; | ||
166 | 128 | ||
167 | spear_start_ehci(ehci); | 129 | clk_prepare_enable(sehci->clk); |
168 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 130 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
169 | if (retval) | 131 | if (retval) |
170 | goto err_stop_ehci; | 132 | goto err_stop_ehci; |
@@ -172,7 +134,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
172 | return retval; | 134 | return retval; |
173 | 135 | ||
174 | err_stop_ehci: | 136 | err_stop_ehci: |
175 | spear_stop_ehci(ehci); | 137 | clk_disable_unprepare(sehci->clk); |
176 | err_put_hcd: | 138 | err_put_hcd: |
177 | usb_put_hcd(hcd); | 139 | usb_put_hcd(hcd); |
178 | fail: | 140 | fail: |
@@ -184,7 +146,7 @@ fail: | |||
184 | static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) | 146 | static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) |
185 | { | 147 | { |
186 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 148 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
187 | struct spear_ehci *ehci_p = to_spear_ehci(hcd); | 149 | struct spear_ehci *sehci = to_spear_ehci(hcd); |
188 | 150 | ||
189 | if (!hcd) | 151 | if (!hcd) |
190 | return 0; | 152 | return 0; |
@@ -192,8 +154,8 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) | |||
192 | BUG(); | 154 | BUG(); |
193 | usb_remove_hcd(hcd); | 155 | usb_remove_hcd(hcd); |
194 | 156 | ||
195 | if (ehci_p->clk) | 157 | if (sehci->clk) |
196 | spear_stop_ehci(ehci_p); | 158 | clk_disable_unprepare(sehci->clk); |
197 | usb_put_hcd(hcd); | 159 | usb_put_hcd(hcd); |
198 | 160 | ||
199 | return 0; | 161 | return 0; |
@@ -216,4 +178,29 @@ static struct platform_driver spear_ehci_hcd_driver = { | |||
216 | } | 178 | } |
217 | }; | 179 | }; |
218 | 180 | ||
181 | static const struct ehci_driver_overrides spear_overrides __initdata = { | ||
182 | .extra_priv_size = sizeof(struct spear_ehci), | ||
183 | }; | ||
184 | |||
185 | static int __init ehci_spear_init(void) | ||
186 | { | ||
187 | if (usb_disabled()) | ||
188 | return -ENODEV; | ||
189 | |||
190 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
191 | |||
192 | ehci_init_driver(&ehci_spear_hc_driver, &spear_overrides); | ||
193 | return platform_driver_register(&spear_ehci_hcd_driver); | ||
194 | } | ||
195 | module_init(ehci_spear_init); | ||
196 | |||
197 | static void __exit ehci_spear_cleanup(void) | ||
198 | { | ||
199 | platform_driver_unregister(&spear_ehci_hcd_driver); | ||
200 | } | ||
201 | module_exit(ehci_spear_cleanup); | ||
202 | |||
203 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
219 | MODULE_ALIAS("platform:spear-ehci"); | 204 | MODULE_ALIAS("platform:spear-ehci"); |
205 | MODULE_AUTHOR("Deepak Sikri"); | ||
206 | MODULE_LICENSE("GPL"); | ||