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
|
/** @file
Header file for PCH PCI Express helpers library
@copyright
Copyright (c) 1999 - 2013 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.
This file contains a 'Sample Driver' and is licensed as such
under the terms of your license agreement with Intel or your
vendor. This file may be modified by the user, subject to
the additional terms of the license agreement
**/
#ifndef _PCH_PCI_EXPRESS_HELPERS_LIB_H_
#define _PCH_PCI_EXPRESS_HELPERS_LIB_H_
//
// Function prototypes
//
/**
Find the Offset to a given Capabilities ID
CAPID list:
0x01 = PCI Power Management Interface
0x04 = Slot Identification
0x05 = MSI Capability
0x10 = PCI Express Capability
@param[in] Bus Pci Bus Number
@param[in] Device Pci Device Number
@param[in] Function Pci Function Number
@param[in] CapId CAPID to search for
@retval 0 CAPID not found
@retval Other CAPID found, Offset of desired CAPID
**/
UINT8
PcieFindCapId (
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 Function,
IN UINT8 CapId
);
/**
Search and return the offset of desired Pci Express Capability ID
CAPID list:
0x0001 = Advanced Error Rreporting Capability
0x0002 = Virtual Channel Capability
0x0003 = Device Serial Number Capability
0x0004 = Power Budgeting Capability
@param[in] Bus Pci Bus Number
@param[in] Device Pci Device Number
@param[in] Function Pci Function Number
@param[in] CapId Extended CAPID to search for
@retval 0 CAPID not found
@retval Other CAPID found, Offset of desired CAPID
**/
UINT16
PcieFindExtendedCapId (
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 Function,
IN UINT16 CapId
);
/**
Map a TC to VC0 for port and endpoint
@param[in] Bus1 The bus number of the port
@param[in] Device1 The device number of the port
@param[in] Function1 The function number of the port
@param[in] Bus2 The bus number of the endpoint
@param[in] Device2 The device number of the endpoint
@param[in] TCx The TC number
@exception EFI_UNSUPPORTED Unsupported operation.
@retval EFI_SUCCESS Successfully completed.
**/
EFI_STATUS
PcieMapTcxVc0 (
IN UINT8 Bus1,
IN UINT8 Device1,
IN UINT8 Function1,
IN UINT8 Bus2,
IN UINT8 Device2,
IN UINT8 TCx
);
/**
Set Common clock to Root port and Endpoint PCI device
@param[in] Bus1 Root port Pci Bus Number
@param[in] Device1 Root port Pci Device Number
@param[in] Function1 Root port Pci Function Number
@param[in] Bus2 Endpoint Pci Bus Number
@param[in] Device2 Endpoint Pci Device Number
@exception EFI_UNSUPPORTED Unsupported operation.
@retval EFI_SUCCESS VC mapping correctly initialized
**/
EFI_STATUS
PcieSetCommonClock (
IN UINT8 Bus1,
IN UINT8 Device1,
IN UINT8 Function1,
IN UINT8 Bus2,
IN UINT8 Device2
);
/**
This function enables the CLKREQ# PM on all the end point functions
@param[in] Bus Pci Bus Number
@param[in] Device Pci Device Number
@param[in] RootFunction Rootport Function Number
@retval None
**/
VOID
PcieSetClkreq (
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 RootFunction
);
/**
This function get or set the Max Payload Size on all the end point functions
@param[in] EndPointBus The Bus Number of the Endpoint
@param[in] EndPointDevice The Device Number of the Endpoint
@param[in] MaxPayload The Max Payolad Size of the root port
@param[in] Operation True: Set the Max Payload Size on all the end point functions
False: Get the Max Payload Size on all the end point functions
@retval EFI_SUCCESS Successfully completed.
**/
EFI_STATUS
PcieMaxPayloadSize (
IN UINT8 EndPointBus,
IN UINT8 EndPointDevice,
IN OUT UINT16 *MaxPayload,
IN BOOLEAN Operation
);
/**
This function disable the forwarding of EOI messages unless it discovers
an IOAPIC behind this root port.
@param[in] RootBus The Bus Number of the root port
@param[in] RootDevice The Device Number of the root port
@param[in] RootFunction The Function Number of the root port
@param[in] EndPointBus The Bus Number of the Endpoint
@param[in] EndPointDevice The Device Number of the Endpoint
@exception EFI_UNSUPPORTED Unsupported operation.
@retval EFI_SUCCESS Successfully completed.
**/
EFI_STATUS
PcieSetEoiFwdDisable (
IN UINT8 RootBus,
IN UINT8 RootDevice,
IN UINT8 RootFunction,
IN UINT8 EndPointBus,
IN UINT8 EndPointDevice
);
/**
This function performs the Power Management settings for root port and downstream device
@param[in] RootBus Pci Bus Number of the root port
@param[in] RootDevice Pci Device Number of the root port
@param[in] RootFunction Pci Function Number of the root port
@param[in] RootPortAspm Root port Aspm configuration
@param[in] NumOfDevAspmOverride Number of Device specific ASPM policy override items
@param[in] DevAspmOverride Pointer to array of Device specific ASPM policy override items
@param[in] TempBusNumberMin Minimal temp bus number that can be assigned to the root port (as secondary
bus number) and its down stream switches
@param[in] TempBusNumberMax Maximal temp bus number that can be assigned to the root port (as subordinate
bus number) and its down stream switches
@param[in] NumOfDevltrOverride Number of Device specific LTR override items
@param[in] DevLtrOverride Pointer to array of Device specific LTR policy override items
@param[in] PchPwrOptPcie Pcie Power Optimizer Configuration
@param[in, out] L1SubstatesSupported L1 substates supported on the root port
@param[in] L1SubstatesConfig L1 substates configurations on the root port
@param[in] PolicyRevision Policy revision for codes compatibility
@param[in] FirstRpToSetPm Indicates if this is the first root port to be set
@param[in] L1SupportedInAllEnabledPorts Check if L1 is supported in all enabled ports
@param[in] ClkreqSupportedInAllEnabledPorts Check if clkreq is supported in all enabled ports
@param[out] LtrSupported Return to check if all endpoints support LTR
@retval EFI_SUCCESS The function completed successfully
@exception EFI_UNSUPPORTED The pointer to the Port PCI Express Capability Structure is not found
**/
EFI_STATUS
PcieSetPm (
IN UINT8 RootBus,
IN UINT8 RootDevice,
IN UINT8 RootFunction,
IN PCH_PCI_EXPRESS_ASPM_CONTROL RootPortAspm,
IN UINT8 NumOfDevAspmOverride,
IN PCH_PCIE_DEVICE_ASPM_OVERRIDE *DevAspmOverride,
IN UINT8 TempBusNumberMin,
IN UINT8 TempBusNumberMax,
IN UINT8 NumOfDevltrOverride,
IN PCH_PCIE_DEVICE_LTR_OVERRIDE *DevLtrOverride,
IN PCH_PCIE_PWR_OPT *PchPwrOptPcie,
IN OUT BOOLEAN *L1SubstatesSupported,
IN PCH_PCIE_EXPRESS_L1SUBSTATES_CONTROL L1SubstatesConfig,
IN UINT8 PolicyRevision,
IN BOOLEAN FirstRPToSetPm,
IN BOOLEAN L1SupportedInAllEnabledPorts,
IN BOOLEAN ClkreqSupportedInAllEnabledPorts,
OUT BOOLEAN *LtrSupported
);
/**
This function checks if the root port and downstream device support Clkreq per port, ASPM L1 and L1 substates
@param[in] RootBus Pci Bus Number of the root port
@param[in] RootDevice Pci Device Number of the root port
@param[in] RootFunction Pci Function Number of the root port
@param[in] RootPortAspm Root port Aspm configuration
@param[in] NumOfDevAspmOverride Number of Device specific ASPM policy override items
@param[in] DevAspmOverride Pointer to array of Device specific ASPM policy override items
@param[in] TempBusNumberMin Minimal temp bus number that can be assigned to the root port (as secondary
bus number) and its down stream switches
@param[in] TempBusNumberMax Maximal temp bus number that can be assigned to the root port (as subordinate
bus number) and its down stream switches
@param[in] NumOfDevLtrOverride Number of Device specific LTR override items
@param[in] DevLtrOverride Pointer to array of Device specific LTR policy override items
@param[in] PchPwrOptPcie Pcie Power Optimizer Configuration
@param[in, out] L1SubstatesSupported Flag to indicate if L1 Substates are supported
@param[in] L1SubstatesConfig L1 Substates configuration
@param[in] PolicyRevision Revision of the policy
@param[in, out] AspmVal Aspm value for both rootport and end point devices
@param[in, out] ClkreqPerPortSupported Clkreq support for both rootport and endpoint devices
@param[out] LtrSupported Return to check if all endpoints support LTR
@retval EFI_SUCCESS The function completed successfully
@exception EFI_UNSUPPORTED The pointer to the Port PCI Express Capability Structure is not found
**/
EFI_STATUS
PcieCheckPmConfig (
IN UINT8 RootBus,
IN UINT8 RootDevice,
IN UINT8 RootFunction,
IN PCH_PCI_EXPRESS_ASPM_CONTROL RootPortAspm,
IN UINT8 NumOfDevAspmOverride,
IN PCH_PCIE_DEVICE_ASPM_OVERRIDE *DevAspmOverride,
IN UINT8 TempBusNumberMin,
IN UINT8 TempBusNumberMax,
IN UINT8 NumOfDevLtrOverride,
IN PCH_PCIE_DEVICE_LTR_OVERRIDE *DevLtrOverride,
IN PCH_PCIE_PWR_OPT *PchPwrOptPcie,
IN OUT BOOLEAN *L1SubstatesSupported,
IN PCH_PCIE_EXPRESS_L1SUBSTATES_CONTROL L1SubstatesConfig,
IN UINT8 PolicyRevision,
IN OUT UINT16 *AspmVal,
IN OUT BOOLEAN *ClkreqPerPortSupported,
OUT BOOLEAN *LtrSupported
);
/**
Initializes the root port and its down stream devices
@param[in] RootPortBus Pci Bus Number of the root port
@param[in] RootPortDevice Pci Device Number of the root port
@param[in] RootPortFunc Pci Function Number of the root port
@param[in] TempBusNumberMin Minimal temp bus number that can be assigned to the root port (as secondary
bus number) and its down stream switches
@param[in] TempBusNumberMax Maximal temp bus number that can be assigned to the root port (as subordinate
bus number) and its down stream switches
@param[out] DeviceClassDword Get the downstream device code dword for unstream RootPort reference
@retval EFI_SUCCESS Successfully completed
@retval EFI_NOT_FOUND Can not find device.
**/
EFI_STATUS
PchPcieInitRootPortDownstreamDevices (
IN UINT8 RootPortBus,
IN UINT8 RootPortDevice,
IN UINT8 RootPortFunc,
IN UINT8 TempBusNumberMin,
IN UINT8 TempBusNumberMax,
OUT UINT32 *DeviceClassDword
);
#endif
|