Eric Lescouet | d20db4b | 2010-04-24 23:38:17 +0200 | [diff] [blame] | 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 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame^] | 9 | #ifndef __LINUX_CH11_H |
| 10 | #define __LINUX_CH11_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame^] | 12 | #include <linux/types.h> /* __u8 etc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 43 | #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define USB_PORT_FEAT_OVER_CURRENT 3 |
| 45 | #define USB_PORT_FEAT_RESET 4 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 46 | #define USB_PORT_FEAT_L1 5 /* L1 suspend */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #define USB_PORT_FEAT_POWER 8 |
Alan Stern | 288ead4 | 2010-03-04 11:32:30 -0500 | [diff] [blame] | 48 | #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 56 | #define USB_PORT_FEAT_C_PORT_L1 23 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 58 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | * Hub Status and Hub Change results |
| 60 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
| 61 | */ |
| 62 | struct usb_port_status { |
| 63 | __le16 wPortStatus; |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 64 | __le16 wPortChange; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } __attribute__ ((packed)); |
| 66 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 67 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 76 | #define USB_PORT_STAT_L1 0x0020 |
| 77 | /* bits 6 to 7 are reserved */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ |
Alan Stern | 288ead4 | 2010-03-04 11:32:30 -0500 | [diff] [blame] | 84 | #define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 86 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David Brownell | dbe0dbb | 2008-02-10 12:24:00 -0800 | [diff] [blame] | 96 | #define USB_PORT_STAT_C_L1 0x0020 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | /* |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 99 | * wHubCharacteristics (masks) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 108 | struct 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-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 125 | /* |
| 126 | * Hub descriptor |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 133 | struct usb_hub_descriptor { |
| 134 | __u8 bDescLength; |
| 135 | __u8 bDescriptorType; |
| 136 | __u8 bNbrPorts; |
Greg Kroah-Hartman | 74ad9bd | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 137 | __le16 wHubCharacteristics; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | __u8 bPwrOn2PwrGood; |
| 139 | __u8 bHubContrCurrent; |
Greg Kroah-Hartman | 84cca82 | 2008-01-30 15:21:33 -0800 | [diff] [blame] | 140 | /* add 1 bit for hub status change; round to bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 152 | enum 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.net | e09711a | 2005-08-13 18:41:04 -0700 | [diff] [blame] | 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 | |
Alan Stern | 3b02ca3 | 2010-04-30 12:42:23 -0400 | [diff] [blame^] | 167 | #endif /* __LINUX_CH11_H */ |