Fixed unexpected timeout in Usb MassStorage Driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbHub.h
1 /** @file
2
3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 UsbHub.h
15
16 Abstract:
17
18 The definition for USB hub
19
20 Revision History
21
22
23 **/
24
25 #ifndef _USB_HUB_H_
26 #define _USB_HUB_H_
27
28 #include <IndustryStandard/Usb.h>
29
30 #define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
31 #define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
32
33 enum {
34 USB_DESC_TYPE_HUB = 0x29,
35
36 //
37 // Hub class control transfer target
38 //
39 USB_HUB_TARGET_HUB = 0,
40 USB_HUB_TARGET_PORT = 3,
41
42 //
43 // HUB class specific contrl transfer request type
44 //
45 USB_HUB_REQ_GET_STATUS = 0,
46 USB_HUB_REQ_CLEAR_FEATURE = 1,
47 USB_HUB_REQ_SET_FEATURE = 3,
48 USB_HUB_REQ_GET_DESC = 6,
49 USB_HUB_REQ_SET_DESC = 7,
50 USB_HUB_REQ_CLEAR_TT = 8,
51 USB_HUB_REQ_RESET_TT = 9,
52 USB_HUB_REQ_GET_TT_STATE = 10,
53 USB_HUB_REQ_STOP_TT = 11,
54
55
56 //
57 // USB hub class feature selector
58 //
59 USB_HUB_C_HUB_LOCAL_POWER = 0,
60 USB_HUB_C_HUB_OVER_CURRENT = 1,
61 USB_HUB_PORT_CONNECTION = 0,
62 USB_HUB_PORT_ENABLE = 1,
63 USB_HUB_PORT_SUSPEND = 2,
64 USB_HUB_PORT_OVER_CURRENT = 3,
65 USB_HUB_PORT_RESET = 4,
66 USB_HUB_PORT_POWER = 8,
67 USB_HUB_PORT_LOW_SPEED = 9,
68 USB_HUB_C_PORT_CONNECT = 16,
69 USB_HUB_C_PORT_ENABLE = 17,
70 USB_HUB_C_PORT_SUSPEND = 18,
71 USB_HUB_C_PORT_OVER_CURRENT = 19,
72 USB_HUB_C_PORT_RESET = 20,
73 USB_HUB_PORT_TEST = 21,
74 USB_HUB_PORT_INDICATOR = 22,
75
76 //
77 // USB hub power control method. In gang power control
78 //
79 USB_HUB_GANG_POWER_CTRL = 0,
80 USB_HUB_PORT_POWER_CTRL = 0x01,
81
82 //
83 // USB hub status bits
84 //
85 USB_HUB_STAT_LOCAL_POWER = 0x01,
86 USB_HUB_STAT_OVER_CURRENT = 0x02,
87 USB_HUB_STAT_C_LOCAL_POWER = 0x01,
88 USB_HUB_STAT_C_OVER_CURRENT = 0x02,
89
90 USB_HUB_CLASS_CODE = 0x09,
91 USB_HUB_SUBCLASS_CODE = 0x00,
92
93 //
94 // Host software return timeout if port status doesn't change
95 // after 500ms(LOOP * STALL = 100 * 5ms), set by experience
96 //
97 USB_WAIT_PORT_STS_CHANGE_LOOP = 100,
98 };
99
100 #pragma pack(1)
101 //
102 // Hub descriptor, the last two fields are of variable lenght.
103 //
104 typedef struct {
105 UINT8 Length;
106 UINT8 DescType;
107 UINT8 NumPorts;
108 UINT16 HubCharacter;
109 UINT8 PwrOn2PwrGood;
110 UINT8 HubContrCurrent;
111 UINT8 Filler[16];
112 } EFI_USB_HUB_DESCRIPTOR;
113 #pragma pack()
114
115
116 typedef struct {
117 UINT16 ChangedBit;
118 EFI_USB_PORT_FEATURE Feature;
119 } USB_CHANGE_FEATURE_MAP;
120
121
122 EFI_STATUS
123 UsbHubCtrlClearTTBuffer (
124 IN USB_DEVICE *UsbDev,
125 IN UINT8 Port,
126 IN UINT16 DevAddr,
127 IN UINT16 EpNum,
128 IN UINT16 EpType
129 );
130
131
132 BOOLEAN
133 UsbIsHubInterface (
134 IN USB_INTERFACE *UsbIf
135 );
136
137 EFI_STATUS
138 UsbHubAckHubStatus (
139 IN USB_DEVICE *UsbDev
140 );
141
142 extern USB_HUB_API mUsbHubApi;
143 extern USB_HUB_API mUsbRootHubApi;
144 #endif
145