1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* Realtek Semiconductor Corp.
*
* ehci-dwc.c: DWC USB host controller
*
* Tony Wu (tonywu@realtek.com)
* Jan. 10, 2009
*/
#include <linux/platform_device.h>
#define EHCI_DWC_NAME "dwc_ehci"
/* called during probe() after chip reset completes */
static int
ehci_dwc_setup (struct usb_hcd *hcd)
{
struct ehci_hcd *ehci = hcd_to_ehci (hcd);
int retval = 0;
retval = ehci_halt (ehci);
if (retval)
return retval;
/* data structure init */
retval = ehci_init (hcd);
if (retval)
return retval;
if (ehci_is_TDI (ehci))
ehci_reset (ehci);
#ifdef CONFIG_USB_SUSPEND
/* REVISIT: the controller works fine for wakeup iff the root hub
* itself is "globally" suspended, but usbcore currently doesn't
* understand such things.
*
* System suspend currently expects to be able to suspend the entire
* device tree, device-at-a-time. If we failed selective suspend
* reports, system suspend would fail; so the root hub code must claim
* success. That's lying to usbcore, and it matters for for runtime
* PM scenarios with selective suspend and remote wakeup...
*/
if (ehci->no_selective_suspend && device_can_wakeup (&pdev->dev))
ehci_warn (ehci, "selective suspend/wakeup unavailable\n");
#endif
ehci_port_power(ehci, 0);
return retval;
}
struct hc_driver ehci_dwc_hc_driver = {
.description = hcd_name,
.product_desc = "EHCI Host Controller",
.hcd_priv_size = sizeof (struct ehci_hcd),
/*
* generic hardware linkage
*/
.irq = ehci_irq,
.flags = HCD_MEMORY | HCD_USB2,
/*
* basic lifecycle operations
*/
.reset = ehci_dwc_setup,
.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,
/*
* scheduling support
*/
.get_frame_number = ehci_get_frame,
/*
* root hub support
*/
.hub_status_data = ehci_hub_status_data,
.hub_control = ehci_hub_control,
#ifdef CONFIG_PM
.bus_suspend = ehci_bus_suspend,
.bus_resume = ehci_bus_resume,
#endif
.relinquish_port = ehci_relinquish_port,
.port_handed_over = ehci_port_handed_over,
};
int
ehci_dwc_drv_probe (struct platform_device *pdev)
{
struct hc_driver *phcd;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct resource *res;
int retval;
u32 dwc_usb_irq;
phcd = &ehci_dwc_hc_driver;
res = platform_get_resource (pdev, IORESOURCE_IRQ, 0);
if (res == NULL)
{
printk (KERN_ERR __FILE__ ": get irq resource failed!\n");
retval = -ENOMEM;
return retval;
}
dwc_usb_irq = res->start;
hcd = usb_create_hcd (phcd, &pdev->dev, dev_name(&pdev->dev));
if (hcd == NULL)
{
retval = -ENOMEM;
return retval;
}
res = platform_get_resource (pdev, IORESOURCE_MEM, 0);
if (res == NULL)
{
printk (KERN_ERR __FILE__ ": get memory resource failed!\n");
retval = -ENOMEM;
return retval;
}
hcd->rsrc_start = res->start;
hcd->rsrc_len = res->end - res->start + 1;
if (request_mem_region (hcd->rsrc_start, hcd->rsrc_len, EHCI_DWC_NAME) == NULL)
{
printk (KERN_ERR __FILE__ ": request_mem_region failed\n");
retval = -ENOMEM;
return retval;
}
hcd->regs = (void *) ioremap(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs)
{
printk(KERN_ERR __FILE__ ": ioremap failed\n");
release_mem_region (hcd->rsrc_start, hcd->rsrc_len);
retval = -ENOMEM;
return retval;
}
ehci = hcd_to_ehci (hcd);
ehci->caps = hcd->regs;
ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase));
ehci->hcs_params = readl (&ehci->caps->hcs_params);
retval = usb_add_hcd (hcd, dwc_usb_irq, IRQF_SHARED);
if (retval != 0)
{
release_mem_region (hcd->rsrc_start, hcd->rsrc_len);
iounmap(hcd->regs);
}
return retval;
}
static int
ehci_dwc_drv_remove (struct platform_device *pdev)
{
struct usb_hcd *hcd;
hcd = platform_get_drvdata (pdev);
usb_remove_hcd (hcd);
if (hcd->driver->flags & HCD_MEMORY)
{
iounmap (hcd->regs);
release_mem_region (hcd->rsrc_start, hcd->rsrc_len);
}
else
release_region (hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd (hcd);
return 0;
}
struct platform_driver ehci_dwc_driver = {
.probe = ehci_dwc_drv_probe,
.remove = ehci_dwc_drv_remove,
.shutdown = usb_hcd_platform_shutdown,
.driver = {
.name = "dwc_ehci",
},
};
|