blob: 889c0f32a40b729431f2dab51d13aead39f5f3e8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_HUB_H
2#define __LINUX_HUB_H
3
4/*
5 * Hub protocol and driver data structures.
6 *
7 * Some of these are known to the "virtual root hub" code
8 * in host controller drivers.
9 */
10
11#include <linux/list.h>
12#include <linux/workqueue.h>
13#include <linux/compiler.h> /* likely()/unlikely() */
14
15/*
16 * Hub request types
17 */
18
19#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
20#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
21
22/*
23 * Hub class requests
24 * See USB 2.0 spec Table 11-16
25 */
26#define HUB_CLEAR_TT_BUFFER 8
27#define HUB_RESET_TT 9
28#define HUB_GET_TT_STATE 10
29#define HUB_STOP_TT 11
30
31/*
32 * Hub Class feature numbers
33 * See USB 2.0 spec Table 11-17
34 */
35#define C_HUB_LOCAL_POWER 0
36#define C_HUB_OVER_CURRENT 1
37
38/*
39 * Port feature numbers
40 * See USB 2.0 spec Table 11-17
41 */
42#define USB_PORT_FEAT_CONNECTION 0
43#define USB_PORT_FEAT_ENABLE 1
David Brownelldbe0dbb2008-02-10 12:24:00 -080044#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define USB_PORT_FEAT_OVER_CURRENT 3
46#define USB_PORT_FEAT_RESET 4
David Brownelldbe0dbb2008-02-10 12:24:00 -080047#define USB_PORT_FEAT_L1 5 /* L1 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define USB_PORT_FEAT_POWER 8
49#define USB_PORT_FEAT_LOWSPEED 9
Sarah Sharpd2e9b4d2009-04-27 19:55:01 -070050/* This value was never in Table 11-17 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define USB_PORT_FEAT_HIGHSPEED 10
Sarah Sharpd2e9b4d2009-04-27 19:55:01 -070052/* This value is also fake */
53#define USB_PORT_FEAT_SUPERSPEED 11
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define USB_PORT_FEAT_C_CONNECTION 16
55#define USB_PORT_FEAT_C_ENABLE 17
56#define USB_PORT_FEAT_C_SUSPEND 18
57#define USB_PORT_FEAT_C_OVER_CURRENT 19
58#define USB_PORT_FEAT_C_RESET 20
59#define USB_PORT_FEAT_TEST 21
60#define USB_PORT_FEAT_INDICATOR 22
David Brownelldbe0dbb2008-02-10 12:24:00 -080061#define USB_PORT_FEAT_C_PORT_L1 23
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080063/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 * Hub Status and Hub Change results
65 * See USB 2.0 spec Table 11-19 and Table 11-20
66 */
67struct usb_port_status {
68 __le16 wPortStatus;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080069 __le16 wPortChange;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070} __attribute__ ((packed));
71
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080072/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 * wPortStatus bit field
74 * See USB 2.0 spec Table 11-21
75 */
76#define USB_PORT_STAT_CONNECTION 0x0001
77#define USB_PORT_STAT_ENABLE 0x0002
78#define USB_PORT_STAT_SUSPEND 0x0004
79#define USB_PORT_STAT_OVERCURRENT 0x0008
80#define USB_PORT_STAT_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -080081#define USB_PORT_STAT_L1 0x0020
82/* bits 6 to 7 are reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#define USB_PORT_STAT_POWER 0x0100
84#define USB_PORT_STAT_LOW_SPEED 0x0200
85#define USB_PORT_STAT_HIGH_SPEED 0x0400
86#define USB_PORT_STAT_TEST 0x0800
87#define USB_PORT_STAT_INDICATOR 0x1000
88/* bits 13 to 15 are reserved */
89
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080090/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 * wPortChange bit field
92 * See USB 2.0 spec Table 11-22
93 * Bits 0 to 4 shown, bits 5 to 15 are reserved
94 */
95#define USB_PORT_STAT_C_CONNECTION 0x0001
96#define USB_PORT_STAT_C_ENABLE 0x0002
97#define USB_PORT_STAT_C_SUSPEND 0x0004
98#define USB_PORT_STAT_C_OVERCURRENT 0x0008
99#define USB_PORT_STAT_C_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -0800100#define USB_PORT_STAT_C_L1 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102/*
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800103 * wHubCharacteristics (masks)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 * See USB 2.0 spec Table 11-13, offset 3
105 */
106#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
107#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
108#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
109#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
110#define HUB_CHAR_PORTIND 0x0080 /* D7 */
111
112struct usb_hub_status {
113 __le16 wHubStatus;
114 __le16 wHubChange;
115} __attribute__ ((packed));
116
117/*
118 * Hub Status & Hub Change bit masks
119 * See USB 2.0 spec Table 11-19 and Table 11-20
120 * Bits 0 and 1 for wHubStatus and wHubChange
121 * Bits 2 to 15 are reserved for both
122 */
123#define HUB_STATUS_LOCAL_POWER 0x0001
124#define HUB_STATUS_OVERCURRENT 0x0002
125#define HUB_CHANGE_LOCAL_POWER 0x0001
126#define HUB_CHANGE_OVERCURRENT 0x0002
127
128
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800129/*
130 * Hub descriptor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 * See USB 2.0 spec Table 11-13
132 */
133
134#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
135#define USB_DT_HUB_NONVAR_SIZE 7
136
137struct usb_hub_descriptor {
138 __u8 bDescLength;
139 __u8 bDescriptorType;
140 __u8 bNbrPorts;
Greg Kroah-Hartman74ad9bd2005-06-20 21:15:16 -0700141 __le16 wHubCharacteristics;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 __u8 bPwrOn2PwrGood;
143 __u8 bHubContrCurrent;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800144 /* add 1 bit for hub status change; round to bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
146 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
147} __attribute__ ((packed));
148
149
150/* port indicator status selectors, tables 11-7 and 11-25 */
151#define HUB_LED_AUTO 0
152#define HUB_LED_AMBER 1
153#define HUB_LED_GREEN 2
154#define HUB_LED_OFF 3
155
156enum hub_led_mode {
157 INDICATOR_AUTO = 0,
158 INDICATOR_CYCLE,
159 /* software blinks for attention: software, hardware, reserved */
160 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
161 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
162 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
163} __attribute__ ((packed));
164
165struct usb_device;
166
david-b@pacbell.nete09711a2005-08-13 18:41:04 -0700167/* Transaction Translator Think Times, in bits */
168#define HUB_TTTT_8_BITS 0x00
169#define HUB_TTTT_16_BITS 0x20
170#define HUB_TTTT_24_BITS 0x40
171#define HUB_TTTT_32_BITS 0x60
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173/*
174 * As of USB 2.0, full/low speed devices are segregated into trees.
175 * One type grows from USB 1.1 host controllers (OHCI, UHCI etc).
176 * The other type grows from high speed hubs when they connect to
177 * full/low speed devices using "Transaction Translators" (TTs).
178 *
179 * TTs should only be known to the hub driver, and high speed bus
180 * drivers (only EHCI for now). They affect periodic scheduling and
181 * sometimes control/bulk error recovery.
182 */
183struct usb_tt {
184 struct usb_device *hub; /* upstream highspeed hub */
185 int multi; /* true means one TT per port */
david-b@pacbell.nete09711a2005-08-13 18:41:04 -0700186 unsigned think_time; /* think time in ns */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188 /* for control/bulk error recovery (CLEAR_TT_BUFFER) */
189 spinlock_t lock;
190 struct list_head clear_list; /* of usb_tt_clear */
191 struct work_struct kevent;
192};
193
194struct usb_tt_clear {
195 struct list_head clear_list;
196 unsigned tt;
197 u16 devinfo;
198};
199
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800200extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe);
Inaky Perez-Gonzalezfc721f52008-04-08 13:24:46 -0700201extern void usb_ep0_reinit(struct usb_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#endif /* __LINUX_HUB_H */