ch11.h 4.5 KB

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