blob: bd3185aba4eee9f878d87696c4e79371f1e6bf27 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#ifndef __LINUX_HUB_H
10#define __LINUX_HUB_H
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/list.h>
13#include <linux/workqueue.h>
14#include <linux/compiler.h> /* likely()/unlikely() */
15
16/*
17 * Hub request types
18 */
19
20#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
21#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
22
23/*
24 * Hub class requests
25 * See USB 2.0 spec Table 11-16
26 */
27#define HUB_CLEAR_TT_BUFFER 8
28#define HUB_RESET_TT 9
29#define HUB_GET_TT_STATE 10
30#define HUB_STOP_TT 11
31
32/*
33 * Hub Class feature numbers
34 * See USB 2.0 spec Table 11-17
35 */
36#define C_HUB_LOCAL_POWER 0
37#define C_HUB_OVER_CURRENT 1
38
39/*
40 * Port feature numbers
41 * See USB 2.0 spec Table 11-17
42 */
43#define USB_PORT_FEAT_CONNECTION 0
44#define USB_PORT_FEAT_ENABLE 1
David Brownelldbe0dbb2008-02-10 12:24:00 -080045#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#define USB_PORT_FEAT_OVER_CURRENT 3
47#define USB_PORT_FEAT_RESET 4
David Brownelldbe0dbb2008-02-10 12:24:00 -080048#define USB_PORT_FEAT_L1 5 /* L1 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define USB_PORT_FEAT_POWER 8
Alan Stern288ead42010-03-04 11:32:30 -050050#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define USB_PORT_FEAT_C_CONNECTION 16
52#define USB_PORT_FEAT_C_ENABLE 17
53#define USB_PORT_FEAT_C_SUSPEND 18
54#define USB_PORT_FEAT_C_OVER_CURRENT 19
55#define USB_PORT_FEAT_C_RESET 20
56#define USB_PORT_FEAT_TEST 21
57#define USB_PORT_FEAT_INDICATOR 22
David Brownelldbe0dbb2008-02-10 12:24:00 -080058#define USB_PORT_FEAT_C_PORT_L1 23
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080060/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 * Hub Status and Hub Change results
62 * See USB 2.0 spec Table 11-19 and Table 11-20
63 */
64struct usb_port_status {
65 __le16 wPortStatus;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080066 __le16 wPortChange;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067} __attribute__ ((packed));
68
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080069/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 * wPortStatus bit field
71 * See USB 2.0 spec Table 11-21
72 */
73#define USB_PORT_STAT_CONNECTION 0x0001
74#define USB_PORT_STAT_ENABLE 0x0002
75#define USB_PORT_STAT_SUSPEND 0x0004
76#define USB_PORT_STAT_OVERCURRENT 0x0008
77#define USB_PORT_STAT_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -080078#define USB_PORT_STAT_L1 0x0020
79/* bits 6 to 7 are reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define USB_PORT_STAT_POWER 0x0100
81#define USB_PORT_STAT_LOW_SPEED 0x0200
82#define USB_PORT_STAT_HIGH_SPEED 0x0400
83#define USB_PORT_STAT_TEST 0x0800
84#define USB_PORT_STAT_INDICATOR 0x1000
85/* bits 13 to 15 are reserved */
Alan Stern288ead42010-03-04 11:32:30 -050086#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080088/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 * wPortChange bit field
90 * See USB 2.0 spec Table 11-22
91 * Bits 0 to 4 shown, bits 5 to 15 are reserved
92 */
93#define USB_PORT_STAT_C_CONNECTION 0x0001
94#define USB_PORT_STAT_C_ENABLE 0x0002
95#define USB_PORT_STAT_C_SUSPEND 0x0004
96#define USB_PORT_STAT_C_OVERCURRENT 0x0008
97#define USB_PORT_STAT_C_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -080098#define USB_PORT_STAT_C_L1 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100/*
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800101 * wHubCharacteristics (masks)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 * See USB 2.0 spec Table 11-13, offset 3
103 */
104#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
105#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
106#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
107#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
108#define HUB_CHAR_PORTIND 0x0080 /* D7 */
109
110struct usb_hub_status {
111 __le16 wHubStatus;
112 __le16 wHubChange;
113} __attribute__ ((packed));
114
115/*
116 * Hub Status & Hub Change bit masks
117 * See USB 2.0 spec Table 11-19 and Table 11-20
118 * Bits 0 and 1 for wHubStatus and wHubChange
119 * Bits 2 to 15 are reserved for both
120 */
121#define HUB_STATUS_LOCAL_POWER 0x0001
122#define HUB_STATUS_OVERCURRENT 0x0002
123#define HUB_CHANGE_LOCAL_POWER 0x0001
124#define HUB_CHANGE_OVERCURRENT 0x0002
125
126
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800127/*
128 * Hub descriptor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 * See USB 2.0 spec Table 11-13
130 */
131
132#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
133#define USB_DT_HUB_NONVAR_SIZE 7
134
135struct usb_hub_descriptor {
136 __u8 bDescLength;
137 __u8 bDescriptorType;
138 __u8 bNbrPorts;
Greg Kroah-Hartman74ad9bd2005-06-20 21:15:16 -0700139 __le16 wHubCharacteristics;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 __u8 bPwrOn2PwrGood;
141 __u8 bHubContrCurrent;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800142 /* add 1 bit for hub status change; round to bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
144 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
145} __attribute__ ((packed));
146
147
148/* port indicator status selectors, tables 11-7 and 11-25 */
149#define HUB_LED_AUTO 0
150#define HUB_LED_AMBER 1
151#define HUB_LED_GREEN 2
152#define HUB_LED_OFF 3
153
154enum hub_led_mode {
155 INDICATOR_AUTO = 0,
156 INDICATOR_CYCLE,
157 /* software blinks for attention: software, hardware, reserved */
158 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
159 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
160 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
161} __attribute__ ((packed));
162
david-b@pacbell.nete09711a2005-08-13 18:41:04 -0700163/* Transaction Translator Think Times, in bits */
164#define HUB_TTTT_8_BITS 0x00
165#define HUB_TTTT_16_BITS 0x20
166#define HUB_TTTT_24_BITS 0x40
167#define HUB_TTTT_32_BITS 0x60
168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169#endif /* __LINUX_HUB_H */