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
31struct usb_hcd {
32
33
34
35
36 struct usb_bus *bus;
37 struct list_head hcd_list;
38
39 const char *product_desc;
40 const char *description;
41
42 struct timer_list rh_timer;
43 struct list_head dev_list;
44 struct tq_struct work;
45
46
47
48
49 struct hc_driver *driver;
50 int irq;
51 void *regs;
52
53#ifdef CONFIG_PCI
54
55 struct pci_dev *pdev;
56 int region;
57 u32 pci_state [16];
58 atomic_t resume_count;
59#endif
60
61 int state;
62# define __ACTIVE 0x01
63# define __SLEEPY 0x02
64# define __SUSPEND 0x04
65# define __TRANSIENT 0x80
66
67# define USB_STATE_HALT 0
68# define USB_STATE_RUNNING (__ACTIVE)
69# define USB_STATE_READY (__ACTIVE|__SLEEPY)
70# define USB_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE)
71# define USB_STATE_RESUMING (__SUSPEND|__TRANSIENT)
72# define USB_STATE_SUSPENDED (__SUSPEND)
73
74#define HCD_IS_RUNNING(state) ((state) & __ACTIVE)
75#define HCD_IS_SUSPENDED(state) ((state) & __SUSPEND)
76
77
78
79
80
81
82};
83
84struct hcd_dev {
85 struct list_head dev_list;
86 struct list_head urb_list;
87
88
89 void *ep[32];
90};
91
92
93
94struct hcd_timeout {
95 struct list_head timeout_list;
96 struct timer_list timer;
97};
98
99
100
101
102
103struct hc_driver {
104 const char *description;
105
106
107 void (*irq) (struct usb_hcd *hcd, struct pt_regs *regs);
108
109 int flags;
110#define HCD_MEMORY 0x0001
111#define HCD_USB11 0x0010
112#define HCD_USB2 0x0020
113
114
115 int (*start) (struct usb_hcd *hcd);
116
117
118 int (*suspend) (struct usb_hcd *hcd, u32 state);
119
120
121 int (*resume) (struct usb_hcd *hcd);
122
123
124 void (*stop) (struct usb_hcd *hcd);
125
126
127 int (*get_frame_number) (struct usb_hcd *hcd);
128
129
130
131
132 struct usb_hcd *(*hcd_alloc) (void);
133 void (*hcd_free) (struct usb_hcd *hcd);
134
135
136 int (*urb_enqueue) (struct usb_hcd *hcd, struct urb *urb,
137 int mem_flags);
138 int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
139
140
141
142 void (*free_config) (struct usb_hcd *hcd,
143 struct usb_device *dev);
144
145
146 int (*hub_status_data) (struct usb_hcd *hcd, char *buf);
147 int (*hub_control) (struct usb_hcd *hcd,
148 u16 typeReq, u16 wValue, u16 wIndex,
149 char *buf, u16 wLength);
150};
151
152extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb,
153 struct pt_regs *regs);
154
155#ifdef CONFIG_PCI
156
157struct pci_device_id;
158extern int usb_hcd_pci_probe (struct pci_dev *dev,
159 const struct pci_device_id *id);
160extern void usb_hcd_pci_remove (struct pci_dev *dev);
161
162#ifdef CONFIG_PM
163
164
165extern int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state);
166extern int usb_hcd_pci_resume (struct pci_dev *dev);
167
168#endif
169
170#endif
171
172
173
174
175
176
177
178#include "hub.h"
179
180
181#define DeviceRequest \
182 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
183#define DeviceOutRequest \
184 ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
185
186#define InterfaceRequest \
187 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
188
189#define EndpointRequest \
190 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
191#define EndpointOutRequest \
192 ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
193
194
195#define DEVICE_REMOTE_WAKEUP 1
196#define ENDPOINT_HALT 0
197
198
199
200#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
201#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
202#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
203#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)
204#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)
205#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)
206#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
207
208
209
210
211
212
213
214#define FRAME_TIME_USECS 1000L
215#define BitTime(bytecount) (7 * 8 * bytecount / 6)
216
217
218
219
220#define NS_TO_US(ns) ((ns + 500L) / 1000L)
221
222
223extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb,
224 int bustime, int isoc);
225extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
226 int isoc);
227
228
229
230
231#define BW_HOST_DELAY 1000L
232#define BW_HUB_LS_SETUP 333L
233
234
235#define FRAME_TIME_BITS 12000L
236#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L)
237#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L)
238
239extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
240
241
242
243
244
245
246#define USB2_HOST_DELAY 5
247#define HS_USECS(bytes) NS_TO_US ( ((55 * 8 * 2083)/1000) \
248 + ((2083UL * (3167 + BitTime (bytes)))/1000) \
249 + USB2_HOST_DELAY)
250#define HS_USECS_ISO(bytes) NS_TO_US ( ((long)(38 * 8 * 2.083)) \
251 + ((2083UL * (3167 + BitTime (bytes)))/1000) \
252 + USB2_HOST_DELAY)
253
254extern long usb_calc_bus_time (int speed, int is_input,
255 int isoc, int bytecount);
256
257
258
259
260
261#define bitmap DeviceRemovable
262
263
264
265
266
267
268#define RUN_CONTEXT (in_irq () ? "in_irq" \
269 : (in_interrupt () ? "in_interrupt" : "can sleep"))
270
271
272
273#ifndef container_of
274#define container_of list_entry
275#endif
276
277#define usb_get_urb(x) (x)
278#define usb_put_urb(x)
279
280static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd)
281 { return hcd->bus; }
282
283static inline void
284usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe)
285 { }
286
287#define URB_ZERO_PACKET USB_ZERO_PACKET
288#define URB_ISO_ASAP USB_ISO_ASAP
289