PeiBoardInitLib.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /** @file
  2. @copyright
  3. Copyright 2018 - 2021 Intel Corporation.
  4. Copyright (c) 2021 - 2022, 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. EFI_STATUS
  17. EFIAPI
  18. TypeAowandaPeiBoardInitLibConstructor (
  19. IN EFI_PEI_FILE_HANDLE FileHandle,
  20. IN CONST EFI_PEI_SERVICES **PeiServices
  21. )
  22. {
  23. EFI_STATUS Status = EFI_SUCCESS;
  24. UBA_CONFIG_DATABASE_PPI *UbaConfigPpi;
  25. EFI_HOB_GUID_TYPE *GuidHob;
  26. EFI_PLATFORM_INFO *PlatformInfo;
  27. UINT8 SocketIndex;
  28. UINT8 ChannelIndex;
  29. GuidHob = GetFirstGuidHob (&gEfiPlatformInfoGuid);
  30. ASSERT (GuidHob != NULL);
  31. if (GuidHob == NULL) {
  32. return EFI_NOT_FOUND;
  33. }
  34. PlatformInfo = GET_GUID_HOB_DATA (GuidHob);
  35. if (PlatformInfo->BoardId == TypeAowanda) {
  36. DEBUG ((DEBUG_INFO, "PEI UBA init BoardId 0x%X: TypeAowanda\n", PlatformInfo->BoardId));
  37. // Socket 0 has SMT DIMM connector, Socket 1 has PTH DIMM connector
  38. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  39. for (ChannelIndex = 0; ChannelIndex < MAX_CH; ChannelIndex++) {
  40. switch (SocketIndex) {
  41. case 0:
  42. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorSmt;
  43. break;
  44. case 1:
  45. // Fall through since socket 1 is PTH type
  46. default:
  47. // Use the more restrictive type as the default case
  48. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorPth;
  49. break;
  50. }
  51. }
  52. }
  53. BuildGuidDataHob (
  54. &gEfiPlatformInfoGuid,
  55. &(PlatformInfo),
  56. sizeof (EFI_PLATFORM_INFO)
  57. );
  58. Status = PeiServicesLocatePpi (
  59. &gUbaConfigDatabasePpiGuid,
  60. 0,
  61. NULL,
  62. (VOID **) &UbaConfigPpi
  63. );
  64. if (EFI_ERROR(Status)) {
  65. return Status;
  66. }
  67. Status = UbaConfigPpi->InitSku (
  68. UbaConfigPpi,
  69. PlatformInfo->BoardId,
  70. NULL,
  71. NULL
  72. );
  73. ASSERT_EFI_ERROR (Status);
  74. Status = TypeAowandaInstallGpioData (UbaConfigPpi);
  75. if (EFI_ERROR (Status)) {
  76. return Status;
  77. }
  78. Status = TypeAowandaInstallPcdData (UbaConfigPpi);
  79. if (EFI_ERROR (Status)) {
  80. return Status;
  81. }
  82. Status = TypeAowandaInstallSoftStrapData (UbaConfigPpi);
  83. if (EFI_ERROR (Status)) {
  84. return Status;
  85. }
  86. Status = TypeAowandaPchEarlyUpdate (UbaConfigPpi);
  87. if (EFI_ERROR (Status)) {
  88. return Status;
  89. }
  90. Status = TypeAowandaPlatformUpdateUsbOcMappings (UbaConfigPpi);
  91. if (EFI_ERROR (Status)) {
  92. return Status;
  93. }
  94. Status = TypeAowandaInstallSlotTableData (UbaConfigPpi);
  95. if (EFI_ERROR (Status)) {
  96. return Status;
  97. }
  98. Status = TypeAowandaInstallKtiEparamData (UbaConfigPpi);
  99. if (EFI_ERROR (Status)) {
  100. return Status;
  101. }
  102. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  103. //
  104. // Set default memory type connector.
  105. // Socket 0: DimmConnectorSmt
  106. // Socket 1: DimmConnectorPth
  107. //
  108. if (SocketIndex % 2 == 0) {
  109. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorSmt);
  110. } else {
  111. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorPth);
  112. }
  113. }
  114. //
  115. // Initialize InterposerType to InterposerUnknown
  116. //
  117. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; ++SocketIndex) {
  118. PlatformInfo->InterposerType[SocketIndex] = InterposerUnknown;
  119. }
  120. //
  121. // TypeAowandaIioPortBifurcationInit will use PlatformInfo->InterposerType for PPO.
  122. //
  123. Status = TypeAowandaIioPortBifurcationInit (UbaConfigPpi);
  124. if (EFI_ERROR (Status)) {
  125. return Status;
  126. }
  127. }
  128. return Status;
  129. }