hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/** @file
  Pch information library.
 
  All function in this library is available for PEI, DXE, and SMM,
  But do not support UEFI RUNTIME environment call.
 
  Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved. <BR>
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/
 
#include <Uefi/UefiBaseType.h>
#include <Library/BaseLib.h>
#include <Library/PchInfoLib.h>
#include <Register/PchRegsLpcCnl.h>
#include "PchInfoLibPrivate.h"
#include <Private/Library/PmcPrivateLib.h>
#include <Register/PchRegsLpc.h>
 
/**
  Determine Pch Series based on Device Id
 
  @param[in] LpcDeviceId      Lpc Device Id
 
  @retval PCH_SERIES          Pch Series
**/
PCH_SERIES
PchSeriesFromLpcDid (
  IN UINT16 LpcDeviceId
  )
{
  switch (LpcDeviceId & B_LPC_CFG_DID) {
 
    case V_LPC_CFG_DID_CNL_H:
      return PCH_H;
 
    case V_LPC_CFG_DID_CNL_LP:
      return PCH_LP;
 
    case V_LPC_CFG_DID_CML_LP:
      return PCH_LP;
 
    default:
      return PCH_UNKNOWN_SERIES;
  }
}
 
/**
  Return Pch Generation
 
  @retval PCH_GENERATION            Pch Generation
**/
PCH_GENERATION
PchGeneration (
  VOID
  )
{
  return CNL_PCH;
}
 
/**
  Check if this is Server PCH
 
  @retval TRUE                It's a Server PCH
  @retval FALSE               It's not a Server PCH
**/
BOOLEAN
IsPchServer (
  VOID
  )
{
  return FALSE;
}
 
/**
  Get RST mode supported by the silicon
 
  @retval RST_MODE    RST mode supported by silicon
**/
RST_MODE
PchGetSupportedRstMode (
  VOID
  )
{
  switch (PchGetLpcDid ()) {
 
    case V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_4:
    case V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A303_SKU:
      return RstUnsupported;
      break;
 
    default:
      return RstPremium;
      break;
  }
}
 
/**
  Check if this is Server SKU
 
  @retval TRUE                It's PCH Server SKU
  @retval FALSE               It's not PCH Server SKU
**/
BOOLEAN
IsPchServerSku (
  VOID
  )
{
  UINT16 LpcDid;
 
  LpcDid = PchGetLpcDid ();
 
  if (LpcDid == V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A309_SKU) {
    return TRUE;
  } else {
    return FALSE;
  }
}
 
/**
  Get PCH series ASCII string.
 
  @retval PCH Series string
**/
CHAR8*
PchGetSeriesStr (
  VOID
  )
{
  switch (PchSeries ()) {
 
    case PCH_LP:
      return "CNL PCH-LP";
 
    case PCH_H:
      return "CNL PCH-H";
 
    default:
      return NULL;
  }
}
 
GLOBAL_REMOVE_IF_UNREFERENCED
struct PCH_SKU_STRING mSkuStrs[] = {
  //
  // PCH LP Mobile LPC Device IDs
  //
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_SUPER_SKU, "Super SKU"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_0, "(U) Super SKU"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_1, "Super SKU (locked)"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_2, "(Y) Premium SKU"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_3, "(U) Premium  SKU"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_4, "(U) Base/Mainstream SKU"},
  {V_CNL_PCH_LP_LPC_CFG_DEVICE_ID_MB_5, "(Y) Super SKU"},
  //
  // PCH H LPC Device IDs
  //
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A300_SKU, "CNL PCH-H SKU A300"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A303_SKU, "H310"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A304_SKU, "H370"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A305_SKU, "Z390"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A306_SKU, "Q370"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A309_SKU, "C246"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A30A_SKU, "C242"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A30B_SKU, "X399"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A30C_SKU, "QM370"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A30D_SKU, "HM370"},
  {V_CNL_PCH_H_LPC_CFG_DEVICE_ID_A30E_SKU, "CM246"},
  {0xFFFF, NULL}
};
 
/**
  Check whether integrated LAN controller is supported by PCH Series.
 
  @retval TRUE                    GbE is supported in current PCH
  @retval FALSE                   GbE is not supported on current PCH
**/
BOOLEAN
PchIsGbeSupported (
  VOID
  )
{
  return TRUE;
}
 
/**
  Get Pch Maximum Pcie Root Port Number
 
  @retval Pch Maximum Pcie Root Port Number
**/
UINT8
GetPchMaxPciePortNum (
  VOID
  )
{
  if (IsPchLp ()) {
    return 16;
  } else {
    return 24;
  }
}
 
/**
  Get Pch Usb2 Maximum Physical Port Number
 
  @retval Pch Usb2 Maximum Physical Port Number
**/
UINT8
GetPchUsb2MaxPhysicalPortNum (
  VOID
  )
{
  if (IsPchLp ()) {
    return 10;
  } else {
    return 14;
  }
}
 
/**
  Get Pch Maximum Usb2 Port Number of XHCI Controller
 
  @retval Pch Maximum Usb2 Port Number of XHCI Controller
**/
UINT8
GetPchXhciMaxUsb2PortNum (
  VOID
  )
{
  if (IsPchLp ()) {
    return 12;
  } else {
    return 16;
  }
}
 
/**
  Get Pch Maximum Usb3 Port Number of XHCI Controller
 
  @retval Pch Maximum Usb3 Port Number of XHCI Controller
**/
UINT8
GetPchXhciMaxUsb3PortNum (
  VOID
  )
{
  if (IsPchLp ()) {
    return 6;
  } else {
    return 10;
  }
}
 
/**
  Check if given Display Audio Link T-Mode is supported
 
  @param[in] Tmode          T-mode support to be checked
 
  @retval    TRUE           T-mode supported
  @retval    FALSE          T-mode not supported
**/
BOOLEAN
IsAudioIDispTmodeSupported (
  IN PCH_HDAUDIO_IDISP_TMODE Tmode
  )
{
  //
  // iDisplay Audio Link T-mode support per PCH Generation/Series:
  // 1. 1T  - CNP-LP
  // 2. 2T  - CNP-LP/H (default)
  //
  switch (Tmode) {
    case PchHdaIDispMode1T:
      return IsPchLp ();
    case PchHdaIDispMode2T:
      return TRUE;
    case PchHdaIDispMode4T:
    case PchHdaIDispMode8T:
    case PchHdaIDispMode16T:
    default:
      return FALSE;
  }
}
 
/**
  Gets the maximum number of UFS controller supported by this chipset.
 
  @return Number of supported UFS controllers
**/
UINT8
PchGetMaxUfsNum (
  VOID
  )
{
  if (IsPchLp ()) {
    return 1;
  } else {
    return 0;
  }
}
 
/**
  Check if this chipset supports eMMC controller
 
  @retval BOOLEAN  TRUE if supported, FALSE otherwise
**/
BOOLEAN
IsPchEmmcSupported (
  VOID
  )
{
  if (IsPchLp ()) {
    return TRUE;
  }
 
  return FALSE;
}
 
/**
  Check if this chipset supports SD controller
 
  @retval BOOLEAN  TRUE if supported, FALSE otherwise
**/
BOOLEAN
IsPchSdCardSupported (
  VOID
  )
{
  return TRUE;
}
 
/**
  Check if this chipset supports UFS controller
 
  @retval BOOLEAN  TRUE if supported, FALSE otherwise
**/
BOOLEAN
IsPchUfsSupported (
  VOID
  )
{
  if (IsPchLp ()) {
    return TRUE;
  }
 
  return FALSE;
}
 
/**
  Check if link between PCH and CPU is an P-DMI
 
  @retval    TRUE           P-DMI link
  @retval    FALSE          Not an P-DMI link
**/
BOOLEAN
IsPchWithPdmi (
  VOID
  )
{
  return IsPchH ();
}
 
/**
  Check if link between PCH and CPU is an OP-DMI
 
  @retval    TRUE           OP-DMI link
  @retval    FALSE          Not an OP-DMI link
**/
BOOLEAN
IsPchWithOpdmi (
  VOID
  )
{
  return !IsPchH ();
}
 
/**
  Check if link between PCH and CPU is an F-DMI
 
  @retval    TRUE           F-DMI link
  @retval    FALSE          Not an F-DMI link
**/
BOOLEAN
IsPchWithFdmi (
  VOID
  )
{
  return FALSE;
}