Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


ch11.h
001: /*
002:  * This file holds Hub protocol constants and data structures that are
003:  * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
004:  *
005:  * It is used/shared between the USB core, the HCDs and couple of other USB
006:  * drivers.
007:  */
008: 
009: #ifndef __LINUX_CH11_H
010: #define __LINUX_CH11_H
011: 
012: #include <linux/types.h>        /* __u8 etc */
013: 
014: /*
015:  * Hub request types
016:  */
017: 
018: #define USB_RT_HUB      (USB_TYPE_CLASS | USB_RECIP_DEVICE)
019: #define USB_RT_PORT     (USB_TYPE_CLASS | USB_RECIP_OTHER)
020: 
021: /*
022:  * Hub class requests
023:  * See USB 2.0 spec Table 11-16
024:  */
025: #define HUB_CLEAR_TT_BUFFER     8
026: #define HUB_RESET_TT            9
027: #define HUB_GET_TT_STATE        10
028: #define HUB_STOP_TT             11
029: #define HUB_SET_DEPTH           12
030: 
031: /*
032:  * Hub class additional requests defined by USB 3.0 spec
033:  * See USB 3.0 spec Table 10-6
034:  */
035: #define HUB_SET_DEPTH           12
036: #define HUB_GET_PORT_ERR_COUNT  13
037: 
038: /*
039:  * Hub Class feature numbers
040:  * See USB 2.0 spec Table 11-17
041:  */
042: #define C_HUB_LOCAL_POWER       0
043: #define C_HUB_OVER_CURRENT      1
044: 
045: /*
046:  * Port feature numbers
047:  * See USB 2.0 spec Table 11-17
048:  */
049: #define USB_PORT_FEAT_CONNECTION        0
050: #define USB_PORT_FEAT_ENABLE            1
051: #define USB_PORT_FEAT_SUSPEND           2       /* L2 suspend */
052: #define USB_PORT_FEAT_OVER_CURRENT      3
053: #define USB_PORT_FEAT_RESET             4
054: #define USB_PORT_FEAT_L1                5       /* L1 suspend */
055: #define USB_PORT_FEAT_POWER             8
056: #define USB_PORT_FEAT_LOWSPEED          9       /* Should never be used */
057: #define USB_PORT_FEAT_C_CONNECTION      16
058: #define USB_PORT_FEAT_C_ENABLE          17
059: #define USB_PORT_FEAT_C_SUSPEND         18
060: #define USB_PORT_FEAT_C_OVER_CURRENT    19
061: #define USB_PORT_FEAT_C_RESET           20
062: #define USB_PORT_FEAT_TEST              21
063: #define USB_PORT_FEAT_INDICATOR         22
064: #define USB_PORT_FEAT_C_PORT_L1         23
065: 
066: /*
067:  * Port feature selectors added by USB 3.0 spec.
068:  * See USB 3.0 spec Table 10-7
069:  */
070: #define USB_PORT_FEAT_LINK_STATE                5
071: #define USB_PORT_FEAT_U1_TIMEOUT                23
072: #define USB_PORT_FEAT_U2_TIMEOUT                24
073: #define USB_PORT_FEAT_C_PORT_LINK_STATE         25
074: #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR       26
075: #define USB_PORT_FEAT_REMOTE_WAKE_MASK          27
076: #define USB_PORT_FEAT_BH_PORT_RESET             28
077: #define USB_PORT_FEAT_C_BH_PORT_RESET           29
078: #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT       30
079: 
080: /*
081:  * Hub Status and Hub Change results
082:  * See USB 2.0 spec Table 11-19 and Table 11-20
083:  */
084: struct usb_port_status {
085:         __le16 wPortStatus;
086:         __le16 wPortChange;
087: } __attribute__ ((packed));
088: 
089: /*
090:  * wPortStatus bit field
091:  * See USB 2.0 spec Table 11-21
092:  */
093: #define USB_PORT_STAT_CONNECTION        0x0001
094: #define USB_PORT_STAT_ENABLE            0x0002
095: #define USB_PORT_STAT_SUSPEND           0x0004
096: #define USB_PORT_STAT_OVERCURRENT       0x0008
097: #define USB_PORT_STAT_RESET             0x0010
098: #define USB_PORT_STAT_L1                0x0020
099: /* bits 6 to 7 are reserved */
100: #define USB_PORT_STAT_POWER             0x0100
101: #define USB_PORT_STAT_LOW_SPEED         0x0200
102: #define USB_PORT_STAT_HIGH_SPEED        0x0400
103: #define USB_PORT_STAT_TEST              0x0800
104: #define USB_PORT_STAT_INDICATOR         0x1000
105: /* bits 13 to 15 are reserved */
106: 
107: /*
108:  * Additions to wPortStatus bit field from USB 3.0
109:  * See USB 3.0 spec Table 10-10
110:  */
111: #define USB_PORT_STAT_LINK_STATE        0x01e0
112: #define USB_SS_PORT_STAT_POWER          0x0200
113: #define USB_SS_PORT_STAT_SPEED          0x1c00
114: #define USB_PORT_STAT_SPEED_5GBPS       0x0000
115: /* Valid only if port is enabled */
116: /* Bits that are the same from USB 2.0 */
117: #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION |           \
118:                                 USB_PORT_STAT_ENABLE |      \
119:                                 USB_PORT_STAT_OVERCURRENT | \
120:                                 USB_PORT_STAT_RESET)
121: 
122: /*
123:  * Definitions for PORT_LINK_STATE values
124:  * (bits 5-8) in wPortStatus
125:  */
126: #define USB_SS_PORT_LS_U0               0x0000
127: #define USB_SS_PORT_LS_U1               0x0020
128: #define USB_SS_PORT_LS_U2               0x0040
129: #define USB_SS_PORT_LS_U3               0x0060
130: #define USB_SS_PORT_LS_SS_DISABLED      0x0080
131: #define USB_SS_PORT_LS_RX_DETECT        0x00a0
132: #define USB_SS_PORT_LS_SS_INACTIVE      0x00c0
133: #define USB_SS_PORT_LS_POLLING          0x00e0
134: #define USB_SS_PORT_LS_RECOVERY         0x0100
135: #define USB_SS_PORT_LS_HOT_RESET        0x0120
136: #define USB_SS_PORT_LS_COMP_MOD         0x0140
137: #define USB_SS_PORT_LS_LOOPBACK         0x0160
138: 
139: /*
140:  * wPortChange bit field
141:  * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
142:  * Bits 0 to 5 shown, bits 6 to 15 are reserved
143:  */
144: #define USB_PORT_STAT_C_CONNECTION      0x0001
145: #define USB_PORT_STAT_C_ENABLE          0x0002
146: #define USB_PORT_STAT_C_SUSPEND         0x0004
147: #define USB_PORT_STAT_C_OVERCURRENT     0x0008
148: #define USB_PORT_STAT_C_RESET           0x0010
149: #define USB_PORT_STAT_C_L1              0x0020
150: /*
151:  * USB 3.0 wPortChange bit fields
152:  * See USB 3.0 spec Table 10-11
153:  */
154: #define USB_PORT_STAT_C_BH_RESET        0x0020
155: #define USB_PORT_STAT_C_LINK_STATE      0x0040
156: #define USB_PORT_STAT_C_CONFIG_ERROR    0x0080
157: 
158: /*
159:  * wHubCharacteristics (masks)
160:  * See USB 2.0 spec Table 11-13, offset 3
161:  */
162: #define HUB_CHAR_LPSM           0x0003 /* D1 .. D0 */
163: #define HUB_CHAR_COMPOUND       0x0004 /* D2       */
164: #define HUB_CHAR_OCPM           0x0018 /* D4 .. D3 */
165: #define HUB_CHAR_TTTT           0x0060 /* D6 .. D5 */
166: #define HUB_CHAR_PORTIND        0x0080 /* D7       */
167: 
168: struct usb_hub_status {
169:         __le16 wHubStatus;
170:         __le16 wHubChange;
171: } __attribute__ ((packed));
172: 
173: /*
174:  * Hub Status & Hub Change bit masks
175:  * See USB 2.0 spec Table 11-19 and Table 11-20
176:  * Bits 0 and 1 for wHubStatus and wHubChange
177:  * Bits 2 to 15 are reserved for both
178:  */
179: #define HUB_STATUS_LOCAL_POWER  0x0001
180: #define HUB_STATUS_OVERCURRENT  0x0002
181: #define HUB_CHANGE_LOCAL_POWER  0x0001
182: #define HUB_CHANGE_OVERCURRENT  0x0002
183: 
184: 
185: /*
186:  * Hub descriptor
187:  * See USB 2.0 spec Table 11-13
188:  */
189: 
190: #define USB_DT_HUB                      (USB_TYPE_CLASS | 0x09)
191: #define USB_DT_SS_HUB                   (USB_TYPE_CLASS | 0x0a)
192: #define USB_DT_HUB_NONVAR_SIZE          7
193: #define USB_DT_SS_HUB_SIZE              12
194: 
195: struct usb_hub_descriptor {
196:         __u8  bDescLength;
197:         __u8  bDescriptorType;
198:         __u8  bNbrPorts;
199:         __le16 wHubCharacteristics;
200:         __u8  bPwrOn2PwrGood;
201:         __u8  bHubContrCurrent;
202: 
203:         /* 2.0 and 3.0 hubs differ here */
204:         union {
205:                 struct {
206:                         /* add 1 bit for hub status change; round to bytes */
207:                         __u8  DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
208:                         __u8  PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
209:                 }  __attribute__ ((packed)) hs;
210: 
211:                 struct {
212:                         __u8 bHubHdrDecLat;
213:                         __u16 wHubDelay;
214:                         __u16 DeviceRemovable;
215:                 }  __attribute__ ((packed)) ss;
216:         } u;
217: } __attribute__ ((packed));
218: 
219: /* port indicator status selectors, tables 11-7 and 11-25 */
220: #define HUB_LED_AUTO    0
221: #define HUB_LED_AMBER   1
222: #define HUB_LED_GREEN   2
223: #define HUB_LED_OFF     3
224: 
225: enum hub_led_mode {
226:         INDICATOR_AUTO = 0,
227:         INDICATOR_CYCLE,
228:         /* software blinks for attention:  software, hardware, reserved */
229:         INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
230:         INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
231:         INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
232: } __attribute__ ((packed));
233: 
234: /* Transaction Translator Think Times, in bits */
235: #define HUB_TTTT_8_BITS         0x00
236: #define HUB_TTTT_16_BITS        0x20
237: #define HUB_TTTT_24_BITS        0x40
238: #define HUB_TTTT_32_BITS        0x60
239: 
240: #endif /* __LINUX_CH11_H */
241: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/