hc_crisv10.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. #ifndef __LINUX_ETRAX_USB_H
  2. #define __LINUX_ETRAX_USB_H
  3. #include <linux/types.h>
  4. #include <linux/list.h>
  5. typedef struct USB_IN_Desc {
  6. volatile __u16 sw_len;
  7. volatile __u16 command;
  8. volatile unsigned long next;
  9. volatile unsigned long buf;
  10. volatile __u16 hw_len;
  11. volatile __u16 status;
  12. } USB_IN_Desc_t;
  13. typedef struct USB_SB_Desc {
  14. volatile __u16 sw_len;
  15. volatile __u16 command;
  16. volatile unsigned long next;
  17. volatile unsigned long buf;
  18. __u32 dummy;
  19. } USB_SB_Desc_t;
  20. typedef struct USB_EP_Desc {
  21. volatile __u16 hw_len;
  22. volatile __u16 command;
  23. volatile unsigned long sub;
  24. volatile unsigned long next;
  25. __u32 dummy;
  26. } USB_EP_Desc_t;
  27. struct virt_root_hub {
  28. int devnum;
  29. void *urb;
  30. void *int_addr;
  31. int send;
  32. int interval;
  33. int numports;
  34. struct timer_list rh_int_timer;
  35. volatile __u16 wPortChange_1;
  36. volatile __u16 wPortChange_2;
  37. volatile __u16 prev_wPortStatus_1;
  38. volatile __u16 prev_wPortStatus_2;
  39. };
  40. struct etrax_usb_intr_traffic {
  41. int sleeping;
  42. int error;
  43. struct wait_queue *wq;
  44. };
  45. typedef struct etrax_usb_hc {
  46. struct usb_bus *bus;
  47. struct virt_root_hub rh;
  48. struct etrax_usb_intr_traffic intr;
  49. } etrax_hc_t;
  50. typedef enum {
  51. STARTED,
  52. NOT_STARTED,
  53. UNLINK,
  54. TRANSFER_DONE,
  55. WAITING_FOR_DESCR_INTR
  56. } etrax_usb_urb_state_t;
  57. typedef struct etrax_usb_urb_priv {
  58. /* The first_sb field is used for freeing all SB descriptors belonging
  59. to an urb. The corresponding ep descriptor's sub pointer cannot be
  60. used for this since the DMA advances the sub pointer as it processes
  61. the sb list. */
  62. USB_SB_Desc_t *first_sb;
  63. /* The last_sb field referes to the last SB descriptor that belongs to
  64. this urb. This is important to know so we can free the SB descriptors
  65. that ranges between first_sb and last_sb. */
  66. USB_SB_Desc_t *last_sb;
  67. /* The rx_offset field is used in ctrl and bulk traffic to keep track
  68. of the offset in the urb's transfer_buffer where incoming data should be
  69. copied to. */
  70. __u32 rx_offset;
  71. /* Counter used in isochronous transfers to keep track of the
  72. number of packets received/transmitted. */
  73. __u32 isoc_packet_counter;
  74. /* This field is used to pass information about the urb's current state between
  75. the various interrupt handlers (thus marked volatile). */
  76. volatile etrax_usb_urb_state_t urb_state;
  77. /* Connection between the submitted urb and ETRAX epid number */
  78. __u8 epid;
  79. /* The rx_data_list field is used for periodic traffic, to hold
  80. received data for later processing in the the complete_urb functions,
  81. where the data us copied to the urb's transfer_buffer. Basically, we
  82. use this intermediate storage because we don't know when it's safe to
  83. reuse the transfer_buffer (FIXME?). */
  84. struct list_head rx_data_list;
  85. } etrax_urb_priv_t;
  86. /* This struct is for passing data from the top half to the bottom half. */
  87. typedef struct usb_interrupt_registers
  88. {
  89. etrax_hc_t *hc;
  90. __u32 r_usb_epid_attn;
  91. __u8 r_usb_status;
  92. __u16 r_usb_rh_port_status_1;
  93. __u16 r_usb_rh_port_status_2;
  94. __u32 r_usb_irq_mask_read;
  95. __u32 r_usb_fm_number;
  96. struct work_struct usb_bh;
  97. } usb_interrupt_registers_t;
  98. /* This struct is for passing data from the isoc top half to the isoc bottom half. */
  99. typedef struct usb_isoc_complete_data
  100. {
  101. struct urb *urb;
  102. struct work_struct usb_bh;
  103. } usb_isoc_complete_data_t;
  104. /* This struct holds data we get from the rx descriptors for DMA channel 9
  105. for periodic traffic (intr and isoc). */
  106. typedef struct rx_data
  107. {
  108. void *data;
  109. int length;
  110. struct list_head list;
  111. } rx_data_t;
  112. typedef struct urb_entry
  113. {
  114. struct urb *urb;
  115. struct list_head list;
  116. } urb_entry_t;
  117. /* ---------------------------------------------------------------------------
  118. Virtual Root HUB
  119. ------------------------------------------------------------------------- */
  120. /* destination of request */
  121. #define RH_INTERFACE 0x01
  122. #define RH_ENDPOINT 0x02
  123. #define RH_OTHER 0x03
  124. #define RH_CLASS 0x20
  125. #define RH_VENDOR 0x40
  126. /* Requests: bRequest << 8 | bmRequestType */
  127. #define RH_GET_STATUS 0x0080
  128. #define RH_CLEAR_FEATURE 0x0100
  129. #define RH_SET_FEATURE 0x0300
  130. #define RH_SET_ADDRESS 0x0500
  131. #define RH_GET_DESCRIPTOR 0x0680
  132. #define RH_SET_DESCRIPTOR 0x0700
  133. #define RH_GET_CONFIGURATION 0x0880
  134. #define RH_SET_CONFIGURATION 0x0900
  135. #define RH_GET_STATE 0x0280
  136. #define RH_GET_INTERFACE 0x0A80
  137. #define RH_SET_INTERFACE 0x0B00
  138. #define RH_SYNC_FRAME 0x0C80
  139. /* Our Vendor Specific Request */
  140. #define RH_SET_EP 0x2000
  141. /* Hub port features */
  142. #define RH_PORT_CONNECTION 0x00
  143. #define RH_PORT_ENABLE 0x01
  144. #define RH_PORT_SUSPEND 0x02
  145. #define RH_PORT_OVER_CURRENT 0x03
  146. #define RH_PORT_RESET 0x04
  147. #define RH_PORT_POWER 0x08
  148. #define RH_PORT_LOW_SPEED 0x09
  149. #define RH_C_PORT_CONNECTION 0x10
  150. #define RH_C_PORT_ENABLE 0x11
  151. #define RH_C_PORT_SUSPEND 0x12
  152. #define RH_C_PORT_OVER_CURRENT 0x13
  153. #define RH_C_PORT_RESET 0x14
  154. /* Hub features */
  155. #define RH_C_HUB_LOCAL_POWER 0x00
  156. #define RH_C_HUB_OVER_CURRENT 0x01
  157. #define RH_DEVICE_REMOTE_WAKEUP 0x00
  158. #define RH_ENDPOINT_STALL 0x01
  159. /* Our Vendor Specific feature */
  160. #define RH_REMOVE_EP 0x00
  161. #define RH_ACK 0x01
  162. #define RH_REQ_ERR -1
  163. #define RH_NACK 0x00
  164. /* Field definitions for */
  165. #define USB_IN_command__eol__BITNR 0 /* command macros */
  166. #define USB_IN_command__eol__WIDTH 1
  167. #define USB_IN_command__eol__no 0
  168. #define USB_IN_command__eol__yes 1
  169. #define USB_IN_command__intr__BITNR 3
  170. #define USB_IN_command__intr__WIDTH 1
  171. #define USB_IN_command__intr__no 0
  172. #define USB_IN_command__intr__yes 1
  173. #define USB_IN_status__eop__BITNR 1 /* status macros. */
  174. #define USB_IN_status__eop__WIDTH 1
  175. #define USB_IN_status__eop__no 0
  176. #define USB_IN_status__eop__yes 1
  177. #define USB_IN_status__eot__BITNR 5
  178. #define USB_IN_status__eot__WIDTH 1
  179. #define USB_IN_status__eot__no 0
  180. #define USB_IN_status__eot__yes 1
  181. #define USB_IN_status__error__BITNR 6
  182. #define USB_IN_status__error__WIDTH 1
  183. #define USB_IN_status__error__no 0
  184. #define USB_IN_status__error__yes 1
  185. #define USB_IN_status__nodata__BITNR 7
  186. #define USB_IN_status__nodata__WIDTH 1
  187. #define USB_IN_status__nodata__no 0
  188. #define USB_IN_status__nodata__yes 1
  189. #define USB_IN_status__epid__BITNR 8
  190. #define USB_IN_status__epid__WIDTH 5
  191. #define USB_EP_command__eol__BITNR 0
  192. #define USB_EP_command__eol__WIDTH 1
  193. #define USB_EP_command__eol__no 0
  194. #define USB_EP_command__eol__yes 1
  195. #define USB_EP_command__eof__BITNR 1
  196. #define USB_EP_command__eof__WIDTH 1
  197. #define USB_EP_command__eof__no 0
  198. #define USB_EP_command__eof__yes 1
  199. #define USB_EP_command__intr__BITNR 3
  200. #define USB_EP_command__intr__WIDTH 1
  201. #define USB_EP_command__intr__no 0
  202. #define USB_EP_command__intr__yes 1
  203. #define USB_EP_command__enable__BITNR 4
  204. #define USB_EP_command__enable__WIDTH 1
  205. #define USB_EP_command__enable__no 0
  206. #define USB_EP_command__enable__yes 1
  207. #define USB_EP_command__hw_valid__BITNR 5
  208. #define USB_EP_command__hw_valid__WIDTH 1
  209. #define USB_EP_command__hw_valid__no 0
  210. #define USB_EP_command__hw_valid__yes 1
  211. #define USB_EP_command__epid__BITNR 8
  212. #define USB_EP_command__epid__WIDTH 5
  213. #define USB_SB_command__eol__BITNR 0 /* command macros. */
  214. #define USB_SB_command__eol__WIDTH 1
  215. #define USB_SB_command__eol__no 0
  216. #define USB_SB_command__eol__yes 1
  217. #define USB_SB_command__eot__BITNR 1
  218. #define USB_SB_command__eot__WIDTH 1
  219. #define USB_SB_command__eot__no 0
  220. #define USB_SB_command__eot__yes 1
  221. #define USB_SB_command__intr__BITNR 3
  222. #define USB_SB_command__intr__WIDTH 1
  223. #define USB_SB_command__intr__no 0
  224. #define USB_SB_command__intr__yes 1
  225. #define USB_SB_command__tt__BITNR 4
  226. #define USB_SB_command__tt__WIDTH 2
  227. #define USB_SB_command__tt__zout 0
  228. #define USB_SB_command__tt__in 1
  229. #define USB_SB_command__tt__out 2
  230. #define USB_SB_command__tt__setup 3
  231. #define USB_SB_command__rem__BITNR 8
  232. #define USB_SB_command__rem__WIDTH 6
  233. #define USB_SB_command__full__BITNR 6
  234. #define USB_SB_command__full__WIDTH 1
  235. #define USB_SB_command__full__no 0
  236. #define USB_SB_command__full__yes 1
  237. #endif