usb-host.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:6k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  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. __u16 sw_len;
  7. __u16 command;
  8. unsigned long next;
  9. unsigned long buf;
  10. __u16 hw_len;
  11. __u16 status;
  12. } USB_IN_Desc_t;
  13. typedef struct USB_SB_Desc {
  14. __u16 sw_len;
  15. __u16 command;
  16. unsigned long next;
  17. unsigned long buf;
  18. __u32 dummy;
  19. } USB_SB_Desc_t;
  20. typedef struct USB_EP_Desc {
  21. __u16 hw_len;
  22. __u16 command;
  23. unsigned long sub;
  24. unsigned long nep;
  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. __u16 wPortChange_1;
  36. __u16 wPortChange_2;
  37. __u16 prev_wPortStatus_1;
  38. __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 {idle, eot, nodata}  etrax_usb_rx_state_t;
  51. typedef struct etrax_usb_urb_priv {
  52. USB_SB_Desc_t *first_sb;
  53. __u32 rx_offset;
  54. etrax_usb_rx_state_t rx_state;
  55. __u8 eot;
  56. struct list_head ep_in_list;
  57. } etrax_urb_priv_t;
  58. struct usb_reg_context
  59. {
  60. etrax_hc_t *hc;
  61. __u32 r_usb_epid_attn;
  62. __u8 r_usb_status;
  63. __u32 r_usb_rh_port_status_1;
  64. __u32 r_usb_rh_port_status_2;
  65. __u32 r_usb_irq_mask_read;
  66. struct tq_struct usb_bh;
  67. #if 0
  68. __u32 r_usb_ept_data[32];
  69. #endif
  70. };
  71. struct in_chunk
  72. {
  73. void *data;
  74. int length;
  75. char epid;
  76. struct list_head list;
  77. };
  78.   
  79. /* --------------------------------------------------------------------------- 
  80.    Virtual Root HUB 
  81.    ------------------------------------------------------------------------- */
  82. /* destination of request */
  83. #define RH_INTERFACE               0x01
  84. #define RH_ENDPOINT                0x02
  85. #define RH_OTHER                   0x03
  86. #define RH_CLASS                   0x20
  87. #define RH_VENDOR                  0x40
  88. /* Requests: bRequest << 8 | bmRequestType */
  89. #define RH_GET_STATUS           0x0080
  90. #define RH_CLEAR_FEATURE        0x0100
  91. #define RH_SET_FEATURE          0x0300
  92. #define RH_SET_ADDRESS 0x0500
  93. #define RH_GET_DESCRIPTOR 0x0680
  94. #define RH_SET_DESCRIPTOR       0x0700
  95. #define RH_GET_CONFIGURATION 0x0880
  96. #define RH_SET_CONFIGURATION 0x0900
  97. #define RH_GET_STATE            0x0280
  98. #define RH_GET_INTERFACE        0x0A80
  99. #define RH_SET_INTERFACE        0x0B00
  100. #define RH_SYNC_FRAME           0x0C80
  101. /* Our Vendor Specific Request */
  102. #define RH_SET_EP               0x2000
  103. /* Hub port features */
  104. #define RH_PORT_CONNECTION         0x00
  105. #define RH_PORT_ENABLE             0x01
  106. #define RH_PORT_SUSPEND            0x02
  107. #define RH_PORT_OVER_CURRENT       0x03
  108. #define RH_PORT_RESET              0x04
  109. #define RH_PORT_POWER              0x08
  110. #define RH_PORT_LOW_SPEED          0x09
  111. #define RH_C_PORT_CONNECTION       0x10
  112. #define RH_C_PORT_ENABLE           0x11
  113. #define RH_C_PORT_SUSPEND          0x12
  114. #define RH_C_PORT_OVER_CURRENT     0x13
  115. #define RH_C_PORT_RESET            0x14
  116. /* Hub features */
  117. #define RH_C_HUB_LOCAL_POWER       0x00
  118. #define RH_C_HUB_OVER_CURRENT      0x01
  119. #define RH_DEVICE_REMOTE_WAKEUP    0x00
  120. #define RH_ENDPOINT_STALL          0x01
  121. /* Our Vendor Specific feature */
  122. #define RH_REMOVE_EP               0x00
  123. #define RH_ACK                     0x01
  124. #define RH_REQ_ERR                 -1
  125. #define RH_NACK                    0x00
  126. /* Field definitions for */
  127. #define USB_IN_command__eol__BITNR      0 /* command macros */
  128. #define USB_IN_command__eol__WIDTH      1
  129. #define USB_IN_command__eol__no         0
  130. #define USB_IN_command__eol__yes        1
  131. #define USB_IN_command__intr__BITNR     3
  132. #define USB_IN_command__intr__WIDTH     1
  133. #define USB_IN_command__intr__no        0
  134. #define USB_IN_command__intr__yes       1
  135. #define USB_IN_status__eop__BITNR       1 /* status macros. */
  136. #define USB_IN_status__eop__WIDTH       1
  137. #define USB_IN_status__eop__no          0
  138. #define USB_IN_status__eop__yes         1
  139. #define USB_IN_status__eot__BITNR       5
  140. #define USB_IN_status__eot__WIDTH       1
  141. #define USB_IN_status__eot__no          0
  142. #define USB_IN_status__eot__yes         1
  143. #define USB_IN_status__error__BITNR     6
  144. #define USB_IN_status__error__WIDTH     1
  145. #define USB_IN_status__error__no        0
  146. #define USB_IN_status__error__yes       1
  147. #define USB_IN_status__nodata__BITNR    7
  148. #define USB_IN_status__nodata__WIDTH    1
  149. #define USB_IN_status__nodata__no       0
  150. #define USB_IN_status__nodata__yes      1
  151. #define USB_IN_status__epid__BITNR      8
  152. #define USB_IN_status__epid__WIDTH      5
  153. #define USB_EP_command__eol__BITNR      0
  154. #define USB_EP_command__eol__WIDTH      1
  155. #define USB_EP_command__eol__no         0
  156. #define USB_EP_command__eol__yes        1
  157. #define USB_EP_command__eof__BITNR      1
  158. #define USB_EP_command__eof__WIDTH      1
  159. #define USB_EP_command__eof__no         0
  160. #define USB_EP_command__eof__yes        1
  161. #define USB_EP_command__intr__BITNR     3
  162. #define USB_EP_command__intr__WIDTH     1
  163. #define USB_EP_command__intr__no        0
  164. #define USB_EP_command__intr__yes       1
  165. #define USB_EP_command__enable__BITNR   4
  166. #define USB_EP_command__enable__WIDTH   1
  167. #define USB_EP_command__enable__no      0
  168. #define USB_EP_command__enable__yes     1
  169. #define USB_EP_command__hw_valid__BITNR 5
  170. #define USB_EP_command__hw_valid__WIDTH 1
  171. #define USB_EP_command__hw_valid__no    0
  172. #define USB_EP_command__hw_valid__yes   1
  173. #define USB_EP_command__epid__BITNR     8
  174. #define USB_EP_command__epid__WIDTH     5
  175. #define USB_SB_command__eol__BITNR      0 /* command macros. */
  176. #define USB_SB_command__eol__WIDTH      1
  177. #define USB_SB_command__eol__no         0
  178. #define USB_SB_command__eol__yes        1
  179. #define USB_SB_command__eot__BITNR      1
  180. #define USB_SB_command__eot__WIDTH      1
  181. #define USB_SB_command__eot__no         0
  182. #define USB_SB_command__eot__yes        1
  183. #define USB_SB_command__intr__BITNR     3
  184. #define USB_SB_command__intr__WIDTH     1
  185. #define USB_SB_command__intr__no        0
  186. #define USB_SB_command__intr__yes       1
  187. #define USB_SB_command__tt__BITNR       4
  188. #define USB_SB_command__tt__WIDTH       2
  189. #define USB_SB_command__tt__zout        0
  190. #define USB_SB_command__tt__in          1
  191. #define USB_SB_command__tt__out         2
  192. #define USB_SB_command__tt__setup       3
  193. #define USB_SB_command__rem__BITNR      8
  194. #define USB_SB_command__rem__WIDTH      6
  195. #define USB_SB_command__full__BITNR     6
  196. #define USB_SB_command__full__WIDTH     1
  197. #define USB_SB_command__full__no        0
  198. #define USB_SB_command__full__yes       1
  199. #endif