1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <linux/platform_device.h>
20#include <linux/signal.h>
21
22#include <mach/hardware.h>
23
24
25extern int usb_disabled(void);
26
27
28
29static void lh7a404_start_hc(struct platform_device *dev)
30{
31 printk(KERN_DEBUG __FILE__
32 ": starting LH7A404 OHCI USB Controller\n");
33
34
35
36
37
38 CSC_PWRCNT |= CSC_PWRCNT_USBH_EN;
39 udelay(1000);
40 USBH_CMDSTATUS = OHCI_HCR;
41
42 printk(KERN_DEBUG __FILE__
43 ": Clock to USB host has been enabled \n");
44}
45
46static void lh7a404_stop_hc(struct platform_device *dev)
47{
48 printk(KERN_DEBUG __FILE__
49 ": stopping LH7A404 OHCI USB Controller\n");
50
51 CSC_PWRCNT &= ~CSC_PWRCNT_USBH_EN;
52}
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70int usb_hcd_lh7a404_probe (const struct hc_driver *driver,
71 struct platform_device *dev)
72{
73 int retval;
74 struct usb_hcd *hcd;
75
76 if (dev->resource[1].flags != IORESOURCE_IRQ) {
77 pr_debug("resource[1] is not IORESOURCE_IRQ");
78 return -ENOMEM;
79 }
80
81 hcd = usb_create_hcd(driver, &dev->dev, "lh7a404");
82 if (!hcd)
83 return -ENOMEM;
84 hcd->rsrc_start = dev->resource[0].start;
85 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
86
87 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
88 pr_debug("request_mem_region failed");
89 retval = -EBUSY;
90 goto err1;
91 }
92
93 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
94 if (!hcd->regs) {
95 pr_debug("ioremap failed");
96 retval = -ENOMEM;
97 goto err2;
98 }
99
100 lh7a404_start_hc(dev);
101 ohci_hcd_init(hcd_to_ohci(hcd));
102
103 retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED);
104 if (retval == 0)
105 return retval;
106
107 lh7a404_stop_hc(dev);
108 iounmap(hcd->regs);
109 err2:
110 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
111 err1:
112 usb_put_hcd(hcd);
113 return retval;
114}
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130void usb_hcd_lh7a404_remove (struct usb_hcd *hcd, struct platform_device *dev)
131{
132 usb_remove_hcd(hcd);
133 lh7a404_stop_hc(dev);
134 iounmap(hcd->regs);
135 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
136 usb_put_hcd(hcd);
137}
138
139
140
141static int __devinit
142ohci_lh7a404_start (struct usb_hcd *hcd)
143{
144 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
145 int ret;
146
147 ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
148 if ((ret = ohci_init(ohci)) < 0)
149 return ret;
150
151 if ((ret = ohci_run (ohci)) < 0) {
152 err ("can't start %s", hcd->self.bus_name);
153 ohci_stop (hcd);
154 return ret;
155 }
156 return 0;
157}
158
159
160
161static const struct hc_driver ohci_lh7a404_hc_driver = {
162 .description = hcd_name,
163 .product_desc = "LH7A404 OHCI",
164 .hcd_priv_size = sizeof(struct ohci_hcd),
165
166
167
168
169 .irq = ohci_irq,
170 .flags = HCD_USB11 | HCD_MEMORY,
171
172
173
174
175 .start = ohci_lh7a404_start,
176 .stop = ohci_stop,
177 .shutdown = ohci_shutdown,
178
179
180
181
182 .urb_enqueue = ohci_urb_enqueue,
183 .urb_dequeue = ohci_urb_dequeue,
184 .endpoint_disable = ohci_endpoint_disable,
185
186
187
188
189 .get_frame_number = ohci_get_frame,
190
191
192
193
194 .hub_status_data = ohci_hub_status_data,
195 .hub_control = ohci_hub_control,
196#ifdef CONFIG_PM
197 .bus_suspend = ohci_bus_suspend,
198 .bus_resume = ohci_bus_resume,
199#endif
200 .start_port_reset = ohci_start_port_reset,
201};
202
203
204
205static int ohci_hcd_lh7a404_drv_probe(struct platform_device *pdev)
206{
207 int ret;
208
209 pr_debug ("In ohci_hcd_lh7a404_drv_probe");
210
211 if (usb_disabled())
212 return -ENODEV;
213
214 ret = usb_hcd_lh7a404_probe(&ohci_lh7a404_hc_driver, pdev);
215 return ret;
216}
217
218static int ohci_hcd_lh7a404_drv_remove(struct platform_device *pdev)
219{
220 struct usb_hcd *hcd = platform_get_drvdata(pdev);
221
222 usb_hcd_lh7a404_remove(hcd, pdev);
223 return 0;
224}
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241static struct platform_driver ohci_hcd_lh7a404_driver = {
242 .probe = ohci_hcd_lh7a404_drv_probe,
243 .remove = ohci_hcd_lh7a404_drv_remove,
244 .shutdown = usb_hcd_platform_shutdown,
245
246
247 .driver = {
248 .name = "lh7a404-ohci",
249 .owner = THIS_MODULE,
250 },
251};
252
253MODULE_ALIAS("platform:lh7a404-ohci");
254