/*---------------------------------------------------------------------------* Project: USB Host Stack (UHS) File: uhs_ch11.h Description: USB constants and structures related to the USB Hub Specification, which is defined in chapter 11 of the USB 2.0 specification. Copyright (C) 2011 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef __UHS_CH11_H__ #define __UHS_CH11_H__ #ifdef __cplusplus extern "C" { #endif PACKED_STRUCT_BEGIN /* * Upper limit on maximum number of supported hub ports */ #define UHS_HUB_MAXCHILDREN 10 /* * Hub request types */ #define UHS_RT_HUB (UHS_TYPE_CLASS | UHS_RECIP_DEVICE) #define UHS_RT_PORT (UHS_TYPE_CLASS | UHS_RECIP_OTHER) /* * Hub class requests * See USB 2.0 spec Table 11-16 */ #define UHS_HUB_CLEAR_TT_BUFFER 8 #define UHS_HUB_RESET_TT 9 #define UHS_HUB_GET_TT_STATE 10 #define UHS_HUB_STOP_TT 11 #define UHS_HUB_SET_DEPTH 12 /* * Hub Class feature numbers * See USB 2.0 spec Table 11-17 */ #define UHS_C_HUB_LOCAL_POWER 0 #define UHS_C_HUB_OVER_CURRENT 1 /* * Port feature numbers * See USB 2.0 spec Table 11-17 */ #define UHS_PORT_FEAT_CONNECTION 0 #define UHS_PORT_FEAT_ENABLE 1 #define UHS_PORT_FEAT_SUSPEND 2 /* L2 suspend */ #define UHS_PORT_FEAT_OVER_CURRENT 3 #define UHS_PORT_FEAT_RESET 4 #define UHS_PORT_FEAT_L1 5 /* L1 suspend */ #define UHS_PORT_FEAT_POWER 8 #define UHS_PORT_FEAT_LOWSPEED 9 /* Should never be used */ #define UHS_PORT_FEAT_C_CONNECTION 16 #define UHS_PORT_FEAT_C_ENABLE 17 #define UHS_PORT_FEAT_C_SUSPEND 18 #define UHS_PORT_FEAT_C_OVER_CURRENT 19 #define UHS_PORT_FEAT_C_RESET 20 #define UHS_PORT_FEAT_TEST 21 #define UHS_PORT_FEAT_INDICATOR 22 #define UHS_PORT_FEAT_C_PORT_L1 23 #define UHS_PORT_FEAT_C_PORT_LINK_STATE 25 #define UHS_PORT_FEAT_C_PORT_CONFIG_ERROR 26 #define UHS_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27 #define UHS_PORT_FEAT_BH_PORT_RESET 28 #define UHS_PORT_FEAT_C_BH_PORT_RESET 29 #define UHS_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 /* * Hub Status and Hub Change results * See USB 2.0 spec Table 11-19 and Table 11-20 */ typedef struct { u16 wPortStatus; u16 wPortChange; } PACKED_STRUCT_ATTRIBUTE UhsPortStatus; /* * wPortStatus bit field * See USB 2.0 spec Table 11-21 */ #define UHS_PORT_STAT_CONNECTION 0x0001 #define UHS_PORT_STAT_ENABLE 0x0002 #define UHS_PORT_STAT_SUSPEND 0x0004 #define UHS_PORT_STAT_OVERCURRENT 0x0008 #define UHS_PORT_STAT_RESET 0x0010 #define UHS_PORT_STAT_L1 0x0020 /* bits 6 to 7 are reserved */ #define UHS_PORT_STAT_POWER 0x0100 #define UHS_PORT_STAT_LOW_SPEED 0x0200 #define UHS_PORT_STAT_HIGH_SPEED 0x0400 #define UHS_PORT_STAT_TEST 0x0800 #define UHS_PORT_STAT_INDICATOR 0x1000 /* bits 13 to 15 are reserved */ /* Valid only if port is enabled */ /* Bits that are the same from USB 2.0 */ #define UHS_SS_PORT_STAT_MASK (UHS_PORT_STAT_CONNECTION | \ UHS_PORT_STAT_ENABLE | \ UHS_PORT_STAT_OVERCURRENT | \ UHS_PORT_STAT_RESET) /* * Definitions for PORT_LINK_STATE values * (bits 5-8) in wPortStatus */ #define UHS_SS_PORT_LS_U0 0x0000 #define UHS_SS_PORT_LS_U1 0x0020 #define UHS_SS_PORT_LS_U2 0x0040 #define UHS_SS_PORT_LS_U3 0x0060 #define UHS_SS_PORT_LS_SS_DISABLED 0x0080 #define UHS_SS_PORT_LS_RX_DETECT 0x00a0 #define UHS_SS_PORT_LS_SS_INACTIVE 0x00c0 #define UHS_SS_PORT_LS_POLLING 0x00e0 #define UHS_SS_PORT_LS_RECOVERY 0x0100 #define UHS_SS_PORT_LS_HOT_RESET 0x0120 #define UHS_SS_PORT_LS_COMP_MOD 0x0140 #define UHS_SS_PORT_LS_LOOPBACK 0x0160 /* * wPortChange bit field * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 * Bits 0 to 5 shown, bits 6 to 15 are reserved */ #define UHS_PORT_STAT_C_CONNECTION 0x0001 #define UHS_PORT_STAT_C_ENABLE 0x0002 #define UHS_PORT_STAT_C_SUSPEND 0x0004 #define UHS_PORT_STAT_C_OVERCURRENT 0x0008 #define UHS_PORT_STAT_C_RESET 0x0010 #define UHS_PORT_STAT_C_L1 0x0020 /* * wHubCharacteristics (masks) * See USB 2.0 spec Table 11-13, offset 3 */ #define UHS_HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ #define UHS_HUB_CHAR_COMPOUND 0x0004 /* D2 */ #define UHS_HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */ #define UHS_HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */ #define UHS_HUB_CHAR_PORTIND 0x00 /* D7 */ typedef struct { u16 wHubStatus; u16 wHubChange; } PACKED_STRUCT_ATTRIBUTE UhsHubStatus; /* * Hub Status & Hub Change bit masks * See USB 2.0 spec Table 11-19 and Table 11-20 * Bits 0 and 1 for wHubStatus and wHubChange * Bits 2 to 15 are reserved for both */ #define UHS_HUB_STATUS_LOCAL_POWER 0x0001 #define UHS_HUB_STATUS_OVERCURRENT 0x0002 #define UHS_HUB_CHANGE_LOCAL_POWER 0x0001 #define UHS_HUB_CHANGE_OVERCURRENT 0x0002 /* * Hub descriptor * See USB 2.0 spec Table 11-13 */ #define UHS_DT_HUB (UHS_TYPE_CLASS | 0x09) #define UHS_DT_SS_HUB (UHS_TYPE_CLASS | 0x0a) #define UHS_DT_HUB_NONVAR_SIZE 7 #define UHS_DT_SS_HUB_SIZE 12 typedef struct { u8 bDescLength; u8 bDescriptorType; u8 bNbrPorts; u16 wHubCharacteristics; u8 bPwrOn2PwrGood; u8 bHubContrCurrent; /* add 1 bit for hub status change; round to bytes */ u8 DeviceRemovable[(UHS_HUB_MAXCHILDREN + 1 + 7) / 8]; /* This field exists for reasons of compatibility with software written for 1.0 compliant devices. All bits in this field should be set to 1B. */ u8 PortPwrCtrlMask; }PACKED_STRUCT_ATTRIBUTE UhsHubDescriptor; /* Macro for obtaining hub descriptor length as a function of max ports */ #define UHS_HUB_DESCRIPTOR_SIZE(maxPorts) (7 + ((maxPorts)+1+7)/8) /* port indicator status selectors, tables 11-7 and 11-25 */ #define UHS_HUB_LED_AUTO 0 #define UHS_HUB_LED_AMBER 1 #define UHS_HUB_LED_GREEN 2 #define UHS_HUB_LED_OFF 3 typedef enum { UHS_HUB_LED_INDICATOR_AUTO = 0, UHS_HUB_LED_INDICATOR_CYCLE, /* software blinks for attention: software, hardware, reserved */ UHS_HUB_LED_NDICATOR_GREEN_BLINK, UHS_HUB_LED_INDICATOR_GREEN_BLINK_OFF, UHS_HUB_LED_INDICATOR_AMBER_BLINK, UHS_HUB_LED_INDICATOR_AMBER_BLINK_OFF, UHS_HUB_LED_INDICATOR_ALT_BLINK, UHS_HUB_LED_INDICATOR_ALT_BLINK_OFF }UhsHubLedMode; /* Transaction Translator Think Times, in bits */ #define UHS_HUB_TTTT_8_BITS 0x00 #define UHS_HUB_TTTT_16_BITS 0x20 #define UHS_HUB_TTTT_24_BITS 0x40 #define UHS_HUB_TTTT_32_BITS 0x60 PACKED_STRUCT_END #ifdef __cplusplus } #endif #endif /* __UHS_CH11_H__ */