Eric Lescouet | d20db4b | 2010-04-24 23:38:17 +0200 | [diff] [blame] | 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 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame] | 9 | #ifndef __LINUX_CH11_H |
| 10 | #define __LINUX_CH11_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame] | 12 | #include <linux/types.h> /* __u8 etc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Alan Stern | 36ff66d | 2013-06-27 15:27:07 -0400 | [diff] [blame^] | 14 | /* This is arbitrary. |
| 15 | * From USB 2.0 spec Table 11-13, offset 7, a hub can |
| 16 | * have up to 255 ports. The most yet reported is 10. |
| 17 | * |
| 18 | * Current Wireless USB host hardware (Intel i1480 for example) allows |
| 19 | * up to 22 devices to connect. Upcoming hardware might raise that |
| 20 | * limit. Because the arrays need to add a bit for hub status data, we |
| 21 | * use 31, so plus one evens out to four bytes. |
| 22 | */ |
| 23 | #define USB_MAXCHILDREN 31 |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | /* |
| 26 | * Hub request types |
| 27 | */ |
| 28 | |
| 29 | #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) |
| 30 | #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) |
| 31 | |
| 32 | /* |
| 33 | * Hub class requests |
| 34 | * See USB 2.0 spec Table 11-16 |
| 35 | */ |
| 36 | #define HUB_CLEAR_TT_BUFFER 8 |
| 37 | #define HUB_RESET_TT 9 |
| 38 | #define HUB_GET_TT_STATE 10 |
| 39 | #define HUB_STOP_TT 11 |
| 40 | |
| 41 | /* |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 42 | * Hub class additional requests defined by USB 3.0 spec |
| 43 | * See USB 3.0 spec Table 10-6 |
| 44 | */ |
| 45 | #define HUB_SET_DEPTH 12 |
| 46 | #define HUB_GET_PORT_ERR_COUNT 13 |
| 47 | |
| 48 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | * Hub Class feature numbers |
| 50 | * See USB 2.0 spec Table 11-17 |
| 51 | */ |
| 52 | #define C_HUB_LOCAL_POWER 0 |
| 53 | #define C_HUB_OVER_CURRENT 1 |
| 54 | |
| 55 | /* |
| 56 | * Port feature numbers |
| 57 | * See USB 2.0 spec Table 11-17 |
| 58 | */ |
| 59 | #define USB_PORT_FEAT_CONNECTION 0 |
| 60 | #define USB_PORT_FEAT_ENABLE 1 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 61 | #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #define USB_PORT_FEAT_OVER_CURRENT 3 |
| 63 | #define USB_PORT_FEAT_RESET 4 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 64 | #define USB_PORT_FEAT_L1 5 /* L1 suspend */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define USB_PORT_FEAT_POWER 8 |
Alan Stern | 288ead4 | 2010-03-04 11:32:30 -0500 | [diff] [blame] | 66 | #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #define USB_PORT_FEAT_C_CONNECTION 16 |
| 68 | #define USB_PORT_FEAT_C_ENABLE 17 |
| 69 | #define USB_PORT_FEAT_C_SUSPEND 18 |
| 70 | #define USB_PORT_FEAT_C_OVER_CURRENT 19 |
| 71 | #define USB_PORT_FEAT_C_RESET 20 |
| 72 | #define USB_PORT_FEAT_TEST 21 |
| 73 | #define USB_PORT_FEAT_INDICATOR 22 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 74 | #define USB_PORT_FEAT_C_PORT_L1 23 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 76 | /* |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 77 | * Port feature selectors added by USB 3.0 spec. |
| 78 | * See USB 3.0 spec Table 10-7 |
| 79 | */ |
| 80 | #define USB_PORT_FEAT_LINK_STATE 5 |
| 81 | #define USB_PORT_FEAT_U1_TIMEOUT 23 |
| 82 | #define USB_PORT_FEAT_U2_TIMEOUT 24 |
Sarah Sharp | d9f5343 | 2012-01-05 16:28:54 -0800 | [diff] [blame] | 83 | #define USB_PORT_FEAT_C_PORT_LINK_STATE 25 |
| 84 | #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26 |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 85 | #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27 |
| 86 | #define USB_PORT_FEAT_BH_PORT_RESET 28 |
| 87 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 |
| 88 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 |
| 89 | |
Sarah Sharp | 1ea7e0e | 2012-04-24 17:21:50 -0700 | [diff] [blame] | 90 | #define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8) |
| 91 | |
Sarah Sharp | 4296c70a | 2012-01-06 10:34:31 -0800 | [diff] [blame] | 92 | /* USB 3.0 hub remote wake mask bits, see table 10-14 */ |
| 93 | #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) |
| 94 | #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) |
| 95 | #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) |
| 96 | |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 97 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | * Hub Status and Hub Change results |
| 99 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
| 100 | */ |
| 101 | struct usb_port_status { |
| 102 | __le16 wPortStatus; |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 103 | __le16 wPortChange; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } __attribute__ ((packed)); |
| 105 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 106 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | * wPortStatus bit field |
| 108 | * See USB 2.0 spec Table 11-21 |
| 109 | */ |
| 110 | #define USB_PORT_STAT_CONNECTION 0x0001 |
| 111 | #define USB_PORT_STAT_ENABLE 0x0002 |
| 112 | #define USB_PORT_STAT_SUSPEND 0x0004 |
| 113 | #define USB_PORT_STAT_OVERCURRENT 0x0008 |
| 114 | #define USB_PORT_STAT_RESET 0x0010 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 115 | #define USB_PORT_STAT_L1 0x0020 |
| 116 | /* bits 6 to 7 are reserved */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | #define USB_PORT_STAT_POWER 0x0100 |
| 118 | #define USB_PORT_STAT_LOW_SPEED 0x0200 |
| 119 | #define USB_PORT_STAT_HIGH_SPEED 0x0400 |
| 120 | #define USB_PORT_STAT_TEST 0x0800 |
| 121 | #define USB_PORT_STAT_INDICATOR 0x1000 |
| 122 | /* bits 13 to 15 are reserved */ |
| 123 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 124 | /* |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 125 | * Additions to wPortStatus bit field from USB 3.0 |
| 126 | * See USB 3.0 spec Table 10-10 |
| 127 | */ |
| 128 | #define USB_PORT_STAT_LINK_STATE 0x01e0 |
| 129 | #define USB_SS_PORT_STAT_POWER 0x0200 |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 130 | #define USB_SS_PORT_STAT_SPEED 0x1c00 |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 131 | #define USB_PORT_STAT_SPEED_5GBPS 0x0000 |
| 132 | /* Valid only if port is enabled */ |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 133 | /* Bits that are the same from USB 2.0 */ |
| 134 | #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \ |
| 135 | USB_PORT_STAT_ENABLE | \ |
| 136 | USB_PORT_STAT_OVERCURRENT | \ |
| 137 | USB_PORT_STAT_RESET) |
Tatyana Brokhman | 0eadcc0 | 2010-11-01 18:18:24 +0200 | [diff] [blame] | 138 | |
| 139 | /* |
| 140 | * Definitions for PORT_LINK_STATE values |
| 141 | * (bits 5-8) in wPortStatus |
| 142 | */ |
| 143 | #define USB_SS_PORT_LS_U0 0x0000 |
| 144 | #define USB_SS_PORT_LS_U1 0x0020 |
| 145 | #define USB_SS_PORT_LS_U2 0x0040 |
| 146 | #define USB_SS_PORT_LS_U3 0x0060 |
| 147 | #define USB_SS_PORT_LS_SS_DISABLED 0x0080 |
| 148 | #define USB_SS_PORT_LS_RX_DETECT 0x00a0 |
| 149 | #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0 |
| 150 | #define USB_SS_PORT_LS_POLLING 0x00e0 |
| 151 | #define USB_SS_PORT_LS_RECOVERY 0x0100 |
| 152 | #define USB_SS_PORT_LS_HOT_RESET 0x0120 |
| 153 | #define USB_SS_PORT_LS_COMP_MOD 0x0140 |
| 154 | #define USB_SS_PORT_LS_LOOPBACK 0x0160 |
| 155 | |
| 156 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | * wPortChange bit field |
Paul Bolle | b9f2e9a | 2011-02-14 23:06:15 +0100 | [diff] [blame] | 158 | * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 |
| 159 | * Bits 0 to 5 shown, bits 6 to 15 are reserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | */ |
| 161 | #define USB_PORT_STAT_C_CONNECTION 0x0001 |
| 162 | #define USB_PORT_STAT_C_ENABLE 0x0002 |
| 163 | #define USB_PORT_STAT_C_SUSPEND 0x0004 |
| 164 | #define USB_PORT_STAT_C_OVERCURRENT 0x0008 |
| 165 | #define USB_PORT_STAT_C_RESET 0x0010 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 166 | #define USB_PORT_STAT_C_L1 0x0020 |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 167 | /* |
| 168 | * USB 3.0 wPortChange bit fields |
| 169 | * See USB 3.0 spec Table 10-11 |
| 170 | */ |
| 171 | #define USB_PORT_STAT_C_BH_RESET 0x0020 |
| 172 | #define USB_PORT_STAT_C_LINK_STATE 0x0040 |
| 173 | #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | /* |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 176 | * wHubCharacteristics (masks) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | * See USB 2.0 spec Table 11-13, offset 3 |
| 178 | */ |
Aman Deep | c842114 | 2011-11-22 19:33:36 +0530 | [diff] [blame] | 179 | #define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */ |
| 180 | #define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */ |
| 181 | #define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */ |
| 182 | #define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */ |
| 183 | |
| 184 | #define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */ |
| 185 | |
| 186 | #define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */ |
| 187 | #define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */ |
| 188 | #define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */ |
| 189 | #define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */ |
| 190 | |
| 191 | #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */ |
| 192 | #define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
| 194 | struct usb_hub_status { |
| 195 | __le16 wHubStatus; |
| 196 | __le16 wHubChange; |
| 197 | } __attribute__ ((packed)); |
| 198 | |
| 199 | /* |
| 200 | * Hub Status & Hub Change bit masks |
| 201 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
| 202 | * Bits 0 and 1 for wHubStatus and wHubChange |
| 203 | * Bits 2 to 15 are reserved for both |
| 204 | */ |
| 205 | #define HUB_STATUS_LOCAL_POWER 0x0001 |
| 206 | #define HUB_STATUS_OVERCURRENT 0x0002 |
| 207 | #define HUB_CHANGE_LOCAL_POWER 0x0001 |
| 208 | #define HUB_CHANGE_OVERCURRENT 0x0002 |
| 209 | |
| 210 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 211 | /* |
| 212 | * Hub descriptor |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | * See USB 2.0 spec Table 11-13 |
| 214 | */ |
| 215 | |
| 216 | #define USB_DT_HUB (USB_TYPE_CLASS | 0x09) |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 217 | #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | #define USB_DT_HUB_NONVAR_SIZE 7 |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 219 | #define USB_DT_SS_HUB_SIZE 12 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Aman Deep | 7bf0118 | 2011-12-08 12:05:22 +0530 | [diff] [blame] | 221 | /* |
| 222 | * Hub Device descriptor |
| 223 | * USB Hub class device protocols |
| 224 | */ |
| 225 | |
| 226 | #define USB_HUB_PR_FS 0 /* Full speed hub */ |
| 227 | #define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */ |
| 228 | #define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */ |
| 229 | #define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */ |
| 230 | #define USB_HUB_PR_SS 3 /* Super speed hub */ |
| 231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | struct usb_hub_descriptor { |
| 233 | __u8 bDescLength; |
| 234 | __u8 bDescriptorType; |
| 235 | __u8 bNbrPorts; |
Greg Kroah-Hartman | 74ad9bd | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 236 | __le16 wHubCharacteristics; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | __u8 bPwrOn2PwrGood; |
| 238 | __u8 bHubContrCurrent; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 240 | /* 2.0 and 3.0 hubs differ here */ |
| 241 | union { |
| 242 | struct { |
| 243 | /* add 1 bit for hub status change; round to bytes */ |
| 244 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; |
| 245 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; |
| 246 | } __attribute__ ((packed)) hs; |
| 247 | |
| 248 | struct { |
| 249 | __u8 bHubHdrDecLat; |
Lan Tianyu | 9c20890 | 2012-09-10 21:24:41 +0800 | [diff] [blame] | 250 | __le16 wHubDelay; |
| 251 | __le16 DeviceRemovable; |
John Youn | dbe79bb | 2001-09-17 00:00:00 -0700 | [diff] [blame] | 252 | } __attribute__ ((packed)) ss; |
| 253 | } u; |
| 254 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | /* port indicator status selectors, tables 11-7 and 11-25 */ |
| 257 | #define HUB_LED_AUTO 0 |
| 258 | #define HUB_LED_AMBER 1 |
| 259 | #define HUB_LED_GREEN 2 |
| 260 | #define HUB_LED_OFF 3 |
| 261 | |
| 262 | enum hub_led_mode { |
| 263 | INDICATOR_AUTO = 0, |
| 264 | INDICATOR_CYCLE, |
| 265 | /* software blinks for attention: software, hardware, reserved */ |
| 266 | INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF, |
| 267 | INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF, |
| 268 | INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF |
| 269 | } __attribute__ ((packed)); |
| 270 | |
david-b@pacbell.net | e09711a | 2005-08-13 18:41:04 -0700 | [diff] [blame] | 271 | /* Transaction Translator Think Times, in bits */ |
| 272 | #define HUB_TTTT_8_BITS 0x00 |
| 273 | #define HUB_TTTT_16_BITS 0x20 |
| 274 | #define HUB_TTTT_24_BITS 0x40 |
| 275 | #define HUB_TTTT_32_BITS 0x60 |
| 276 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame] | 277 | #endif /* __LINUX_CH11_H */ |