PeiGalagoPro3InitPreMemLib.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /** @file
  2. System 76 GalagoPro3 board pre-memory initialization.
  3. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <SaPolicyCommon.h>
  8. #include <Library/DebugLib.h>
  9. #include <Library/BaseMemoryLib.h>
  10. #include <Library/IoLib.h>
  11. #include <Library/HobLib.h>
  12. #include <Library/PcdLib.h>
  13. #include <Library/PchCycleDecodingLib.h>
  14. #include <Library/PciLib.h>
  15. #include <Library/PcdLib.h>
  16. #include <Library/BaseMemoryLib.h>
  17. #include <Library/PeiSaPolicyLib.h>
  18. #include <Library/BoardInitLib.h>
  19. #include <PchAccess.h>
  20. #include <Library/GpioNativeLib.h>
  21. #include <Library/GpioLib.h>
  22. #include <GpioPinsSklLp.h>
  23. #include <GpioPinsSklH.h>
  24. #include <Library/GpioExpanderLib.h>
  25. #include <SioRegs.h>
  26. #include <Library/PchPcrLib.h>
  27. #include <Library/SiliconInitLib.h>
  28. #include "PeiGalagoPro3InitLib.h"
  29. #include <ConfigBlock.h>
  30. #include <ConfigBlock/MemoryConfig.h>
  31. //
  32. // Reference RCOMP resistors on motherboard - for SKL RVP1
  33. //
  34. GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 RcompResistorSklRvp1[SA_MRC_MAX_RCOMP] = { 200, 81, 162 };
  35. //
  36. // RCOMP target values for RdOdt, WrDS, WrDSCmd, WrDSCtl, WrDSClk - for SKL RVP1
  37. //
  38. GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 RcompTargetSklRvp1[SA_MRC_MAX_RCOMP_TARGETS] = { 100, 40, 40, 23, 40 };
  39. //
  40. // Reference RCOMP resistors on motherboard - for SKL RVP2
  41. //
  42. GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 RcompResistorSklRvp2[SA_MRC_MAX_RCOMP] = { 121, 81, 100 };
  43. //
  44. // RCOMP target values for RdOdt, WrDS, WrDSCmd, WrDSCtl, WrDSClk - for SKL RVP2
  45. //
  46. GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 RcompTargetSklRvp2[SA_MRC_MAX_RCOMP_TARGETS] = { 100, 40, 20, 20, 26 };
  47. /**
  48. N 1XX WU board configuration init function for PEI pre-memory phase.
  49. PEI_BOARD_CONFIG_PCD_INIT
  50. @param Content pointer to the buffer contain init information for board init.
  51. @retval EFI_SUCCESS The function completed successfully.
  52. @retval EFI_INVALID_PARAMETER The parameter is NULL.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. GalagoPro3InitPreMem (
  57. VOID
  58. )
  59. {
  60. PcdSet32S (PcdPcie0WakeGpioNo, 0);
  61. PcdSet8S (PcdPcie0HoldRstExpanderNo, 0);
  62. PcdSet32S (PcdPcie0HoldRstGpioNo, 8);
  63. PcdSetBoolS (PcdPcie0HoldRstActive, TRUE);
  64. PcdSet8S (PcdPcie0PwrEnableExpanderNo, 0);
  65. PcdSet32S (PcdPcie0PwrEnableGpioNo, 16);
  66. PcdSetBoolS (PcdPcie0PwrEnableActive, FALSE);
  67. //
  68. // HSIO PTSS Table
  69. //
  70. PcdSet32S (PcdSpecificLpHsioPtssTable1, (UINTN) PchLpHsioPtss_Bx_GalagoPro3);
  71. PcdSet16S (PcdSpecificLpHsioPtssTable1Size, (UINTN) PchLpHsioPtss_Bx_GALAGO_PRO_3_Size);
  72. PcdSet32S (PcdSpecificLpHsioPtssTable2, (UINTN) PchLpHsioPtss_Cx_GalagoPro3);
  73. PcdSet16S (PcdSpecificLpHsioPtssTable2Size, (UINTN) PchLpHsioPtss_Cx_GALAGO_PRO_3_Size);
  74. //
  75. // DRAM related definition
  76. //
  77. PcdSet8S (PcdSaMiscUserBd, 5);
  78. PcdSet8S (PcdMrcSpdAddressTable0, 0xA0);
  79. PcdSet8S (PcdMrcSpdAddressTable1, 0xA2);
  80. PcdSet8S (PcdMrcSpdAddressTable2, 0xA4);
  81. PcdSet8S (PcdMrcSpdAddressTable3, 0xA6);
  82. PcdSetBoolS(PcdMrcDqPinsInterleavedControl, TRUE);
  83. PcdSetBoolS(PcdMrcDqPinsInterleaved, TRUE);
  84. PcdSet32S(PcdMrcRcompResistor, (UINTN)RcompResistorSklRvp2);
  85. PcdSet32S(PcdMrcRcompTarget, (UINTN)RcompTargetSklRvp2);
  86. PcdSet8S(PcdMrcCaVrefConfig, 2); // DDR4 boards
  87. PcdSetBoolS (PcdIoExpanderPresent, TRUE);
  88. return EFI_SUCCESS;
  89. }
  90. #define SIO_RUNTIME_REG_BASE_ADDRESS 0x0680
  91. /**
  92. Configures GPIO
  93. @param[in] GpioTable Point to Platform Gpio table
  94. @param[in] GpioTableCount Number of Gpio table entries
  95. **/
  96. VOID
  97. ConfigureGpio (
  98. IN GPIO_INIT_CONFIG *GpioDefinition,
  99. IN UINT16 GpioTableCount
  100. )
  101. {
  102. EFI_STATUS Status;
  103. DEBUG ((DEBUG_INFO, "ConfigureGpio() Start\n"));
  104. Status = GpioConfigurePads (GpioTableCount, GpioDefinition);
  105. DEBUG ((DEBUG_INFO, "ConfigureGpio() End\n"));
  106. }
  107. /**
  108. Configure GPIO Before Memory is not ready.
  109. **/
  110. VOID
  111. GpioInitPreMem (
  112. VOID
  113. )
  114. {
  115. // ConfigureGpio ();
  116. }
  117. /**
  118. Configure Super IO
  119. **/
  120. VOID
  121. SioInit (
  122. VOID
  123. )
  124. {
  125. //
  126. // Program and Enable Default Super IO Configuration Port Addresses and range
  127. //
  128. PchLpcGenIoRangeSet (PcdGet16 (PcdLpcSioConfigDefaultPort) & (~0xF), 0x10);
  129. //
  130. // 128 Byte Boundary and SIO Runtime Register Range is 0x0 to 0xF;
  131. //
  132. PchLpcGenIoRangeSet (SIO_RUNTIME_REG_BASE_ADDRESS & (~0x7F), 0x10);
  133. return;
  134. }
  135. /**
  136. Configues the IC2 Controller on which GPIO Expander Communicates.
  137. This Function is to enable the I2CGPIOExapanderLib to programm the Gpios
  138. Complete intilization will be done in later Stage
  139. **/
  140. VOID
  141. EFIAPI
  142. I2CGpioExpanderInitPreMem(
  143. VOID
  144. )
  145. {
  146. ConfigureSerialIoController (PchSerialIoIndexI2C4, PchSerialIoAcpiHidden);
  147. SerialIoI2cGpioInit (PchSerialIoIndexI2C4, PchSerialIoAcpiHidden, PchSerialIoIs33V);
  148. }
  149. /**
  150. Configure GPIO and SIO before memory ready
  151. @retval EFI_SUCCESS Operation success.
  152. **/
  153. EFI_STATUS
  154. EFIAPI
  155. GalagoPro3BoardInitBeforeMemoryInit (
  156. VOID
  157. )
  158. {
  159. GalagoPro3InitPreMem ();
  160. //
  161. // Configures the I2CGpioExpander
  162. //
  163. if (PcdGetBool (PcdIoExpanderPresent)) {
  164. I2CGpioExpanderInitPreMem();
  165. }
  166. GpioInitPreMem ();
  167. SioInit ();
  168. ///
  169. /// Do basic PCH init
  170. ///
  171. SiliconInit ();
  172. return EFI_SUCCESS;
  173. }
  174. EFI_STATUS
  175. EFIAPI
  176. GalagoPro3BoardDebugInit (
  177. VOID
  178. )
  179. {
  180. ///
  181. /// Do Early PCH init
  182. ///
  183. EarlySiliconInit ();
  184. return EFI_SUCCESS;
  185. }
  186. EFI_BOOT_MODE
  187. EFIAPI
  188. GalagoPro3BoardBootModeDetect (
  189. VOID
  190. )
  191. {
  192. return BOOT_WITH_FULL_CONFIGURATION;
  193. }