1 /*---------------------------------------------------------------------------* 2 Project: USB Host Stack (UHS) 3 File: uhs_ch11.h 4 Description: USB constants and structures related to the USB Hub Specification, 5 which is defined in chapter 11 of the USB 2.0 specification. 6 7 Copyright (C) Nintendo. All rights reserved. 8 9 These coded instructions, statements, and computer programs contain 10 proprietary information of Nintendo of America Inc. and/or Nintendo 11 Company Ltd., and are protected by Federal copyright law. They may 12 not be disclosed to third parties or copied or duplicated in any form, 13 in whole or in part, without the prior written consent of Nintendo. 14 15 *---------------------------------------------------------------------------*/ 16 #ifndef __UHS_CH11_H__ 17 #define __UHS_CH11_H__ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 PACKED_STRUCT_BEGIN 23 24 /* 25 * Upper limit on maximum number of supported hub ports 26 */ 27 #define UHS_HUB_MAXCHILDREN 10 28 29 /* 30 * Hub request types 31 */ 32 #define UHS_RT_HUB (UHS_TYPE_CLASS | UHS_RECIP_DEVICE) 33 #define UHS_RT_PORT (UHS_TYPE_CLASS | UHS_RECIP_OTHER) 34 35 /* 36 * Hub class requests 37 * See USB 2.0 spec Table 11-16 38 */ 39 #define UHS_HUB_CLEAR_TT_BUFFER 8 40 #define UHS_HUB_RESET_TT 9 41 #define UHS_HUB_GET_TT_STATE 10 42 #define UHS_HUB_STOP_TT 11 43 #define UHS_HUB_SET_DEPTH 12 44 45 /* 46 * Hub Class feature numbers 47 * See USB 2.0 spec Table 11-17 48 */ 49 #define UHS_C_HUB_LOCAL_POWER 0 50 #define UHS_C_HUB_OVER_CURRENT 1 51 52 /* 53 * Port feature numbers 54 * See USB 2.0 spec Table 11-17 55 */ 56 #define UHS_PORT_FEAT_CONNECTION 0 57 #define UHS_PORT_FEAT_ENABLE 1 58 #define UHS_PORT_FEAT_SUSPEND 2 /* L2 suspend */ 59 #define UHS_PORT_FEAT_OVER_CURRENT 3 60 #define UHS_PORT_FEAT_RESET 4 61 #define UHS_PORT_FEAT_L1 5 /* L1 suspend */ 62 #define UHS_PORT_FEAT_POWER 8 63 #define UHS_PORT_FEAT_LOWSPEED 9 /* Should never be used */ 64 #define UHS_PORT_FEAT_C_CONNECTION 16 65 #define UHS_PORT_FEAT_C_ENABLE 17 66 #define UHS_PORT_FEAT_C_SUSPEND 18 67 #define UHS_PORT_FEAT_C_OVER_CURRENT 19 68 #define UHS_PORT_FEAT_C_RESET 20 69 #define UHS_PORT_FEAT_TEST 21 70 #define UHS_PORT_FEAT_INDICATOR 22 71 #define UHS_PORT_FEAT_C_PORT_L1 23 72 #define UHS_PORT_FEAT_C_PORT_LINK_STATE 25 73 #define UHS_PORT_FEAT_C_PORT_CONFIG_ERROR 26 74 #define UHS_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27 75 #define UHS_PORT_FEAT_BH_PORT_RESET 28 76 #define UHS_PORT_FEAT_C_BH_PORT_RESET 29 77 #define UHS_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 78 79 /* 80 * Hub Status and Hub Change results 81 * See USB 2.0 spec Table 11-19 and Table 11-20 82 */ 83 typedef struct { 84 u16 wPortStatus; 85 u16 wPortChange; 86 } PACKED_STRUCT_ATTRIBUTE UhsPortStatus; 87 88 /* 89 * wPortStatus bit field 90 * See USB 2.0 spec Table 11-21 91 */ 92 #define UHS_PORT_STAT_CONNECTION 0x0001 93 #define UHS_PORT_STAT_ENABLE 0x0002 94 #define UHS_PORT_STAT_SUSPEND 0x0004 95 #define UHS_PORT_STAT_OVERCURRENT 0x0008 96 #define UHS_PORT_STAT_RESET 0x0010 97 #define UHS_PORT_STAT_L1 0x0020 98 /* bits 6 to 7 are reserved */ 99 #define UHS_PORT_STAT_POWER 0x0100 100 #define UHS_PORT_STAT_LOW_SPEED 0x0200 101 #define UHS_PORT_STAT_HIGH_SPEED 0x0400 102 #define UHS_PORT_STAT_TEST 0x0800 103 #define UHS_PORT_STAT_INDICATOR 0x1000 104 /* bits 13 to 15 are reserved */ 105 106 /* Valid only if port is enabled */ 107 /* Bits that are the same from USB 2.0 */ 108 #define UHS_SS_PORT_STAT_MASK (UHS_PORT_STAT_CONNECTION | \ 109 UHS_PORT_STAT_ENABLE | \ 110 UHS_PORT_STAT_OVERCURRENT | \ 111 UHS_PORT_STAT_RESET) 112 113 /* 114 * Definitions for PORT_LINK_STATE values 115 * (bits 5-8) in wPortStatus 116 */ 117 #define UHS_SS_PORT_LS_U0 0x0000 118 #define UHS_SS_PORT_LS_U1 0x0020 119 #define UHS_SS_PORT_LS_U2 0x0040 120 #define UHS_SS_PORT_LS_U3 0x0060 121 #define UHS_SS_PORT_LS_SS_DISABLED 0x0080 122 #define UHS_SS_PORT_LS_RX_DETECT 0x00a0 123 #define UHS_SS_PORT_LS_SS_INACTIVE 0x00c0 124 #define UHS_SS_PORT_LS_POLLING 0x00e0 125 #define UHS_SS_PORT_LS_RECOVERY 0x0100 126 #define UHS_SS_PORT_LS_HOT_RESET 0x0120 127 #define UHS_SS_PORT_LS_COMP_MOD 0x0140 128 #define UHS_SS_PORT_LS_LOOPBACK 0x0160 129 130 /* 131 * wPortChange bit field 132 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 133 * Bits 0 to 5 shown, bits 6 to 15 are reserved 134 */ 135 #define UHS_PORT_STAT_C_CONNECTION 0x0001 136 #define UHS_PORT_STAT_C_ENABLE 0x0002 137 #define UHS_PORT_STAT_C_SUSPEND 0x0004 138 #define UHS_PORT_STAT_C_OVERCURRENT 0x0008 139 #define UHS_PORT_STAT_C_RESET 0x0010 140 #define UHS_PORT_STAT_C_L1 0x0020 141 142 /* 143 * wHubCharacteristics (masks) 144 * See USB 2.0 spec Table 11-13, offset 3 145 */ 146 #define UHS_HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ 147 #define UHS_HUB_CHAR_COMPOUND 0x0004 /* D2 */ 148 #define UHS_HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */ 149 #define UHS_HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */ 150 #define UHS_HUB_CHAR_PORTIND 0x00 /* D7 */ 151 152 typedef struct { 153 u16 wHubStatus; 154 u16 wHubChange; 155 } PACKED_STRUCT_ATTRIBUTE UhsHubStatus; 156 157 /* 158 * Hub Status & Hub Change bit masks 159 * See USB 2.0 spec Table 11-19 and Table 11-20 160 * Bits 0 and 1 for wHubStatus and wHubChange 161 * Bits 2 to 15 are reserved for both 162 */ 163 #define UHS_HUB_STATUS_LOCAL_POWER 0x0001 164 #define UHS_HUB_STATUS_OVERCURRENT 0x0002 165 #define UHS_HUB_CHANGE_LOCAL_POWER 0x0001 166 #define UHS_HUB_CHANGE_OVERCURRENT 0x0002 167 168 169 /* 170 * Hub descriptor 171 * See USB 2.0 spec Table 11-13 172 */ 173 #define UHS_DT_HUB (UHS_TYPE_CLASS | 0x09) 174 #define UHS_DT_SS_HUB (UHS_TYPE_CLASS | 0x0a) 175 #define UHS_DT_HUB_NONVAR_SIZE 7 176 #define UHS_DT_SS_HUB_SIZE 12 177 178 typedef struct { 179 u8 bDescLength; 180 u8 bDescriptorType; 181 u8 bNbrPorts; 182 u16 wHubCharacteristics; 183 u8 bPwrOn2PwrGood; 184 u8 bHubContrCurrent; 185 186 /* add 1 bit for hub status change; round to bytes */ 187 u8 DeviceRemovable[(UHS_HUB_MAXCHILDREN + 1 + 7) / 8]; 188 189 /* This field exists for reasons of compatibility with software 190 written for 1.0 compliant devices. All bits in this field 191 should be set to 1B. */ 192 u8 PortPwrCtrlMask; 193 194 }PACKED_STRUCT_ATTRIBUTE UhsHubDescriptor; 195 196 /* Macro for obtaining hub descriptor length as a function of max ports */ 197 #define UHS_HUB_DESCRIPTOR_SIZE(maxPorts) (7 + ((maxPorts)+1+7)/8) 198 199 /* port indicator status selectors, tables 11-7 and 11-25 */ 200 #define UHS_HUB_LED_AUTO 0 201 #define UHS_HUB_LED_AMBER 1 202 #define UHS_HUB_LED_GREEN 2 203 #define UHS_HUB_LED_OFF 3 204 205 typedef enum { 206 UHS_HUB_LED_INDICATOR_AUTO = 0, 207 UHS_HUB_LED_INDICATOR_CYCLE, 208 /* software blinks for attention: software, hardware, reserved */ 209 UHS_HUB_LED_NDICATOR_GREEN_BLINK, UHS_HUB_LED_INDICATOR_GREEN_BLINK_OFF, 210 UHS_HUB_LED_INDICATOR_AMBER_BLINK, UHS_HUB_LED_INDICATOR_AMBER_BLINK_OFF, 211 UHS_HUB_LED_INDICATOR_ALT_BLINK, UHS_HUB_LED_INDICATOR_ALT_BLINK_OFF 212 }UhsHubLedMode; 213 214 /* Transaction Translator Think Times, in bits */ 215 #define UHS_HUB_TTTT_8_BITS 0x00 216 #define UHS_HUB_TTTT_16_BITS 0x20 217 #define UHS_HUB_TTTT_24_BITS 0x40 218 #define UHS_HUB_TTTT_32_BITS 0x60 219 220 221 PACKED_STRUCT_END 222 223 #ifdef __cplusplus 224 } 225 #endif 226 227 228 #endif /* __UHS_CH11_H__ */ 229 230