ch11.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * This file holds Hub protocol constants and data structures that are
  3. * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
  4. *
  5. * It is used/shared between the USB core, the HCDs and couple of other USB
  6. * drivers.
  7. */
  8. #ifndef __LINUX_CH11_H
  9. #define __LINUX_CH11_H
  10. #include <linux/types.h> /* __u8 etc */
  11. /*
  12. * Hub request types
  13. */
  14. #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
  15. #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
  16. /*
  17. * Hub class requests
  18. * See USB 2.0 spec Table 11-16
  19. */
  20. #define HUB_CLEAR_TT_BUFFER 8
  21. #define HUB_RESET_TT 9
  22. #define HUB_GET_TT_STATE 10
  23. #define HUB_STOP_TT 11
  24. #define HUB_SET_DEPTH 12
  25. /*
  26. * Hub class additional requests defined by USB 3.0 spec
  27. * See USB 3.0 spec Table 10-6
  28. */
  29. #define HUB_SET_DEPTH 12
  30. #define HUB_GET_PORT_ERR_COUNT 13
  31. /*
  32. * Hub Class feature numbers
  33. * See USB 2.0 spec Table 11-17
  34. */
  35. #define C_HUB_LOCAL_POWER 0
  36. #define C_HUB_OVER_CURRENT 1
  37. /*
  38. * Port feature numbers
  39. * See USB 2.0 spec Table 11-17
  40. */
  41. #define USB_PORT_FEAT_CONNECTION 0
  42. #define USB_PORT_FEAT_ENABLE 1
  43. #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
  44. #define USB_PORT_FEAT_OVER_CURRENT 3
  45. #define USB_PORT_FEAT_RESET 4
  46. #define USB_PORT_FEAT_L1 5 /* L1 suspend */
  47. #define USB_PORT_FEAT_POWER 8
  48. #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
  49. #define USB_PORT_FEAT_C_CONNECTION 16
  50. #define USB_PORT_FEAT_C_ENABLE 17
  51. #define USB_PORT_FEAT_C_SUSPEND 18
  52. #define USB_PORT_FEAT_C_OVER_CURRENT 19
  53. #define USB_PORT_FEAT_C_RESET 20
  54. #define USB_PORT_FEAT_TEST 21
  55. #define USB_PORT_FEAT_INDICATOR 22
  56. #define USB_PORT_FEAT_C_PORT_L1 23
  57. #define USB_PORT_FEAT_C_PORT_LINK_STATE 25
  58. #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
  59. #define USB_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27
  60. #define USB_PORT_FEAT_BH_PORT_RESET 28
  61. #define USB_PORT_FEAT_C_BH_PORT_RESET 29
  62. #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
  63. /*
  64. * Port feature selectors added by USB 3.0 spec.
  65. * See USB 3.0 spec Table 10-7
  66. */
  67. #define USB_PORT_FEAT_LINK_STATE 5
  68. #define USB_PORT_FEAT_U1_TIMEOUT 23
  69. #define USB_PORT_FEAT_U2_TIMEOUT 24
  70. #define USB_PORT_FEAT_C_LINK_STATE 25
  71. #define USB_PORT_FEAT_C_CONFIG_ERR 26
  72. #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
  73. #define USB_PORT_FEAT_BH_PORT_RESET 28
  74. #define USB_PORT_FEAT_C_BH_PORT_RESET 29
  75. #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
  76. /*
  77. * Hub Status and Hub Change results
  78. * See USB 2.0 spec Table 11-19 and Table 11-20
  79. */
  80. struct usb_port_status {
  81. __le16 wPortStatus;
  82. __le16 wPortChange;
  83. } __attribute__ ((packed));
  84. /*
  85. * wPortStatus bit field
  86. * See USB 2.0 spec Table 11-21
  87. */
  88. #define USB_PORT_STAT_CONNECTION 0x0001
  89. #define USB_PORT_STAT_ENABLE 0x0002
  90. #define USB_PORT_STAT_SUSPEND 0x0004
  91. #define USB_PORT_STAT_OVERCURRENT 0x0008
  92. #define USB_PORT_STAT_RESET 0x0010
  93. #define USB_PORT_STAT_L1 0x0020
  94. /* bits 6 to 7 are reserved */
  95. #define USB_PORT_STAT_POWER 0x0100
  96. #define USB_PORT_STAT_LOW_SPEED 0x0200
  97. #define USB_PORT_STAT_HIGH_SPEED 0x0400
  98. #define USB_PORT_STAT_TEST 0x0800
  99. #define USB_PORT_STAT_INDICATOR 0x1000
  100. /* bits 13 to 15 are reserved */
  101. /*
  102. * Additions to wPortStatus bit field from USB 3.0
  103. * See USB 3.0 spec Table 10-10
  104. */
  105. #define USB_PORT_STAT_LINK_STATE 0x01e0
  106. #define USB_SS_PORT_STAT_POWER 0x0200
  107. #define USB_SS_PORT_STAT_SPEED 0x1c00
  108. #define USB_PORT_STAT_SPEED_5GBPS 0x0000
  109. /* Valid only if port is enabled */
  110. /* Bits that are the same from USB 2.0 */
  111. #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
  112. USB_PORT_STAT_ENABLE | \
  113. USB_PORT_STAT_OVERCURRENT | \
  114. USB_PORT_STAT_RESET)
  115. /*
  116. * Definitions for PORT_LINK_STATE values
  117. * (bits 5-8) in wPortStatus
  118. */
  119. #define USB_SS_PORT_LS_U0 0x0000
  120. #define USB_SS_PORT_LS_U1 0x0020
  121. #define USB_SS_PORT_LS_U2 0x0040
  122. #define USB_SS_PORT_LS_U3 0x0060
  123. #define USB_SS_PORT_LS_SS_DISABLED 0x0080
  124. #define USB_SS_PORT_LS_RX_DETECT 0x00a0
  125. #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
  126. #define USB_SS_PORT_LS_POLLING 0x00e0
  127. #define USB_SS_PORT_LS_RECOVERY 0x0100
  128. #define USB_SS_PORT_LS_HOT_RESET 0x0120
  129. #define USB_SS_PORT_LS_COMP_MOD 0x0140
  130. #define USB_SS_PORT_LS_LOOPBACK 0x0160
  131. /*
  132. * wPortChange bit field
  133. * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
  134. * Bits 0 to 5 shown, bits 6 to 15 are reserved
  135. */
  136. #define USB_PORT_STAT_C_CONNECTION 0x0001
  137. #define USB_PORT_STAT_C_ENABLE 0x0002
  138. #define USB_PORT_STAT_C_SUSPEND 0x0004
  139. #define USB_PORT_STAT_C_OVERCURRENT 0x0008
  140. #define USB_PORT_STAT_C_RESET 0x0010
  141. #define USB_PORT_STAT_C_L1 0x0020
  142. /*
  143. * USB 3.0 wPortChange bit fields
  144. * See USB 3.0 spec Table 10-11
  145. */
  146. #define USB_PORT_STAT_C_BH_RESET 0x0020
  147. #define USB_PORT_STAT_C_LINK_STATE 0x0040
  148. #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
  149. /*
  150. * wHubCharacteristics (masks)
  151. * See USB 2.0 spec Table 11-13, offset 3
  152. */
  153. #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
  154. #define HUB_CHAR_COMPOUND 0x0004 /* D2 */
  155. #define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
  156. #define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
  157. #define HUB_CHAR_PORTIND 0x0080 /* D7 */
  158. struct usb_hub_status {
  159. __le16 wHubStatus;
  160. __le16 wHubChange;
  161. } __attribute__ ((packed));
  162. /*
  163. * Hub Status & Hub Change bit masks
  164. * See USB 2.0 spec Table 11-19 and Table 11-20
  165. * Bits 0 and 1 for wHubStatus and wHubChange
  166. * Bits 2 to 15 are reserved for both
  167. */
  168. #define HUB_STATUS_LOCAL_POWER 0x0001
  169. #define HUB_STATUS_OVERCURRENT 0x0002
  170. #define HUB_CHANGE_LOCAL_POWER 0x0001
  171. #define HUB_CHANGE_OVERCURRENT 0x0002
  172. /*
  173. * Hub descriptor
  174. * See USB 2.0 spec Table 11-13
  175. */
  176. #define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
  177. #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
  178. #define USB_DT_HUB_NONVAR_SIZE 7
  179. #define USB_DT_SS_HUB_SIZE 12
  180. struct usb_hub_descriptor {
  181. __u8 bDescLength;
  182. __u8 bDescriptorType;
  183. __u8 bNbrPorts;
  184. __le16 wHubCharacteristics;
  185. __u8 bPwrOn2PwrGood;
  186. __u8 bHubContrCurrent;
  187. /* 2.0 and 3.0 hubs differ here */
  188. union {
  189. struct {
  190. /* add 1 bit for hub status change; round to bytes */
  191. __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
  192. __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
  193. } __attribute__ ((packed)) hs;
  194. struct {
  195. __u8 bHubHdrDecLat;
  196. __u16 wHubDelay;
  197. __u16 DeviceRemovable;
  198. } __attribute__ ((packed)) ss;
  199. } u;
  200. } __attribute__ ((packed));
  201. /* port indicator status selectors, tables 11-7 and 11-25 */
  202. #define HUB_LED_AUTO 0
  203. #define HUB_LED_AMBER 1
  204. #define HUB_LED_GREEN 2
  205. #define HUB_LED_OFF 3
  206. enum hub_led_mode {
  207. INDICATOR_AUTO = 0,
  208. INDICATOR_CYCLE,
  209. /* software blinks for attention: software, hardware, reserved */
  210. INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
  211. INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
  212. INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
  213. } __attribute__ ((packed));
  214. /* Transaction Translator Think Times, in bits */
  215. #define HUB_TTTT_8_BITS 0x00
  216. #define HUB_TTTT_16_BITS 0x20
  217. #define HUB_TTTT_24_BITS 0x40
  218. #define HUB_TTTT_32_BITS 0x60
  219. #endif /* __LINUX_CH11_H */