summaryrefslogtreecommitdiff
path: root/Core/EM/UsbRecovery/HubPeim.h
blob: 7f0a11409d0b4d6d615f550178f617adaa8ae36c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2006, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
//
// $Header: /Alaska/SOURCE/Modules/USBRecovery/HubPeim.h 4     11/24/12 5:42a Ryanchou $
//
// $Revision: 4 $
//
// $Date: 11/24/12 5:42a $
//
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/USBRecovery/HubPeim.h $
// 
// 4     11/24/12 5:42a Ryanchou
// [TAG]  		EIP103990
// [Category]  	Improvement
// [Description]  	Synchronized with USB PEI module 4.6.3_USB_08.10.24.
// [Files]  		EhciPei.c, EhciPei.h, OhciPei.c, OhciPei.h, UhcPeim.c,
// BotPeim.c, BotPeim.h, PeiAtapi.c, UsbBotPeim.c, UsbBotPeim.h,
// HubPeim.c, UsbPeim.c, XhciPei.c, XhciPei.h, HubPeim.h, PeiUsbLib.c,
// PeiUsbLib.h, UsbPeim.h
// 
// 3     1/18/11 12:55a Ryanchou
// [TAG]  		EIP47931
// [Category]  	Improvement
// [Description]  	Added USB 3.0 hub support.
// [Files]  		EhciPei.c, EhciPei.h, HubPeim.c, HubPeim.h, OhciPei.c,
// OhciPei.h, UhcPeim.c, UhcPeim.h, usb.h, UsbHostController.h,
// UsbIoPeim.c, UsbPeim.c, UsbPeim.h, XhciPei.c, XhciPei.h
// 
// 2     7/10/08 6:33p Michaela
// Updated to support OHCI controllers
//
// 1     9/22/06 4:06p Sivagarn
// - Initial Check-in
// - Included Recovery code in Source
// - Included appropriate headers for flies and functions
// - Updated copyright messages
//
//*****************************************************************************

//<AMI_FHDR_START>
//----------------------------------------------------------------------------
//
// Name:        HubPeim.H
//
// Description: This file belongs to "Framework" and included here for
//              compatibility purposes. This file is modified by AMI to include
//              copyright message, appropriate header and integration code
//
//----------------------------------------------------------------------------
//<AMI_FHDR_END>

//
// This file contains 'Framework Code' and is licensed as such
// under the terms of your license agreement with Intel or your
// vendor.  This file may not be modified, except as allowed by
// additional terms of your license agreement.
//

/*++

   Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
   This software and associated documentation (if any) is furnished
   under a license and may only be used or copied in accordance
   with the terms of the license. Except as permitted by such
   license, no part of this software or documentation may be
   reproduced, stored in a retrieval system, or transmitted in any
   form or by any means without the express written consent of
   Intel Corporation.


   Module Name:

    HubPeim.h

   Abstract:

    Constants definitions for Usb Hub Peim

   Revision History

   --*/

#ifndef _PEI_HUB_PEIM_H
#define _PEI_HUB_PEIM_H

#include "Efi.h"
#include "Pei.h"
#include "usb.h"
#include "usbpeim.h"

#include "Ppi\UsbIo.h"
//
// Hub feature numbers
//
#define C_HUB_LOCAL_POWER   0
#define C_HUB_OVER_CURRENT  1


//
// Hub class code & sub class code
//
#define CLASS_CODE_HUB      0x09
#define SUB_CLASS_CODE_HUB  0

//
// Hub Status & Hub Change bit masks
//
#define HUB_STATUS_LOCAL_POWER  0x0001
#define HUB_STATUS_OVERCURRENT  0x0002

#define HUB_CHANGE_LOCAL_POWER  0x0001
#define HUB_CHANGE_OVERCURRENT  0x0002

//
// Hub Characteristics
//
#define HUB_CHAR_LPSM      0x0003
#define HUB_CHAR_COMPOUND  0x0004
#define HUB_CHAR_OCPM      0x0018

//
// Hub specific request
//
#define HUB_CLEAR_FEATURE                0x01
#define HUB_CLEAR_FEATURE_REQ_TYPE       0x20

#define HUB_CLEAR_FEATURE_PORT           0x01
#define HUB_CLEAR_FEATURE_PORT_REQ_TYPE  0x23

#define HUB_GET_BUS_STATE                0x02
#define HUB_GET_BUS_STATE_REQ_TYPE       0xa3

#define HUB_GET_DESCRIPTOR               0x06
#define HUB_GET_DESCRIPTOR_REQ_TYPE      0xa0

#define HUB_GET_HUB_STATUS               0x00
#define HUB_GET_HUB_STATUS_REQ_TYPE      0xa0

#define HUB_GET_PORT_STATUS              0x00
#define HUB_GET_PORT_STATUS_REQ_TYPE     0xa3

#define HUB_SET_DESCRIPTOR               0x07
#define HUB_SET_DESCRIPTOR_REQ_TYPE      0x20

#define HUB_SET_HUB_FEATURE              0x03
#define HUB_SET_HUB_FEATURE_REQ_TYPE     0x20

#define HUB_SET_HUB_DEPTH                0x0C
#define HUB_SET_HUB_DEPTH_REQ_TYPE       0x20

#define HUB_SET_PORT_FEATURE             0x03
#define HUB_SET_PORT_FEATURE_REQ_TYPE    0x23

// Hub port status and port change status bits
#define HUB_PORT_CONNECTION		0x0001
#define HUB_PORT_ENABLE			0x0002
#define HUB_PORT_SUSPEND		0x0004
#define HUB_PORT_OVER_CURRENT	0x0008
#define HUB_PORT_RESET			0x0010
#define HUB_PORT_POWER			0x0100
#define HUB_PORT_LOW_SPEED		0x0200
#define HUB_PORT_HIGH_SPEED		0x0400
#define HUB_PORT_TEST			0x0800
#define HUB_PORT_INDICATOR		0x1000

#define HUB_C_PORT_CONNECTION	0x0001
#define HUB_C_PORT_ENABLE		0x0002
#define HUB_C_PORT_SUSPEND		0x0004
#define HUB_C_PORT_OVER_CURRENT	0x0008
#define HUB_C_PORT_RESET		0x0010

// Super speed hub definition
#define SS_HUB_PORT_CONNECTION		0x0001
#define SS_HUB_PORT_ENABLE			0x0002
#define SS_HUB_PORT_OVER_CURRENT	0x0008
#define SS_HUB_PORT_RESET			0x0010
#define SS_HUB_PORT_LINK_STATE		0x01E0
#define SS_HUB_PORT_POWER			0x0200
#define SS_HUB_PORT_SPEED			0x1800

#define SS_HUB_C_PORT_CONNECTION	0x0001
#define SS_HUB_C_PORT_ENABLE		0x0002
#define SS_HUB_C_PORT_SUSPEND		0x0004
#define SS_HUB_C_PORT_OVER_CURRENT	0x0008
#define SS_HUB_C_PORT_RESET			0x0010
#define	SS_HUB_C_BH_PORT_RESET		0x0020
#define	SS_HUB_C_PORT_LINK_STATE	0x0040
#define	SS_HUB_C_PORT_CONFIG_ERROR	0x0080

#pragma pack(1)
typedef struct usb_hub_status
{
    UINT16 HubStatus;
    UINT16 HubChange;
} EFI_USB_HUB_STATUS;

typedef struct {
	struct {
		UINT16	Connected	:1;
		UINT16	Enabled		:1;
		UINT16	Reserved	:1;
		UINT16	OverCurrent	:1;
		UINT16	Reset		:1;
		UINT16	LinkState	:4;
		UINT16	Power		:1;
		UINT16	Speed		:3;
		UINT16	Reserved1	:3;
	} PortStatus;
	struct {
		UINT16	ConnectChange		:1;
		UINT16	Reserved			:2;
		UINT16	OverCurrentChange	:1;
		UINT16	ResetChange			:1;
		UINT16	BhResetChange		:1;
		UINT16	LinkStateChange		:1;
		UINT16	ConfigErrorChange	:1;
		UINT16	Reserved1			:8;
	} PortChange;
} USB3_HUB_PORT_STATUS;

#pragma pack()

EFI_STATUS
PeiHubGetPortStatus (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    IN UINT8            Port,
    OUT UINT32          *PortStatus );

EFI_STATUS
PeiHubSetPortFeature (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    IN UINT8            Port,
    IN UINT8            Value );

EFI_STATUS
PeiHubSetHubFeature (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    IN UINT8            Value );

EFI_STATUS
PeiHubGetHubStatus (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    OUT UINT32          *HubStatus );

EFI_STATUS
PeiHubClearPortFeature (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    IN UINT8            Port,
    IN UINT8            Value );

EFI_STATUS
PeiHubClearHubFeature (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    IN UINT8            Value );

EFI_STATUS
PeiSetHubDepth (
    IN EFI_PEI_SERVICES        **PeiServices,
    IN PEI_USB_IO_PPI          *UsbIoPpi,
	IN UINT16                  HubDepth);

EFI_STATUS
PeiGetHubDescriptor (
    IN EFI_PEI_SERVICES        **PeiServices,
    IN PEI_USB_IO_PPI          *UsbIoPpi,
    IN UINTN                   DescriptorSize,
    OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor );

EFI_STATUS
PeiDoHubConfig (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_DEVICE   *PeiUsbDevice );

VOID
PeiResetHubPort (
    IN EFI_PEI_SERVICES **PeiServices,
    IN PEI_USB_IO_PPI   *UsbIoPpi,
    UINT8               PortNum );

#endif


//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2006, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************