4 #include <linux/list.h>
5 #include <linux/compiler.h> /* likely()/unlikely() */
11 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
12 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
15 * Hub Class feature numbers
16 * See USB 2.0 spec Table 11-17
18 #define C_HUB_LOCAL_POWER 0
19 #define C_HUB_OVER_CURRENT 1
22 * Port feature numbers
23 * See USB 2.0 spec Table 11-17
25 #define USB_PORT_FEAT_CONNECTION 0
26 #define USB_PORT_FEAT_ENABLE 1
27 #define USB_PORT_FEAT_SUSPEND 2
28 #define USB_PORT_FEAT_OVER_CURRENT 3
29 #define USB_PORT_FEAT_RESET 4
30 #define USB_PORT_FEAT_POWER 8
31 #define USB_PORT_FEAT_LOWSPEED 9
32 #define USB_PORT_FEAT_HIGHSPEED 10
33 #define USB_PORT_FEAT_C_CONNECTION 16
34 #define USB_PORT_FEAT_C_ENABLE 17
35 #define USB_PORT_FEAT_C_SUSPEND 18
36 #define USB_PORT_FEAT_C_OVER_CURRENT 19
37 #define USB_PORT_FEAT_C_RESET 20
38 #define USB_PORT_FEAT_TEST 21
39 #define USB_PORT_FEAT_INDICATOR 22
42 * Hub Status and Hub Change results
43 * See USB 2.0 spec Table 11-19 and Table 11-20
45 struct usb_port_status {
48 } __attribute__ ((packed));
51 * wPortStatus bit field
52 * See USB 2.0 spec Table 11-21
54 #define USB_PORT_STAT_CONNECTION 0x0001
55 #define USB_PORT_STAT_ENABLE 0x0002
56 #define USB_PORT_STAT_SUSPEND 0x0004
57 #define USB_PORT_STAT_OVERCURRENT 0x0008
58 #define USB_PORT_STAT_RESET 0x0010
59 /* bits 5 for 7 are reserved */
60 #define USB_PORT_STAT_POWER 0x0100
61 #define USB_PORT_STAT_LOW_SPEED 0x0200
62 #define USB_PORT_STAT_HIGH_SPEED 0x0400
63 #define USB_PORT_STAT_TEST 0x0800
64 #define USB_PORT_STAT_INDICATOR 0x1000
65 /* bits 13 to 15 are reserved */
68 * wPortChange bit field
69 * See USB 2.0 spec Table 11-22
70 * Bits 0 to 4 shown, bits 5 to 15 are reserved
72 #define USB_PORT_STAT_C_CONNECTION 0x0001
73 #define USB_PORT_STAT_C_ENABLE 0x0002
74 #define USB_PORT_STAT_C_SUSPEND 0x0004
75 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
76 #define USB_PORT_STAT_C_RESET 0x0010
79 * wHubCharacteristics (masks)
80 * See USB 2.0 spec Table 11-13, offset 3
82 #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
83 #define HUB_CHAR_COMPOUND 0x0004 /* D2 */
84 #define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
85 #define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
86 #define HUB_CHAR_PORTIND 0x0080 /* D7 */
88 struct usb_hub_status {
91 } __attribute__ ((packed));
94 * Hub Status & Hub Change bit masks
95 * See USB 2.0 spec Table 11-19 and Table 11-20
96 * Bits 0 and 1 for wHubStatus and wHubChange
97 * Bits 2 to 15 are reserved for both
99 #define HUB_STATUS_LOCAL_POWER 0x0001
100 #define HUB_STATUS_OVERCURRENT 0x0002
101 #define HUB_CHANGE_LOCAL_POWER 0x0001
102 #define HUB_CHANGE_OVERCURRENT 0x0002
107 * See USB 2.0 spec Table 11-13
109 struct usb_hub_descriptor {
111 __u8 bDescriptorType;
113 __u16 wHubCharacteristics;
115 __u8 bHubContrCurrent;
116 /* add 1 bit for hub status change; round to bytes */
117 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
118 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
119 } __attribute__ ((packed));
124 struct usb_device *dev;
126 struct urb *urb; /* Interrupt polling pipe */
128 char buffer[(USB_MAXCHILDREN + 1 + 7) / 8]; /* add 1 bit for hub status change */
129 /* and add 7 bits to round up to byte boundary */
133 struct list_head hub_list;
135 struct list_head event_list;
137 struct usb_hub_descriptor *descriptor;
139 struct semaphore khubd_sem;
140 struct usb_tt tt; /* Transaction Translator */
143 #endif /* __LINUX_HUB_H */