blob: 119194c85d1086fc8374672b5a9297cdb4f6a9e9 [file] [log] [blame]
Eric Lescouetd20db4b2010-04-24 23:38:17 +02001/*
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 Stern3b02ca32010-04-30 12:42:23 -04009#ifndef __LINUX_CH11_H
10#define __LINUX_CH11_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Alan Stern3b02ca32010-04-30 12:42:23 -040012#include <linux/types.h> /* __u8 etc */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14/*
15 * Hub request types
16 */
17
18#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
19#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
20
21/*
22 * Hub class requests
23 * See USB 2.0 spec Table 11-16
24 */
25#define HUB_CLEAR_TT_BUFFER 8
26#define HUB_RESET_TT 9
27#define HUB_GET_TT_STATE 10
28#define HUB_STOP_TT 11
29
30/*
31 * Hub Class feature numbers
32 * See USB 2.0 spec Table 11-17
33 */
34#define C_HUB_LOCAL_POWER 0
35#define C_HUB_OVER_CURRENT 1
36
37/*
38 * Port feature numbers
39 * See USB 2.0 spec Table 11-17
40 */
41#define USB_PORT_FEAT_CONNECTION 0
42#define USB_PORT_FEAT_ENABLE 1
David Brownelldbe0dbb2008-02-10 12:24:00 -080043#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define USB_PORT_FEAT_OVER_CURRENT 3
45#define USB_PORT_FEAT_RESET 4
David Brownelldbe0dbb2008-02-10 12:24:00 -080046#define USB_PORT_FEAT_L1 5 /* L1 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define USB_PORT_FEAT_POWER 8
Alan Stern288ead42010-03-04 11:32:30 -050048#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define USB_PORT_FEAT_C_CONNECTION 16
50#define USB_PORT_FEAT_C_ENABLE 17
51#define USB_PORT_FEAT_C_SUSPEND 18
52#define USB_PORT_FEAT_C_OVER_CURRENT 19
53#define USB_PORT_FEAT_C_RESET 20
54#define USB_PORT_FEAT_TEST 21
55#define USB_PORT_FEAT_INDICATOR 22
David Brownelldbe0dbb2008-02-10 12:24:00 -080056#define USB_PORT_FEAT_C_PORT_L1 23
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080058/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 * Hub Status and Hub Change results
60 * See USB 2.0 spec Table 11-19 and Table 11-20
61 */
62struct usb_port_status {
63 __le16 wPortStatus;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080064 __le16 wPortChange;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065} __attribute__ ((packed));
66
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080067/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 * wPortStatus bit field
69 * See USB 2.0 spec Table 11-21
70 */
71#define USB_PORT_STAT_CONNECTION 0x0001
72#define USB_PORT_STAT_ENABLE 0x0002
73#define USB_PORT_STAT_SUSPEND 0x0004
74#define USB_PORT_STAT_OVERCURRENT 0x0008
75#define USB_PORT_STAT_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -080076#define USB_PORT_STAT_L1 0x0020
77/* bits 6 to 7 are reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define USB_PORT_STAT_POWER 0x0100
79#define USB_PORT_STAT_LOW_SPEED 0x0200
80#define USB_PORT_STAT_HIGH_SPEED 0x0400
81#define USB_PORT_STAT_TEST 0x0800
82#define USB_PORT_STAT_INDICATOR 0x1000
83/* bits 13 to 15 are reserved */
Alan Stern288ead42010-03-04 11:32:30 -050084#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080086/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 * wPortChange bit field
88 * See USB 2.0 spec Table 11-22
89 * Bits 0 to 4 shown, bits 5 to 15 are reserved
90 */
91#define USB_PORT_STAT_C_CONNECTION 0x0001
92#define USB_PORT_STAT_C_ENABLE 0x0002
93#define USB_PORT_STAT_C_SUSPEND 0x0004
94#define USB_PORT_STAT_C_OVERCURRENT 0x0008
95#define USB_PORT_STAT_C_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -080096#define USB_PORT_STAT_C_L1 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98/*
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080099 * wHubCharacteristics (masks)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 * See USB 2.0 spec Table 11-13, offset 3
101 */
102#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
103#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
104#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
105#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
106#define HUB_CHAR_PORTIND 0x0080 /* D7 */
107
108struct usb_hub_status {
109 __le16 wHubStatus;
110 __le16 wHubChange;
111} __attribute__ ((packed));
112
113/*
114 * Hub Status & Hub Change bit masks
115 * See USB 2.0 spec Table 11-19 and Table 11-20
116 * Bits 0 and 1 for wHubStatus and wHubChange
117 * Bits 2 to 15 are reserved for both
118 */
119#define HUB_STATUS_LOCAL_POWER 0x0001
120#define HUB_STATUS_OVERCURRENT 0x0002
121#define HUB_CHANGE_LOCAL_POWER 0x0001
122#define HUB_CHANGE_OVERCURRENT 0x0002
123
124
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800125/*
126 * Hub descriptor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 * See USB 2.0 spec Table 11-13
128 */
129
130#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
131#define USB_DT_HUB_NONVAR_SIZE 7
132
133struct usb_hub_descriptor {
134 __u8 bDescLength;
135 __u8 bDescriptorType;
136 __u8 bNbrPorts;
Greg Kroah-Hartman74ad9bd2005-06-20 21:15:16 -0700137 __le16 wHubCharacteristics;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 __u8 bPwrOn2PwrGood;
139 __u8 bHubContrCurrent;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800140 /* add 1 bit for hub status change; round to bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
142 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
143} __attribute__ ((packed));
144
145
146/* port indicator status selectors, tables 11-7 and 11-25 */
147#define HUB_LED_AUTO 0
148#define HUB_LED_AMBER 1
149#define HUB_LED_GREEN 2
150#define HUB_LED_OFF 3
151
152enum hub_led_mode {
153 INDICATOR_AUTO = 0,
154 INDICATOR_CYCLE,
155 /* software blinks for attention: software, hardware, reserved */
156 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
157 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
158 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
159} __attribute__ ((packed));
160
david-b@pacbell.nete09711a2005-08-13 18:41:04 -0700161/* Transaction Translator Think Times, in bits */
162#define HUB_TTTT_8_BITS 0x00
163#define HUB_TTTT_16_BITS 0x20
164#define HUB_TTTT_24_BITS 0x40
165#define HUB_TTTT_32_BITS 0x60
166
Alan Stern3b02ca32010-04-30 12:42:23 -0400167#endif /* __LINUX_CH11_H */