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;
 
  63         WAITING_FOR_DESCR_INTR
 
  64 } etrax_usb_urb_state_t;
 
  68 typedef struct etrax_usb_urb_priv {
 
  69         /* The first_sb field is used for freeing all SB descriptors belonging
 
  70            to an urb. The corresponding ep descriptor's sub pointer cannot be
 
  71            used for this since the DMA advances the sub pointer as it processes
 
  73         USB_SB_Desc_t *first_sb;
 
  74         /* The last_sb field referes to the last SB descriptor that belongs to
 
  75            this urb. This is important to know so we can free the SB descriptors
 
  76            that ranges between first_sb and last_sb. */
 
  77         USB_SB_Desc_t *last_sb;
 
  79         /* The rx_offset field is used in ctrl and bulk traffic to keep track
 
  80            of the offset in the urb's transfer_buffer where incoming data should be
 
  84         /* Counter used in isochronous transfers to keep track of the
 
  85            number of packets received/transmitted.  */
 
  86         __u32 isoc_packet_counter;
 
  88         /* This field is used to pass information about the urb's current state between
 
  89            the various interrupt handlers (thus marked volatile). */
 
  90         volatile etrax_usb_urb_state_t urb_state;
 
  92         /* Connection between the submitted urb and ETRAX epid number */
 
  95         /* The rx_data_list field is used for periodic traffic, to hold
 
  96            received data for later processing in the the complete_urb functions,
 
  97            where the data us copied to the urb's transfer_buffer. Basically, we
 
  98            use this intermediate storage because we don't know when it's safe to
 
  99            reuse the transfer_buffer (FIXME?). */
 
 100         struct list_head rx_data_list;
 
 103 /* This struct is for passing data from the top half to the bottom half. */
 
 104 typedef struct usb_interrupt_registers
 
 107         __u32 r_usb_epid_attn;
 
 109         __u16 r_usb_rh_port_status_1;
 
 110         __u16 r_usb_rh_port_status_2;
 
 111         __u32 r_usb_irq_mask_read;
 
 112         __u32 r_usb_fm_number;
 
 113         struct work_struct usb_bh;
 
 114 } usb_interrupt_registers_t;
 
 116 /* This struct is for passing data from the isoc top half to the isoc bottom half. */
 
 117 typedef struct usb_isoc_complete_data
 
 120         struct work_struct usb_bh;
 
 121 } usb_isoc_complete_data_t;
 
 123 /* This struct holds data we get from the rx descriptors for DMA channel 9
 
 124    for periodic traffic (intr and isoc). */
 
 125 typedef struct rx_data
 
 129         struct list_head list;
 
 132 typedef struct urb_entry
 
 135         struct list_head list;
 
 138 /* ---------------------------------------------------------------------------
 
 140    ------------------------------------------------------------------------- */
 
 141 /* destination of request */
 
 142 #define RH_INTERFACE               0x01
 
 143 #define RH_ENDPOINT                0x02
 
 144 #define RH_OTHER                   0x03
 
 146 #define RH_CLASS                   0x20
 
 147 #define RH_VENDOR                  0x40
 
 149 /* Requests: bRequest << 8 | bmRequestType */
 
 150 #define RH_GET_STATUS           0x0080
 
 151 #define RH_CLEAR_FEATURE        0x0100
 
 152 #define RH_SET_FEATURE          0x0300
 
 153 #define RH_SET_ADDRESS          0x0500
 
 154 #define RH_GET_DESCRIPTOR       0x0680
 
 155 #define RH_SET_DESCRIPTOR       0x0700
 
 156 #define RH_GET_CONFIGURATION    0x0880
 
 157 #define RH_SET_CONFIGURATION    0x0900
 
 158 #define RH_GET_STATE            0x0280
 
 159 #define RH_GET_INTERFACE        0x0A80
 
 160 #define RH_SET_INTERFACE        0x0B00
 
 161 #define RH_SYNC_FRAME           0x0C80
 
 162 /* Our Vendor Specific Request */
 
 163 #define RH_SET_EP               0x2000
 
 166 /* Hub port features */
 
 167 #define RH_PORT_CONNECTION         0x00
 
 168 #define RH_PORT_ENABLE             0x01
 
 169 #define RH_PORT_SUSPEND            0x02
 
 170 #define RH_PORT_OVER_CURRENT       0x03
 
 171 #define RH_PORT_RESET              0x04
 
 172 #define RH_PORT_POWER              0x08
 
 173 #define RH_PORT_LOW_SPEED          0x09
 
 174 #define RH_C_PORT_CONNECTION       0x10
 
 175 #define RH_C_PORT_ENABLE           0x11
 
 176 #define RH_C_PORT_SUSPEND          0x12
 
 177 #define RH_C_PORT_OVER_CURRENT     0x13
 
 178 #define RH_C_PORT_RESET            0x14
 
 181 #define RH_C_HUB_LOCAL_POWER       0x00
 
 182 #define RH_C_HUB_OVER_CURRENT      0x01
 
 184 #define RH_DEVICE_REMOTE_WAKEUP    0x00
 
 185 #define RH_ENDPOINT_STALL          0x01
 
 187 /* Our Vendor Specific feature */
 
 188 #define RH_REMOVE_EP               0x00
 
 192 #define RH_REQ_ERR                 -1
 
 195 /* Field definitions for */
 
 197 #define USB_IN_command__eol__BITNR      0 /* command macros */
 
 198 #define USB_IN_command__eol__WIDTH      1
 
 199 #define USB_IN_command__eol__no         0
 
 200 #define USB_IN_command__eol__yes        1
 
 202 #define USB_IN_command__intr__BITNR     3
 
 203 #define USB_IN_command__intr__WIDTH     1
 
 204 #define USB_IN_command__intr__no        0
 
 205 #define USB_IN_command__intr__yes       1
 
 207 #define USB_IN_status__eop__BITNR       1 /* status macros. */
 
 208 #define USB_IN_status__eop__WIDTH       1
 
 209 #define USB_IN_status__eop__no          0
 
 210 #define USB_IN_status__eop__yes         1
 
 212 #define USB_IN_status__eot__BITNR       5
 
 213 #define USB_IN_status__eot__WIDTH       1
 
 214 #define USB_IN_status__eot__no          0
 
 215 #define USB_IN_status__eot__yes         1
 
 217 #define USB_IN_status__error__BITNR     6
 
 218 #define USB_IN_status__error__WIDTH     1
 
 219 #define USB_IN_status__error__no        0
 
 220 #define USB_IN_status__error__yes       1
 
 222 #define USB_IN_status__nodata__BITNR    7
 
 223 #define USB_IN_status__nodata__WIDTH    1
 
 224 #define USB_IN_status__nodata__no       0
 
 225 #define USB_IN_status__nodata__yes      1
 
 227 #define USB_IN_status__epid__BITNR      8
 
 228 #define USB_IN_status__epid__WIDTH      5
 
 230 #define USB_EP_command__eol__BITNR      0
 
 231 #define USB_EP_command__eol__WIDTH      1
 
 232 #define USB_EP_command__eol__no         0
 
 233 #define USB_EP_command__eol__yes        1
 
 235 #define USB_EP_command__eof__BITNR      1
 
 236 #define USB_EP_command__eof__WIDTH      1
 
 237 #define USB_EP_command__eof__no         0
 
 238 #define USB_EP_command__eof__yes        1
 
 240 #define USB_EP_command__intr__BITNR     3
 
 241 #define USB_EP_command__intr__WIDTH     1
 
 242 #define USB_EP_command__intr__no        0
 
 243 #define USB_EP_command__intr__yes       1
 
 245 #define USB_EP_command__enable__BITNR   4
 
 246 #define USB_EP_command__enable__WIDTH   1
 
 247 #define USB_EP_command__enable__no      0
 
 248 #define USB_EP_command__enable__yes     1
 
 250 #define USB_EP_command__hw_valid__BITNR 5
 
 251 #define USB_EP_command__hw_valid__WIDTH 1
 
 252 #define USB_EP_command__hw_valid__no    0
 
 253 #define USB_EP_command__hw_valid__yes   1
 
 255 #define USB_EP_command__epid__BITNR     8
 
 256 #define USB_EP_command__epid__WIDTH     5
 
 258 #define USB_SB_command__eol__BITNR      0 /* command macros. */
 
 259 #define USB_SB_command__eol__WIDTH      1
 
 260 #define USB_SB_command__eol__no         0
 
 261 #define USB_SB_command__eol__yes        1
 
 263 #define USB_SB_command__eot__BITNR      1
 
 264 #define USB_SB_command__eot__WIDTH      1
 
 265 #define USB_SB_command__eot__no         0
 
 266 #define USB_SB_command__eot__yes        1
 
 268 #define USB_SB_command__intr__BITNR     3
 
 269 #define USB_SB_command__intr__WIDTH     1
 
 270 #define USB_SB_command__intr__no        0
 
 271 #define USB_SB_command__intr__yes       1
 
 273 #define USB_SB_command__tt__BITNR       4
 
 274 #define USB_SB_command__tt__WIDTH       2
 
 275 #define USB_SB_command__tt__zout        0
 
 276 #define USB_SB_command__tt__in          1
 
 277 #define USB_SB_command__tt__out         2
 
 278 #define USB_SB_command__tt__setup       3
 
 281 #define USB_SB_command__rem__BITNR      8
 
 282 #define USB_SB_command__rem__WIDTH      6
 
 284 #define USB_SB_command__full__BITNR     6
 
 285 #define USB_SB_command__full__WIDTH     1
 
 286 #define USB_SB_command__full__no        0
 
 287 #define USB_SB_command__full__yes       1