1 #ifndef __LINUX_ETRAX_USB_H
2 #define __LINUX_ETRAX_USB_H
4 #include <linux/types.h>
5 #include <linux/list.h>
9 volatile __u16 command
;
10 volatile unsigned long next
;
11 volatile unsigned long buf
;
12 volatile __u16 hw_len
;
13 volatile __u16 status
;
17 volatile __u16 sw_len
;
18 volatile __u16 command
;
19 volatile unsigned long next
;
20 volatile unsigned long buf
;
24 volatile __u16 hw_len
;
25 volatile __u16 command
;
26 volatile unsigned long sub
;
27 volatile unsigned long next
;
31 /* Root Hub port status struct */
33 volatile __u16 wPortChange
[2];
34 volatile __u16 wPortStatusPrev
[2];
45 /* Endpoint HC private data description */
46 struct crisv10_ep_priv
{
50 /* Additional software state info for a USB Controller epid */
52 __u8 inuse
; /* !0 = setup in Etrax and used for a endpoint */
53 __u8 disabled
; /* !0 = Temporarly disabled to avoid resubmission */
54 __u8 type
; /* Setup as: PIPE_BULK, PIPE_CONTROL ... */
55 __u8 out_traffic
; /* !0 = This epid is for out traffic */
58 /* Struct to hold information of scheduled later URB completion */
59 struct urb_later_data
{
60 struct delayed_work dws
;
72 } crisv10_urb_state_t
;
75 struct crisv10_urb_priv
{
76 /* Sequence number for this URB. Every new submited URB gets this from
77 a incrementing counter. Used when a URB is scheduled for later finish to
78 be sure that the intended URB hasn't already been completed (device
79 drivers has a tendency to reuse URBs once they are completed, causing us
80 to not be able to single old ones out only based on the URB pointer.) */
83 /* The first_sb field is used for freeing all SB descriptors belonging
84 to an urb. The corresponding ep descriptor's sub pointer cannot be
85 used for this since the DMA advances the sub pointer as it processes
87 struct USB_SB_Desc
*first_sb
;
89 /* The last_sb field referes to the last SB descriptor that belongs to
90 this urb. This is important to know so we can free the SB descriptors
91 that ranges between first_sb and last_sb. */
92 struct USB_SB_Desc
*last_sb
;
94 /* The rx_offset field is used in ctrl and bulk traffic to keep track
95 of the offset in the urb's transfer_buffer where incoming data should be
99 /* Counter used in isochronous transfers to keep track of the
100 number of packets received/transmitted. */
101 __u32 isoc_packet_counter
;
103 /* Flag that marks if this Isoc Out URB has finished it's transfer. Used
104 because several URBs can be finished before list is processed */
107 /* This field is used to pass information about the urb's current state
108 between the various interrupt handlers (thus marked volatile). */
109 volatile crisv10_urb_state_t urb_state
;
111 /* In Ctrl transfers consist of (at least) 3 packets: SETUP, IN and ZOUT.
112 When DMA8 sub-channel 2 has processed the SB list for this sequence we
113 get a interrupt. We also get a interrupt for In transfers and which
114 one of these interrupts that comes first depends of data size and device.
115 To be sure that we have got both interrupts before we complete the URB
116 we have these to flags that shows which part that has completed.
117 We can then check when we get one of the interrupts that if the other has
118 occured it's safe for us to complete the URB, otherwise we set appropriate
119 flag and do the completion when we get the other interrupt. */
120 volatile unsigned char ctrl_zout_done
;
121 volatile unsigned char ctrl_rx_done
;
123 /* Connection between the submitted urb and ETRAX epid number */
126 /* The rx_data_list field is used for periodic traffic, to hold
127 received data for later processing in the the complete_urb functions,
128 where the data us copied to the urb's transfer_buffer. Basically, we
129 use this intermediate storage because we don't know when it's safe to
130 reuse the transfer_buffer (FIXME?). */
131 struct list_head rx_data_list
;
134 /* The interval time rounded up to closest 2^N */
137 /* Pool of EP descriptors needed if it's a INTR transfer.
138 Amount of EPs in pool correspons to how many INTR that should
139 be inserted in TxIntrEPList (max 128, defined by MAX_INTR_INTERVAL) */
140 struct USB_EP_Desc
* intr_ep_pool
[128];
142 /* The mount of EPs allocated for this INTR URB */
143 int intr_ep_pool_length
;
145 /* Pointer to info struct if URB is scheduled to be finished later */
146 struct urb_later_data
* later_data
;
148 /* Allocated bandwidth for isochronous and interrupt traffic */
153 /* This struct is for passing data from the top half to the bottom half irq
155 struct crisv10_irq_reg
{
157 __u32 r_usb_epid_attn
;
159 __u16 r_usb_rh_port_status_1
;
160 __u16 r_usb_rh_port_status_2
;
161 __u32 r_usb_irq_mask_read
;
162 __u32 r_usb_fm_number
;
163 struct work_struct usb_bh
;
167 /* This struct is for passing data from the isoc top half to the isoc bottom
169 struct crisv10_isoc_complete_data
{
172 struct work_struct usb_bh
;
175 /* Entry item for URB lists for each endpint */
176 typedef struct urb_entry
179 struct list_head list
;
182 /* ---------------------------------------------------------------------------
184 ------------------------------------------------------------------------- */
185 /* destination of request */
186 #define RH_INTERFACE 0x01
187 #define RH_ENDPOINT 0x02
188 #define RH_OTHER 0x03
190 #define RH_CLASS 0x20
191 #define RH_VENDOR 0x40
193 /* Requests: bRequest << 8 | bmRequestType */
194 #define RH_GET_STATUS 0x0080
195 #define RH_CLEAR_FEATURE 0x0100
196 #define RH_SET_FEATURE 0x0300
197 #define RH_SET_ADDRESS 0x0500
198 #define RH_GET_DESCRIPTOR 0x0680
199 #define RH_SET_DESCRIPTOR 0x0700
200 #define RH_GET_CONFIGURATION 0x0880
201 #define RH_SET_CONFIGURATION 0x0900
202 #define RH_GET_STATE 0x0280
203 #define RH_GET_INTERFACE 0x0A80
204 #define RH_SET_INTERFACE 0x0B00
205 #define RH_SYNC_FRAME 0x0C80
206 /* Our Vendor Specific Request */
207 #define RH_SET_EP 0x2000
210 /* Hub port features */
211 #define RH_PORT_CONNECTION 0x00
212 #define RH_PORT_ENABLE 0x01
213 #define RH_PORT_SUSPEND 0x02
214 #define RH_PORT_OVER_CURRENT 0x03
215 #define RH_PORT_RESET 0x04
216 #define RH_PORT_POWER 0x08
217 #define RH_PORT_LOW_SPEED 0x09
218 #define RH_C_PORT_CONNECTION 0x10
219 #define RH_C_PORT_ENABLE 0x11
220 #define RH_C_PORT_SUSPEND 0x12
221 #define RH_C_PORT_OVER_CURRENT 0x13
222 #define RH_C_PORT_RESET 0x14
225 #define RH_C_HUB_LOCAL_POWER 0x00
226 #define RH_C_HUB_OVER_CURRENT 0x01
228 #define RH_DEVICE_REMOTE_WAKEUP 0x00
229 #define RH_ENDPOINT_STALL 0x01
231 /* Our Vendor Specific feature */
232 #define RH_REMOVE_EP 0x00
236 #define RH_REQ_ERR -1
239 /* Field definitions for */
241 #define USB_IN_command__eol__BITNR 0 /* command macros */
242 #define USB_IN_command__eol__WIDTH 1
243 #define USB_IN_command__eol__no 0
244 #define USB_IN_command__eol__yes 1
246 #define USB_IN_command__intr__BITNR 3
247 #define USB_IN_command__intr__WIDTH 1
248 #define USB_IN_command__intr__no 0
249 #define USB_IN_command__intr__yes 1
251 #define USB_IN_status__eop__BITNR 1 /* status macros. */
252 #define USB_IN_status__eop__WIDTH 1
253 #define USB_IN_status__eop__no 0
254 #define USB_IN_status__eop__yes 1
256 #define USB_IN_status__eot__BITNR 5
257 #define USB_IN_status__eot__WIDTH 1
258 #define USB_IN_status__eot__no 0
259 #define USB_IN_status__eot__yes 1
261 #define USB_IN_status__error__BITNR 6
262 #define USB_IN_status__error__WIDTH 1
263 #define USB_IN_status__error__no 0
264 #define USB_IN_status__error__yes 1
266 #define USB_IN_status__nodata__BITNR 7
267 #define USB_IN_status__nodata__WIDTH 1
268 #define USB_IN_status__nodata__no 0
269 #define USB_IN_status__nodata__yes 1
271 #define USB_IN_status__epid__BITNR 8
272 #define USB_IN_status__epid__WIDTH 5
274 #define USB_EP_command__eol__BITNR 0
275 #define USB_EP_command__eol__WIDTH 1
276 #define USB_EP_command__eol__no 0
277 #define USB_EP_command__eol__yes 1
279 #define USB_EP_command__eof__BITNR 1
280 #define USB_EP_command__eof__WIDTH 1
281 #define USB_EP_command__eof__no 0
282 #define USB_EP_command__eof__yes 1
284 #define USB_EP_command__intr__BITNR 3
285 #define USB_EP_command__intr__WIDTH 1
286 #define USB_EP_command__intr__no 0
287 #define USB_EP_command__intr__yes 1
289 #define USB_EP_command__enable__BITNR 4
290 #define USB_EP_command__enable__WIDTH 1
291 #define USB_EP_command__enable__no 0
292 #define USB_EP_command__enable__yes 1
294 #define USB_EP_command__hw_valid__BITNR 5
295 #define USB_EP_command__hw_valid__WIDTH 1
296 #define USB_EP_command__hw_valid__no 0
297 #define USB_EP_command__hw_valid__yes 1
299 #define USB_EP_command__epid__BITNR 8
300 #define USB_EP_command__epid__WIDTH 5
302 #define USB_SB_command__eol__BITNR 0 /* command macros. */
303 #define USB_SB_command__eol__WIDTH 1
304 #define USB_SB_command__eol__no 0
305 #define USB_SB_command__eol__yes 1
307 #define USB_SB_command__eot__BITNR 1
308 #define USB_SB_command__eot__WIDTH 1
309 #define USB_SB_command__eot__no 0
310 #define USB_SB_command__eot__yes 1
312 #define USB_SB_command__intr__BITNR 3
313 #define USB_SB_command__intr__WIDTH 1
314 #define USB_SB_command__intr__no 0
315 #define USB_SB_command__intr__yes 1
317 #define USB_SB_command__tt__BITNR 4
318 #define USB_SB_command__tt__WIDTH 2
319 #define USB_SB_command__tt__zout 0
320 #define USB_SB_command__tt__in 1
321 #define USB_SB_command__tt__out 2
322 #define USB_SB_command__tt__setup 3
325 #define USB_SB_command__rem__BITNR 8
326 #define USB_SB_command__rem__WIDTH 6
328 #define USB_SB_command__full__BITNR 6
329 #define USB_SB_command__full__WIDTH 1
330 #define USB_SB_command__full__no 0
331 #define USB_SB_command__full__yes 1