PeiBoardInitLib.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /** @file
  2. @copyright
  3. Copyright 2018 - 2021 Intel Corporation.
  4. Copyright (c) 2021, American Megatrends International LLC. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. /**
  8. The constructor function for Board Init Libray.
  9. @param FileHandle Handle of the file being invoked.
  10. @param PeiServices Describes the list of possible PEI Services.
  11. @retval EFI_SUCCESS Table initialization successfully.
  12. @retval EFI_OUT_OF_RESOURCES No enough memory to initialize table.
  13. **/
  14. #include "PeiBoardInit.h"
  15. #include <UncoreCommonIncludes.h>
  16. #include <Library/PchMultiPchBase.h>
  17. #include <Ppi/DynamicSiLibraryPpi.h>
  18. EFI_STATUS
  19. EFIAPI
  20. TypeJunctionCityPeiBoardInitLibConstructor (
  21. IN EFI_PEI_FILE_HANDLE FileHandle,
  22. IN CONST EFI_PEI_SERVICES **PeiServices
  23. )
  24. {
  25. EFI_STATUS Status = EFI_SUCCESS;
  26. UBA_CONFIG_DATABASE_PPI *UbaConfigPpi;
  27. EFI_HOB_GUID_TYPE *GuidHob;
  28. EFI_PLATFORM_INFO *PlatformInfo;
  29. UINT8 SocketIndex;
  30. UINT8 ChannelIndex;
  31. GuidHob = GetFirstGuidHob (&gEfiPlatformInfoGuid);
  32. ASSERT (GuidHob != NULL);
  33. if (GuidHob == NULL) {
  34. return EFI_NOT_FOUND;
  35. }
  36. PlatformInfo = GET_GUID_HOB_DATA(GuidHob);
  37. if (PlatformInfo->BoardId == TypeJunctionCity) {
  38. DEBUG ((DEBUG_INFO, "PEI UBA init BoardId 0x%X: JunctionCity\n", PlatformInfo->BoardId));
  39. // Socket 0 has SMT DIMM connector, Socket 1 has PTH DIMM connector
  40. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  41. for (ChannelIndex = 0; ChannelIndex < MAX_CH; ChannelIndex++) {
  42. switch (SocketIndex) {
  43. case 0:
  44. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorSmt;
  45. break;
  46. case 1:
  47. // Fall through since socket 1 is PTH type
  48. default:
  49. // Use the more restrictive type as the default case
  50. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorPth;
  51. break;
  52. }
  53. }
  54. }
  55. BuildGuidDataHob (
  56. &gEfiPlatformInfoGuid,
  57. &(PlatformInfo),
  58. sizeof (EFI_PLATFORM_INFO)
  59. );
  60. Status = PeiServicesLocatePpi (
  61. &gUbaConfigDatabasePpiGuid,
  62. 0,
  63. NULL,
  64. (VOID **) &UbaConfigPpi
  65. );
  66. if (EFI_ERROR(Status)) {
  67. return Status;
  68. }
  69. Status = UbaConfigPpi->InitSku (
  70. UbaConfigPpi,
  71. PlatformInfo->BoardId,
  72. NULL,
  73. NULL
  74. );
  75. ASSERT_EFI_ERROR (Status);
  76. Status = TypeJunctionCityInstallGpioData (UbaConfigPpi);
  77. if (EFI_ERROR(Status)) {
  78. return Status;
  79. }
  80. Status = TypeJunctionCityInstallPcdData (UbaConfigPpi);
  81. if (EFI_ERROR(Status)) {
  82. return Status;
  83. }
  84. Status = TypeJunctionCityInstallSoftStrapData (UbaConfigPpi);
  85. if (EFI_ERROR(Status)) {
  86. return Status;
  87. }
  88. Status = TypeJunctionCityPchEarlyUpdate (UbaConfigPpi);
  89. if (EFI_ERROR(Status)) {
  90. return Status;
  91. }
  92. Status = TypeJunctionCityPlatformUpdateUsbOcMappings (UbaConfigPpi);
  93. if (EFI_ERROR(Status)) {
  94. return Status;
  95. }
  96. Status = TypeJunctionCityInstallSlotTableData (UbaConfigPpi);
  97. if (EFI_ERROR(Status)) {
  98. return Status;
  99. }
  100. Status = TypeJunctionCityInstallKtiEparamData (UbaConfigPpi);
  101. if (EFI_ERROR(Status)) {
  102. return Status;
  103. }
  104. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  105. //
  106. // Set default memory type connector.
  107. // Socket 0: DimmConnectorSmt
  108. // Socket 1: DimmConnectorPth
  109. //
  110. if (SocketIndex % 2 == 0) {
  111. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorSmt);
  112. } else {
  113. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorPth);
  114. }
  115. }
  116. //
  117. // Initialize InterposerType to InterposerUnknown
  118. //
  119. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; ++SocketIndex) {
  120. PlatformInfo->InterposerType[SocketIndex] = InterposerUnknown;
  121. }
  122. //
  123. // TypeJunctionCityIioPortBifurcationInit will use PlatformInfo->InterposerType for PPO.
  124. //
  125. Status = TypeJunctionCityIioPortBifurcationInit (UbaConfigPpi);
  126. if (EFI_ERROR(Status)) {
  127. return Status;
  128. }
  129. }
  130. return Status;
  131. }