1/* 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 9#ifndef __LINUX_CH11_H 10#define __LINUX_CH11_H 11 12#include <linux/types.h> /* __u8 etc */ 13 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 43#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ 44#define USB_PORT_FEAT_OVER_CURRENT 3 45#define USB_PORT_FEAT_RESET 4 46#define USB_PORT_FEAT_L1 5 /* L1 suspend */ 47#define USB_PORT_FEAT_POWER 8 48#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ 49#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 56#define USB_PORT_FEAT_C_PORT_L1 23 57 58/* 59 * 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; 64 __le16 wPortChange; 65} __attribute__ ((packed)); 66 67/* 68 * 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 76#define USB_PORT_STAT_L1 0x0020 77/* bits 6 to 7 are reserved */ 78#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 */ 84#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */ 85 86/* 87 * 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 96#define USB_PORT_STAT_C_L1 0x0020 97 98/* 99 * wHubCharacteristics (masks) 100 * 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 125/* 126 * Hub descriptor 127 * 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; 137 __le16 wHubCharacteristics; 138 __u8 bPwrOn2PwrGood; 139 __u8 bHubContrCurrent; 140 /* add 1 bit for hub status change; round to bytes */ 141 __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 161/* 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 167#endif /* __LINUX_CH11_H */ 168