PeiAspireVn7Dash572GDetect.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /** @file
  2. Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include <PiPei.h>
  6. #include <SaPolicyCommon.h>
  7. #include <Library/DebugLib.h>
  8. #include <Library/BaseMemoryLib.h>
  9. #include <Library/IoLib.h>
  10. #include <Library/HobLib.h>
  11. #include <Library/PcdLib.h>
  12. #include <Library/PchCycleDecodingLib.h>
  13. #include <Library/PciLib.h>
  14. #include <Library/PcdLib.h>
  15. #include <Library/BaseMemoryLib.h>
  16. #include <Library/PeiSaPolicyLib.h>
  17. #include <Library/BoardInitLib.h>
  18. #include <PchAccess.h>
  19. #include <Library/GpioNativeLib.h>
  20. #include <Library/GpioLib.h>
  21. #include <GpioPinsSklLp.h>
  22. #include <GpioPinsSklH.h>
  23. #include <Library/GpioExpanderLib.h>
  24. #include <SioRegs.h>
  25. #include <Library/PchPcrLib.h>
  26. #include <Library/SiliconInitLib.h>
  27. #include "PeiKabylakeRvp3InitLib.h"
  28. #include <ConfigBlock.h>
  29. #include <ConfigBlock/MemoryConfig.h>
  30. #include <Library/EcLib.h>
  31. #include <EcCommands.h>
  32. #define BOARD_ID_MASK_8BIT 0xff
  33. /**
  34. Get board fab ID.
  35. @param[out] DataBuffer
  36. @retval EFI_SUCCESS Command success
  37. @retval EFI_DEVICE_ERROR Command error
  38. **/
  39. EFI_STATUS
  40. GetBoardFabId (
  41. OUT UINT8 *DataBuffer
  42. )
  43. {
  44. UINT8 DataSize;
  45. //
  46. // For 'EC_C_FAB_ID' command NumberOfSendData = 0, NumberOfReceiveData =2.
  47. //
  48. DataSize = 2;
  49. return (LpcEcInterface (EC_C_FAB_ID, &DataSize, DataBuffer));
  50. }
  51. /**
  52. Get RVP3 board ID.
  53. There are 2 different RVP3 boards having different ID.
  54. This function will return board ID to caller.
  55. @param[out] DataBuffer
  56. @retval EFI_SUCCESS Command success
  57. @retval EFI_DEVICE_ERROR Command error
  58. **/
  59. EFI_STATUS
  60. GetRvp3BoardId (
  61. UINT8 *BoardId
  62. )
  63. {
  64. EFI_STATUS Status;
  65. UINT16 EcBoardInfo;
  66. UINT8 DataBuffer[2];
  67. Status = GetBoardFabId (DataBuffer);
  68. if (Status == EFI_SUCCESS) {
  69. EcBoardInfo = DataBuffer[0];
  70. EcBoardInfo = (EcBoardInfo << 8) | DataBuffer[1];
  71. //
  72. // Get the following data:
  73. // [7:0] - BOARD_IDx
  74. // [8] - GEN_ID
  75. // [11:9] - REV_FAB_IDx
  76. // [12] - TP_SPD_PRSNT
  77. // [15:13] - BOM_IDx
  78. //
  79. *BoardId = (UINT8) (EcBoardInfo & BOARD_ID_MASK_8BIT);
  80. DEBUG ((DEBUG_INFO, "BoardId = %X\n", *BoardId));
  81. }
  82. return Status;
  83. }
  84. EFI_STATUS
  85. EFIAPI
  86. KabylakeRvp3BoardDetect (
  87. VOID
  88. )
  89. {
  90. UINT8 BoardId;
  91. if (LibPcdGetSku () != 0) {
  92. return EFI_SUCCESS;
  93. }
  94. DEBUG ((DEBUG_INFO, "KabylakeRvp3DetectionCallback\n"));
  95. if (GetRvp3BoardId (&BoardId) == EFI_SUCCESS) {
  96. if (BoardId == BoardIdKabyLakeYLpddr3Rvp3) {
  97. LibPcdSetSku (BoardIdKabyLakeYLpddr3Rvp3);
  98. ASSERT (LibPcdGetSku() == BoardIdKabyLakeYLpddr3Rvp3);
  99. } else if (BoardId == BoardIdSkylakeRvp3) {
  100. LibPcdSetSku (BoardIdSkylakeRvp3);
  101. ASSERT (LibPcdGetSku() == BoardIdSkylakeRvp3);
  102. }
  103. DEBUG ((DEBUG_INFO, "SKU_ID: 0x%x\n", LibPcdGetSku()));
  104. }
  105. return EFI_SUCCESS;
  106. }