diff options
Diffstat (limited to 'drivers/usb/host/ehci-platform.c')
-rw-r--r-- | drivers/usb/host/ehci-platform.c | 102 |
1 files changed, 48 insertions, 54 deletions
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 764e0100b6f4..58fa0c90c7c7 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -18,9 +18,21 @@ | |||
18 | * | 18 | * |
19 | * Licensed under the GNU/GPL. See COPYING for details. | 19 | * Licensed under the GNU/GPL. See COPYING for details. |
20 | */ | 20 | */ |
21 | #include <linux/kernel.h> | ||
22 | #include <linux/hrtimer.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/module.h> | ||
21 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/usb.h> | ||
27 | #include <linux/usb/hcd.h> | ||
22 | #include <linux/usb/ehci_pdriver.h> | 28 | #include <linux/usb/ehci_pdriver.h> |
23 | 29 | ||
30 | #include "ehci.h" | ||
31 | |||
32 | #define DRIVER_DESC "EHCI generic platform driver" | ||
33 | |||
34 | static const char hcd_name[] = "ehci-platform"; | ||
35 | |||
24 | static int ehci_platform_reset(struct usb_hcd *hcd) | 36 | static int ehci_platform_reset(struct usb_hcd *hcd) |
25 | { | 37 | { |
26 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | 38 | struct platform_device *pdev = to_platform_device(hcd->self.controller); |
@@ -38,47 +50,18 @@ static int ehci_platform_reset(struct usb_hcd *hcd) | |||
38 | if (retval) | 50 | if (retval) |
39 | return retval; | 51 | return retval; |
40 | 52 | ||
41 | if (pdata->port_power_on) | 53 | if (pdata->no_io_watchdog) |
42 | ehci_port_power(ehci, 1); | 54 | ehci->need_io_watchdog = 0; |
43 | if (pdata->port_power_off) | ||
44 | ehci_port_power(ehci, 0); | ||
45 | |||
46 | return 0; | 55 | return 0; |
47 | } | 56 | } |
48 | 57 | ||
49 | static const struct hc_driver ehci_platform_hc_driver = { | 58 | static struct hc_driver __read_mostly ehci_platform_hc_driver; |
50 | .description = hcd_name, | ||
51 | .product_desc = "Generic Platform EHCI Controller", | ||
52 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
53 | |||
54 | .irq = ehci_irq, | ||
55 | .flags = HCD_MEMORY | HCD_USB2, | ||
56 | |||
57 | .reset = ehci_platform_reset, | ||
58 | .start = ehci_run, | ||
59 | .stop = ehci_stop, | ||
60 | .shutdown = ehci_shutdown, | ||
61 | |||
62 | .urb_enqueue = ehci_urb_enqueue, | ||
63 | .urb_dequeue = ehci_urb_dequeue, | ||
64 | .endpoint_disable = ehci_endpoint_disable, | ||
65 | .endpoint_reset = ehci_endpoint_reset, | ||
66 | 59 | ||
67 | .get_frame_number = ehci_get_frame, | 60 | static const struct ehci_driver_overrides platform_overrides __initdata = { |
68 | 61 | .reset = ehci_platform_reset, | |
69 | .hub_status_data = ehci_hub_status_data, | ||
70 | .hub_control = ehci_hub_control, | ||
71 | #if defined(CONFIG_PM) | ||
72 | .bus_suspend = ehci_bus_suspend, | ||
73 | .bus_resume = ehci_bus_resume, | ||
74 | #endif | ||
75 | .relinquish_port = ehci_relinquish_port, | ||
76 | .port_handed_over = ehci_port_handed_over, | ||
77 | |||
78 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
79 | }; | 62 | }; |
80 | 63 | ||
81 | static int __devinit ehci_platform_probe(struct platform_device *dev) | 64 | static int ehci_platform_probe(struct platform_device *dev) |
82 | { | 65 | { |
83 | struct usb_hcd *hcd; | 66 | struct usb_hcd *hcd; |
84 | struct resource *res_mem; | 67 | struct resource *res_mem; |
@@ -96,12 +79,12 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
96 | 79 | ||
97 | irq = platform_get_irq(dev, 0); | 80 | irq = platform_get_irq(dev, 0); |
98 | if (irq < 0) { | 81 | if (irq < 0) { |
99 | pr_err("no irq provided"); | 82 | dev_err(&dev->dev, "no irq provided"); |
100 | return irq; | 83 | return irq; |
101 | } | 84 | } |
102 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | 85 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); |
103 | if (!res_mem) { | 86 | if (!res_mem) { |
104 | pr_err("no memory recourse provided"); | 87 | dev_err(&dev->dev, "no memory resource provided"); |
105 | return -ENXIO; | 88 | return -ENXIO; |
106 | } | 89 | } |
107 | 90 | ||
@@ -121,29 +104,19 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
121 | hcd->rsrc_start = res_mem->start; | 104 | hcd->rsrc_start = res_mem->start; |
122 | hcd->rsrc_len = resource_size(res_mem); | 105 | hcd->rsrc_len = resource_size(res_mem); |
123 | 106 | ||
124 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 107 | hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem); |
125 | pr_err("controller already in use"); | ||
126 | err = -EBUSY; | ||
127 | goto err_put_hcd; | ||
128 | } | ||
129 | |||
130 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
131 | if (!hcd->regs) { | 108 | if (!hcd->regs) { |
132 | err = -ENOMEM; | 109 | err = -ENOMEM; |
133 | goto err_release_region; | 110 | goto err_put_hcd; |
134 | } | 111 | } |
135 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 112 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
136 | if (err) | 113 | if (err) |
137 | goto err_iounmap; | 114 | goto err_put_hcd; |
138 | 115 | ||
139 | platform_set_drvdata(dev, hcd); | 116 | platform_set_drvdata(dev, hcd); |
140 | 117 | ||
141 | return err; | 118 | return err; |
142 | 119 | ||
143 | err_iounmap: | ||
144 | iounmap(hcd->regs); | ||
145 | err_release_region: | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | err_put_hcd: | 120 | err_put_hcd: |
148 | usb_put_hcd(hcd); | 121 | usb_put_hcd(hcd); |
149 | err_power: | 122 | err_power: |
@@ -153,14 +126,12 @@ err_power: | |||
153 | return err; | 126 | return err; |
154 | } | 127 | } |
155 | 128 | ||
156 | static int __devexit ehci_platform_remove(struct platform_device *dev) | 129 | static int ehci_platform_remove(struct platform_device *dev) |
157 | { | 130 | { |
158 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 131 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
159 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; | 132 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; |
160 | 133 | ||
161 | usb_remove_hcd(hcd); | 134 | usb_remove_hcd(hcd); |
162 | iounmap(hcd->regs); | ||
163 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
164 | usb_put_hcd(hcd); | 135 | usb_put_hcd(hcd); |
165 | platform_set_drvdata(dev, NULL); | 136 | platform_set_drvdata(dev, NULL); |
166 | 137 | ||
@@ -225,7 +196,7 @@ static const struct dev_pm_ops ehci_platform_pm_ops = { | |||
225 | static struct platform_driver ehci_platform_driver = { | 196 | static struct platform_driver ehci_platform_driver = { |
226 | .id_table = ehci_platform_table, | 197 | .id_table = ehci_platform_table, |
227 | .probe = ehci_platform_probe, | 198 | .probe = ehci_platform_probe, |
228 | .remove = __devexit_p(ehci_platform_remove), | 199 | .remove = ehci_platform_remove, |
229 | .shutdown = usb_hcd_platform_shutdown, | 200 | .shutdown = usb_hcd_platform_shutdown, |
230 | .driver = { | 201 | .driver = { |
231 | .owner = THIS_MODULE, | 202 | .owner = THIS_MODULE, |
@@ -233,3 +204,26 @@ static struct platform_driver ehci_platform_driver = { | |||
233 | .pm = &ehci_platform_pm_ops, | 204 | .pm = &ehci_platform_pm_ops, |
234 | } | 205 | } |
235 | }; | 206 | }; |
207 | |||
208 | static int __init ehci_platform_init(void) | ||
209 | { | ||
210 | if (usb_disabled()) | ||
211 | return -ENODEV; | ||
212 | |||
213 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
214 | |||
215 | ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides); | ||
216 | return platform_driver_register(&ehci_platform_driver); | ||
217 | } | ||
218 | module_init(ehci_platform_init); | ||
219 | |||
220 | static void __exit ehci_platform_cleanup(void) | ||
221 | { | ||
222 | platform_driver_unregister(&ehci_platform_driver); | ||
223 | } | ||
224 | module_exit(ehci_platform_cleanup); | ||
225 | |||
226 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
227 | MODULE_AUTHOR("Hauke Mehrtens"); | ||
228 | MODULE_AUTHOR("Alan Stern"); | ||
229 | MODULE_LICENSE("GPL"); | ||