ch11.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /*
  25. * Hub Class feature numbers
  26. * See USB 2.0 spec Table 11-17
  27. */
  28. #define C_HUB_LOCAL_POWER 0
  29. #define C_HUB_OVER_CURRENT 1
  30. /*
  31. * Port feature numbers
  32. * See USB 2.0 spec Table 11-17
  33. */
  34. #define USB_PORT_FEAT_CONNECTION 0
  35. #define USB_PORT_FEAT_ENABLE 1
  36. #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
  37. #define USB_PORT_FEAT_OVER_CURRENT 3
  38. #define USB_PORT_FEAT_RESET 4
  39. #define USB_PORT_FEAT_L1 5 /* L1 suspend */
  40. #define USB_PORT_FEAT_POWER 8
  41. #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
  42. #define USB_PORT_FEAT_C_CONNECTION 16
  43. #define USB_PORT_FEAT_C_ENABLE 17
  44. #define USB_PORT_FEAT_C_SUSPEND 18
  45. #define USB_PORT_FEAT_C_OVER_CURRENT 19
  46. #define USB_PORT_FEAT_C_RESET 20
  47. #define USB_PORT_FEAT_TEST 21
  48. #define USB_PORT_FEAT_INDICATOR 22
  49. #define USB_PORT_FEAT_C_PORT_L1 23
  50. /*
  51. * Hub Status and Hub Change results
  52. * See USB 2.0 spec Table 11-19 and Table 11-20
  53. */
  54. struct usb_port_status {
  55. __le16 wPortStatus;
  56. __le16 wPortChange;
  57. } __attribute__ ((packed));
  58. /*
  59. * wPortStatus bit field
  60. * See USB 2.0 spec Table 11-21
  61. */
  62. #define USB_PORT_STAT_CONNECTION 0x0001
  63. #define USB_PORT_STAT_ENABLE 0x0002
  64. #define USB_PORT_STAT_SUSPEND 0x0004
  65. #define USB_PORT_STAT_OVERCURRENT 0x0008
  66. #define USB_PORT_STAT_RESET 0x0010
  67. #define USB_PORT_STAT_L1 0x0020
  68. /* bits 6 to 7 are reserved */
  69. #define USB_PORT_STAT_POWER 0x0100
  70. #define USB_PORT_STAT_LOW_SPEED 0x0200
  71. #define USB_PORT_STAT_HIGH_SPEED 0x0400
  72. #define USB_PORT_STAT_TEST 0x0800
  73. #define USB_PORT_STAT_INDICATOR 0x1000
  74. /* bits 13 to 15 are reserved */
  75. #define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */
  76. /*
  77. * wPortChange bit field
  78. * See USB 2.0 spec Table 11-22
  79. * Bits 0 to 4 shown, bits 5 to 15 are reserved
  80. */
  81. #define USB_PORT_STAT_C_CONNECTION 0x0001
  82. #define USB_PORT_STAT_C_ENABLE 0x0002
  83. #define USB_PORT_STAT_C_SUSPEND 0x0004
  84. #define USB_PORT_STAT_C_OVERCURRENT 0x0008
  85. #define USB_PORT_STAT_C_RESET 0x0010
  86. #define USB_PORT_STAT_C_L1 0x0020
  87. /*
  88. * wHubCharacteristics (masks)
  89. * See USB 2.0 spec Table 11-13, offset 3
  90. */
  91. #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
  92. #define HUB_CHAR_COMPOUND 0x0004 /* D2 */
  93. #define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
  94. #define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
  95. #define HUB_CHAR_PORTIND 0x0080 /* D7 */
  96. struct usb_hub_status {
  97. __le16 wHubStatus;
  98. __le16 wHubChange;
  99. } __attribute__ ((packed));
  100. /*
  101. * Hub Status & Hub Change bit masks
  102. * See USB 2.0 spec Table 11-19 and Table 11-20
  103. * Bits 0 and 1 for wHubStatus and wHubChange
  104. * Bits 2 to 15 are reserved for both
  105. */
  106. #define HUB_STATUS_LOCAL_POWER 0x0001
  107. #define HUB_STATUS_OVERCURRENT 0x0002
  108. #define HUB_CHANGE_LOCAL_POWER 0x0001
  109. #define HUB_CHANGE_OVERCURRENT 0x0002
  110. /*
  111. * Hub descriptor
  112. * See USB 2.0 spec Table 11-13
  113. */
  114. #define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
  115. #define USB_DT_HUB_NONVAR_SIZE 7
  116. struct usb_hub_descriptor {
  117. __u8 bDescLength;
  118. __u8 bDescriptorType;
  119. __u8 bNbrPorts;
  120. __le16 wHubCharacteristics;
  121. __u8 bPwrOn2PwrGood;
  122. __u8 bHubContrCurrent;
  123. /* add 1 bit for hub status change; round to bytes */
  124. __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
  125. __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
  126. } __attribute__ ((packed));
  127. /* port indicator status selectors, tables 11-7 and 11-25 */
  128. #define HUB_LED_AUTO 0
  129. #define HUB_LED_AMBER 1
  130. #define HUB_LED_GREEN 2
  131. #define HUB_LED_OFF 3
  132. enum hub_led_mode {
  133. INDICATOR_AUTO = 0,
  134. INDICATOR_CYCLE,
  135. /* software blinks for attention: software, hardware, reserved */
  136. INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
  137. INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
  138. INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
  139. } __attribute__ ((packed));
  140. /* Transaction Translator Think Times, in bits */
  141. #define HUB_TTTT_8_BITS 0x00
  142. #define HUB_TTTT_16_BITS 0x20
  143. #define HUB_TTTT_24_BITS 0x40
  144. #define HUB_TTTT_32_BITS 0x60
  145. #endif /* __LINUX_CH11_H */