1 #ifndef __LINUX_ETRAX_USB_H
2 #define __LINUX_ETRAX_USB_H
4 #include <linux/types.h>
5 #include <linux/list.h>
7 typedef struct USB_IN_Desc {
9 volatile __u16 command;
10 volatile unsigned long next;
11 volatile unsigned long buf;
12 volatile __u16 hw_len;
13 volatile __u16 status;
16 typedef struct USB_SB_Desc {
17 volatile __u16 sw_len;
18 volatile __u16 command;
19 volatile unsigned long next;
20 volatile unsigned long buf;
24 typedef struct USB_EP_Desc {
25 volatile __u16 hw_len;
26 volatile __u16 command;
27 volatile unsigned long sub;
28 volatile unsigned long next;
32 struct virt_root_hub {
39 struct timer_list rh_int_timer;
40 volatile __u16 wPortChange_1;
41 volatile __u16 wPortChange_2;
42 volatile __u16 prev_wPortStatus_1;
43 volatile __u16 prev_wPortStatus_2;
46 struct etrax_usb_intr_traffic {
49 struct wait_queue *wq;
52 typedef struct etrax_usb_hc {
54 struct virt_root_hub rh;
55 struct etrax_usb_intr_traffic intr;
62 } etrax_usb_urb_state_t;
66 typedef struct etrax_usb_urb_priv {
67 /* The first_sb field is used for freeing all SB descriptors belonging
68 to an urb. The corresponding ep descriptor's sub pointer cannot be
69 used for this since the DMA advances the sub pointer as it processes
71 USB_SB_Desc_t *first_sb;
72 /* The last_sb field referes to the last SB descriptor that belongs to
73 this urb. This is important to know so we can free the SB descriptors
74 that ranges between first_sb and last_sb. */
75 USB_SB_Desc_t *last_sb;
77 /* The rx_offset field is used in ctrl and bulk traffic to keep track
78 of the offset in the urb's transfer_buffer where incoming data should be
82 /* Counter used in isochronous transfers to keep track of the
83 number of packets received/transmitted. */
84 __u32 isoc_packet_counter;
86 /* This field is used to pass information about the urb's current state between
87 the various interrupt handlers (thus marked volatile). */
88 volatile etrax_usb_urb_state_t urb_state;
90 /* Connection between the submitted urb and ETRAX epid number */
93 /* The rx_data_list field is used for periodic traffic, to hold
94 received data for later processing in the the complete_urb functions,
95 where the data us copied to the urb's transfer_buffer. Basically, we
96 use this intermediate storage because we don't know when it's safe to
97 reuse the transfer_buffer (FIXME?). */
98 struct list_head rx_data_list;
101 /* This struct is for passing data from the top half to the bottom half. */
102 typedef struct usb_interrupt_registers
105 __u32 r_usb_epid_attn;
107 __u16 r_usb_rh_port_status_1;
108 __u16 r_usb_rh_port_status_2;
109 __u32 r_usb_irq_mask_read;
110 __u32 r_usb_fm_number;
111 struct tq_struct usb_bh;
112 } usb_interrupt_registers_t;
114 /* This struct holds data we get from the rx descriptors for DMA channel 9
115 for periodic traffic (intr and isoc). */
116 typedef struct rx_data
120 struct list_head list;
123 typedef struct urb_entry
126 struct list_head list;
129 /* ---------------------------------------------------------------------------
131 ------------------------------------------------------------------------- */
132 /* destination of request */
133 #define RH_INTERFACE 0x01
134 #define RH_ENDPOINT 0x02
135 #define RH_OTHER 0x03
137 #define RH_CLASS 0x20
138 #define RH_VENDOR 0x40
140 /* Requests: bRequest << 8 | bmRequestType */
141 #define RH_GET_STATUS 0x0080
142 #define RH_CLEAR_FEATURE 0x0100
143 #define RH_SET_FEATURE 0x0300
144 #define RH_SET_ADDRESS 0x0500
145 #define RH_GET_DESCRIPTOR 0x0680
146 #define RH_SET_DESCRIPTOR 0x0700
147 #define RH_GET_CONFIGURATION 0x0880
148 #define RH_SET_CONFIGURATION 0x0900
149 #define RH_GET_STATE 0x0280
150 #define RH_GET_INTERFACE 0x0A80
151 #define RH_SET_INTERFACE 0x0B00
152 #define RH_SYNC_FRAME 0x0C80
153 /* Our Vendor Specific Request */
154 #define RH_SET_EP 0x2000
157 /* Hub port features */
158 #define RH_PORT_CONNECTION 0x00
159 #define RH_PORT_ENABLE 0x01
160 #define RH_PORT_SUSPEND 0x02
161 #define RH_PORT_OVER_CURRENT 0x03
162 #define RH_PORT_RESET 0x04
163 #define RH_PORT_POWER 0x08
164 #define RH_PORT_LOW_SPEED 0x09
165 #define RH_C_PORT_CONNECTION 0x10
166 #define RH_C_PORT_ENABLE 0x11
167 #define RH_C_PORT_SUSPEND 0x12
168 #define RH_C_PORT_OVER_CURRENT 0x13
169 #define RH_C_PORT_RESET 0x14
172 #define RH_C_HUB_LOCAL_POWER 0x00
173 #define RH_C_HUB_OVER_CURRENT 0x01
175 #define RH_DEVICE_REMOTE_WAKEUP 0x00
176 #define RH_ENDPOINT_STALL 0x01
178 /* Our Vendor Specific feature */
179 #define RH_REMOVE_EP 0x00
183 #define RH_REQ_ERR -1
186 /* Field definitions for */
188 #define USB_IN_command__eol__BITNR 0 /* command macros */
189 #define USB_IN_command__eol__WIDTH 1
190 #define USB_IN_command__eol__no 0
191 #define USB_IN_command__eol__yes 1
193 #define USB_IN_command__intr__BITNR 3
194 #define USB_IN_command__intr__WIDTH 1
195 #define USB_IN_command__intr__no 0
196 #define USB_IN_command__intr__yes 1
198 #define USB_IN_status__eop__BITNR 1 /* status macros. */
199 #define USB_IN_status__eop__WIDTH 1
200 #define USB_IN_status__eop__no 0
201 #define USB_IN_status__eop__yes 1
203 #define USB_IN_status__eot__BITNR 5
204 #define USB_IN_status__eot__WIDTH 1
205 #define USB_IN_status__eot__no 0
206 #define USB_IN_status__eot__yes 1
208 #define USB_IN_status__error__BITNR 6
209 #define USB_IN_status__error__WIDTH 1
210 #define USB_IN_status__error__no 0
211 #define USB_IN_status__error__yes 1
213 #define USB_IN_status__nodata__BITNR 7
214 #define USB_IN_status__nodata__WIDTH 1
215 #define USB_IN_status__nodata__no 0
216 #define USB_IN_status__nodata__yes 1
218 #define USB_IN_status__epid__BITNR 8
219 #define USB_IN_status__epid__WIDTH 5
221 #define USB_EP_command__eol__BITNR 0
222 #define USB_EP_command__eol__WIDTH 1
223 #define USB_EP_command__eol__no 0
224 #define USB_EP_command__eol__yes 1
226 #define USB_EP_command__eof__BITNR 1
227 #define USB_EP_command__eof__WIDTH 1
228 #define USB_EP_command__eof__no 0
229 #define USB_EP_command__eof__yes 1
231 #define USB_EP_command__intr__BITNR 3
232 #define USB_EP_command__intr__WIDTH 1
233 #define USB_EP_command__intr__no 0
234 #define USB_EP_command__intr__yes 1
236 #define USB_EP_command__enable__BITNR 4
237 #define USB_EP_command__enable__WIDTH 1
238 #define USB_EP_command__enable__no 0
239 #define USB_EP_command__enable__yes 1
241 #define USB_EP_command__hw_valid__BITNR 5
242 #define USB_EP_command__hw_valid__WIDTH 1
243 #define USB_EP_command__hw_valid__no 0
244 #define USB_EP_command__hw_valid__yes 1
246 #define USB_EP_command__epid__BITNR 8
247 #define USB_EP_command__epid__WIDTH 5
249 #define USB_SB_command__eol__BITNR 0 /* command macros. */
250 #define USB_SB_command__eol__WIDTH 1
251 #define USB_SB_command__eol__no 0
252 #define USB_SB_command__eol__yes 1
254 #define USB_SB_command__eot__BITNR 1
255 #define USB_SB_command__eot__WIDTH 1
256 #define USB_SB_command__eot__no 0
257 #define USB_SB_command__eot__yes 1
259 #define USB_SB_command__intr__BITNR 3
260 #define USB_SB_command__intr__WIDTH 1
261 #define USB_SB_command__intr__no 0
262 #define USB_SB_command__intr__yes 1
264 #define USB_SB_command__tt__BITNR 4
265 #define USB_SB_command__tt__WIDTH 2
266 #define USB_SB_command__tt__zout 0
267 #define USB_SB_command__tt__in 1
268 #define USB_SB_command__tt__out 2
269 #define USB_SB_command__tt__setup 3
272 #define USB_SB_command__rem__BITNR 8
273 #define USB_SB_command__rem__WIDTH 6
275 #define USB_SB_command__full__BITNR 6
276 #define USB_SB_command__full__WIDTH 1
277 #define USB_SB_command__full__no 0
278 #define USB_SB_command__full__yes 1