hc-crisv10.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. #ifndef __LINUX_ETRAX_USB_H
  2. #define __LINUX_ETRAX_USB_H
  3. #include <linux/types.h>
  4. #include <linux/list.h>
  5. 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. };
  13. struct USB_SB_Desc {
  14. volatile __u16 sw_len;
  15. volatile __u16 command;
  16. volatile unsigned long next;
  17. volatile unsigned long buf;
  18. };
  19. struct USB_EP_Desc {
  20. volatile __u16 hw_len;
  21. volatile __u16 command;
  22. volatile unsigned long sub;
  23. volatile unsigned long next;
  24. };
  25. /* Root Hub port status struct */
  26. struct crisv10_rh {
  27. volatile __u16 wPortChange[2];
  28. volatile __u16 wPortStatusPrev[2];
  29. };
  30. /* HCD description */
  31. struct crisv10_hcd {
  32. spinlock_t lock;
  33. __u8 num_ports;
  34. __u8 running;
  35. };
  36. /* Endpoint HC private data description */
  37. struct crisv10_ep_priv {
  38. int epid;
  39. };
  40. /* Additional software state info for a USB Controller epid */
  41. struct etrax_epid {
  42. __u8 inuse; /* !0 = setup in Etrax and used for a endpoint */
  43. __u8 disabled; /* !0 = Temporarly disabled to avoid resubmission */
  44. __u8 type; /* Setup as: PIPE_BULK, PIPE_CONTROL ... */
  45. __u8 out_traffic; /* !0 = This epid is for out traffic */
  46. };
  47. /* Struct to hold information of scheduled later URB completion */
  48. struct urb_later_data {
  49. struct delayed_work dws;
  50. struct usb_hcd *hcd;
  51. struct urb *urb;
  52. int urb_num;
  53. int status;
  54. };
  55. typedef enum {
  56. STARTED,
  57. NOT_STARTED,
  58. UNLINK,
  59. } crisv10_urb_state_t;
  60. struct crisv10_urb_priv {
  61. /* Sequence number for this URB. Every new submited URB gets this from
  62. a incrementing counter. Used when a URB is scheduled for later finish to
  63. be sure that the intended URB hasn't already been completed (device
  64. drivers has a tendency to reuse URBs once they are completed, causing us
  65. to not be able to single old ones out only based on the URB pointer.) */
  66. __u32 urb_num;
  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
  70. the sb list. */
  71. struct USB_SB_Desc *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. struct USB_SB_Desc *last_sb;
  76. /* The rx_offset field is used in ctrl and bulk traffic to keep track
  77. of the offset in the urb's transfer_buffer where incoming data should be
  78. copied to. */
  79. __u32 rx_offset;
  80. /* Counter used in isochronous transfers to keep track of the
  81. number of packets received/transmitted. */
  82. __u32 isoc_packet_counter;
  83. /* Flag that marks if this Isoc Out URB has finished it's transfer. Used
  84. because several URBs can be finished before list is processed */
  85. __u8 isoc_out_done;
  86. /* This field is used to pass information about the urb's current state
  87. between the various interrupt handlers (thus marked volatile). */
  88. volatile crisv10_urb_state_t urb_state;
  89. /* In Ctrl transfers consist of (at least) 3 packets: SETUP, IN and ZOUT.
  90. When DMA8 sub-channel 2 has processed the SB list for this sequence we
  91. get a interrupt. We also get a interrupt for In transfers and which
  92. one of these interrupts that comes first depends of data size and device.
  93. To be sure that we have got both interrupts before we complete the URB
  94. we have these to flags that shows which part that has completed.
  95. We can then check when we get one of the interrupts that if the other has
  96. occured it's safe for us to complete the URB, otherwise we set appropriate
  97. flag and do the completion when we get the other interrupt. */
  98. volatile unsigned char ctrl_zout_done;
  99. volatile unsigned char ctrl_rx_done;
  100. /* Connection between the submitted urb and ETRAX epid number */
  101. __u8 epid;
  102. /* The rx_data_list field is used for periodic traffic, to hold
  103. received data for later processing in the the complete_urb functions,
  104. where the data us copied to the urb's transfer_buffer. Basically, we
  105. use this intermediate storage because we don't know when it's safe to
  106. reuse the transfer_buffer (FIXME?). */
  107. struct list_head rx_data_list;
  108. /* The interval time rounded up to closest 2^N */
  109. int interval;
  110. /* Pool of EP descriptors needed if it's a INTR transfer.
  111. Amount of EPs in pool correspons to how many INTR that should
  112. be inserted in TxIntrEPList (max 128, defined by MAX_INTR_INTERVAL) */
  113. struct USB_EP_Desc* intr_ep_pool[128];
  114. /* The mount of EPs allocated for this INTR URB */
  115. int intr_ep_pool_length;
  116. /* Pointer to info struct if URB is scheduled to be finished later */
  117. struct urb_later_data* later_data;
  118. /* Allocated bandwidth for isochronous and interrupt traffic */
  119. int bandwidth;
  120. };
  121. /* This struct is for passing data from the top half to the bottom half irq
  122. handlers */
  123. struct crisv10_irq_reg {
  124. struct usb_hcd* hcd;
  125. __u32 r_usb_epid_attn;
  126. __u8 r_usb_status;
  127. __u16 r_usb_rh_port_status_1;
  128. __u16 r_usb_rh_port_status_2;
  129. __u32 r_usb_irq_mask_read;
  130. __u32 r_usb_fm_number;
  131. struct work_struct usb_bh;
  132. };
  133. /* This struct is for passing data from the isoc top half to the isoc bottom
  134. half. */
  135. struct crisv10_isoc_complete_data {
  136. struct usb_hcd *hcd;
  137. struct urb *urb;
  138. struct work_struct usb_bh;
  139. };
  140. /* Entry item for URB lists for each endpint */
  141. typedef struct urb_entry
  142. {
  143. struct urb *urb;
  144. struct list_head list;
  145. } urb_entry_t;
  146. /* ---------------------------------------------------------------------------
  147. Virtual Root HUB
  148. ------------------------------------------------------------------------- */
  149. /* destination of request */
  150. #define RH_INTERFACE 0x01
  151. #define RH_ENDPOINT 0x02
  152. #define RH_OTHER 0x03
  153. #define RH_CLASS 0x20
  154. #define RH_VENDOR 0x40
  155. /* Requests: bRequest << 8 | bmRequestType */
  156. #define RH_GET_STATUS 0x0080
  157. #define RH_CLEAR_FEATURE 0x0100
  158. #define RH_SET_FEATURE 0x0300
  159. #define RH_SET_ADDRESS 0x0500
  160. #define RH_GET_DESCRIPTOR 0x0680
  161. #define RH_SET_DESCRIPTOR 0x0700
  162. #define RH_GET_CONFIGURATION 0x0880
  163. #define RH_SET_CONFIGURATION 0x0900
  164. #define RH_GET_STATE 0x0280
  165. #define RH_GET_INTERFACE 0x0A80
  166. #define RH_SET_INTERFACE 0x0B00
  167. #define RH_SYNC_FRAME 0x0C80
  168. /* Our Vendor Specific Request */
  169. #define RH_SET_EP 0x2000
  170. /* Hub port features */
  171. #define RH_PORT_CONNECTION 0x00
  172. #define RH_PORT_ENABLE 0x01
  173. #define RH_PORT_SUSPEND 0x02
  174. #define RH_PORT_OVER_CURRENT 0x03
  175. #define RH_PORT_RESET 0x04
  176. #define RH_PORT_POWER 0x08
  177. #define RH_PORT_LOW_SPEED 0x09
  178. #define RH_C_PORT_CONNECTION 0x10
  179. #define RH_C_PORT_ENABLE 0x11
  180. #define RH_C_PORT_SUSPEND 0x12
  181. #define RH_C_PORT_OVER_CURRENT 0x13
  182. #define RH_C_PORT_RESET 0x14
  183. /* Hub features */
  184. #define RH_C_HUB_LOCAL_POWER 0x00
  185. #define RH_C_HUB_OVER_CURRENT 0x01
  186. #define RH_DEVICE_REMOTE_WAKEUP 0x00
  187. #define RH_ENDPOINT_STALL 0x01
  188. /* Our Vendor Specific feature */
  189. #define RH_REMOVE_EP 0x00
  190. #define RH_ACK 0x01
  191. #define RH_REQ_ERR -1
  192. #define RH_NACK 0x00
  193. /* Field definitions for */
  194. #define USB_IN_command__eol__BITNR 0 /* command macros */
  195. #define USB_IN_command__eol__WIDTH 1
  196. #define USB_IN_command__eol__no 0
  197. #define USB_IN_command__eol__yes 1
  198. #define USB_IN_command__intr__BITNR 3
  199. #define USB_IN_command__intr__WIDTH 1
  200. #define USB_IN_command__intr__no 0
  201. #define USB_IN_command__intr__yes 1
  202. #define USB_IN_status__eop__BITNR 1 /* status macros. */
  203. #define USB_IN_status__eop__WIDTH 1
  204. #define USB_IN_status__eop__no 0
  205. #define USB_IN_status__eop__yes 1
  206. #define USB_IN_status__eot__BITNR 5
  207. #define USB_IN_status__eot__WIDTH 1
  208. #define USB_IN_status__eot__no 0
  209. #define USB_IN_status__eot__yes 1
  210. #define USB_IN_status__error__BITNR 6
  211. #define USB_IN_status__error__WIDTH 1
  212. #define USB_IN_status__error__no 0
  213. #define USB_IN_status__error__yes 1
  214. #define USB_IN_status__nodata__BITNR 7
  215. #define USB_IN_status__nodata__WIDTH 1
  216. #define USB_IN_status__nodata__no 0
  217. #define USB_IN_status__nodata__yes 1
  218. #define USB_IN_status__epid__BITNR 8
  219. #define USB_IN_status__epid__WIDTH 5
  220. #define USB_EP_command__eol__BITNR 0
  221. #define USB_EP_command__eol__WIDTH 1
  222. #define USB_EP_command__eol__no 0
  223. #define USB_EP_command__eol__yes 1
  224. #define USB_EP_command__eof__BITNR 1
  225. #define USB_EP_command__eof__WIDTH 1
  226. #define USB_EP_command__eof__no 0
  227. #define USB_EP_command__eof__yes 1
  228. #define USB_EP_command__intr__BITNR 3
  229. #define USB_EP_command__intr__WIDTH 1
  230. #define USB_EP_command__intr__no 0
  231. #define USB_EP_command__intr__yes 1
  232. #define USB_EP_command__enable__BITNR 4
  233. #define USB_EP_command__enable__WIDTH 1
  234. #define USB_EP_command__enable__no 0
  235. #define USB_EP_command__enable__yes 1
  236. #define USB_EP_command__hw_valid__BITNR 5
  237. #define USB_EP_command__hw_valid__WIDTH 1
  238. #define USB_EP_command__hw_valid__no 0
  239. #define USB_EP_command__hw_valid__yes 1
  240. #define USB_EP_command__epid__BITNR 8
  241. #define USB_EP_command__epid__WIDTH 5
  242. #define USB_SB_command__eol__BITNR 0 /* command macros. */
  243. #define USB_SB_command__eol__WIDTH 1
  244. #define USB_SB_command__eol__no 0
  245. #define USB_SB_command__eol__yes 1
  246. #define USB_SB_command__eot__BITNR 1
  247. #define USB_SB_command__eot__WIDTH 1
  248. #define USB_SB_command__eot__no 0
  249. #define USB_SB_command__eot__yes 1
  250. #define USB_SB_command__intr__BITNR 3
  251. #define USB_SB_command__intr__WIDTH 1
  252. #define USB_SB_command__intr__no 0
  253. #define USB_SB_command__intr__yes 1
  254. #define USB_SB_command__tt__BITNR 4
  255. #define USB_SB_command__tt__WIDTH 2
  256. #define USB_SB_command__tt__zout 0
  257. #define USB_SB_command__tt__in 1
  258. #define USB_SB_command__tt__out 2
  259. #define USB_SB_command__tt__setup 3
  260. #define USB_SB_command__rem__BITNR 8
  261. #define USB_SB_command__rem__WIDTH 6
  262. #define USB_SB_command__full__BITNR 6
  263. #define USB_SB_command__full__WIDTH 1
  264. #define USB_SB_command__full__no 0
  265. #define USB_SB_command__full__yes 1
  266. #endif