ArmPlatformLib.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /** @file
  2. *
  3. * Copyright 2018-2020 NXP
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause-Patent
  6. *
  7. **/
  8. #include <Library/ArmLib.h>
  9. #include <Library/ArmPlatformLib.h>
  10. #include <Library/SocLib.h>
  11. #include <Ppi/ArmMpCoreInfo.h>
  12. #include <Ppi/NxpPlatformGetClock.h>
  13. ARM_CORE_INFO mLX2160aMpCoreInfoTable[] = {
  14. {
  15. // Cluster 0, Core 0
  16. 0x0,
  17. // MP Core MailBox Set/Get/Clear Addresses and Clear Value
  18. (EFI_PHYSICAL_ADDRESS)0,
  19. (EFI_PHYSICAL_ADDRESS)0,
  20. (EFI_PHYSICAL_ADDRESS)0,
  21. (UINT64)0xFFFFFFFF
  22. }
  23. };
  24. /**
  25. Return the current Boot Mode
  26. This function returns the boot reason on the platform
  27. **/
  28. EFI_BOOT_MODE
  29. ArmPlatformGetBootMode (
  30. VOID
  31. )
  32. {
  33. return BOOT_WITH_FULL_CONFIGURATION;
  34. }
  35. /**
  36. Get the clocks supplied by Platform(Board) to NXP Layerscape SOC IPs
  37. @param[in] ClockType Variable of Type NXP_IP_CLOCK. Indicates which IP clock
  38. is to be retrieved.
  39. @param[in] ... Variable argument list which is parsed based on
  40. ClockType. e.g. if the ClockType is NXP_I2C_CLOCK, then
  41. the second argument will be interpreted as controller
  42. number.
  43. if ClockType is NXP_CORE_CLOCK, then second argument
  44. is interpreted as cluster number and third argument is
  45. interpreted as core number (within the cluster)
  46. @return Actual Clock Frequency. Return value 0 should be
  47. interpreted as clock not being provided to IP.
  48. **/
  49. UINT64
  50. EFIAPI
  51. NxpPlatformGetClock(
  52. IN UINT32 ClockType,
  53. ...
  54. )
  55. {
  56. UINT64 Clock;
  57. VA_LIST Args;
  58. Clock = 0;
  59. VA_START (Args, ClockType);
  60. switch (ClockType) {
  61. case NXP_SYSTEM_CLOCK:
  62. Clock = 100 * 1000 * 1000; // 100 MHz
  63. break;
  64. case NXP_I2C_CLOCK:
  65. case NXP_UART_CLOCK:
  66. Clock = NxpPlatformGetClock (NXP_SYSTEM_CLOCK);
  67. Clock = SocGetClock (Clock, ClockType, Args);
  68. break;
  69. default:
  70. break;
  71. }
  72. VA_END (Args);
  73. return Clock;
  74. }
  75. /**
  76. Initialize controllers that must setup in the normal world
  77. This function is called by the ArmPlatformPkg/PrePi or ArmPlatformPkg/PlatformPei
  78. in the PEI phase.
  79. **/
  80. EFI_STATUS
  81. ArmPlatformInitialize (
  82. IN UINTN MpId
  83. )
  84. {
  85. SocInit ();
  86. return EFI_SUCCESS;
  87. }
  88. EFI_STATUS
  89. PrePeiCoreGetMpCoreInfo (
  90. OUT UINTN *CoreCount,
  91. OUT ARM_CORE_INFO **ArmCoreTable
  92. )
  93. {
  94. if (ArmIsMpCore()) {
  95. *CoreCount = sizeof(mLX2160aMpCoreInfoTable) / sizeof(ARM_CORE_INFO);
  96. *ArmCoreTable = mLX2160aMpCoreInfoTable;
  97. return EFI_SUCCESS;
  98. } else {
  99. return EFI_UNSUPPORTED;
  100. }
  101. }
  102. ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
  103. NXP_PLATFORM_GET_CLOCK_PPI gPlatformGetClockPpi = { NxpPlatformGetClock };
  104. EFI_PEI_PPI_DESCRIPTOR gPlatformPpiTable[] = {
  105. {
  106. EFI_PEI_PPI_DESCRIPTOR_PPI,
  107. &gArmMpCoreInfoPpiGuid,
  108. &mMpCoreInfoPpi
  109. }
  110. };
  111. VOID
  112. ArmPlatformGetPlatformPpiList (
  113. OUT UINTN *PpiListSize,
  114. OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
  115. )
  116. {
  117. if (ArmIsMpCore()) {
  118. *PpiListSize = sizeof(gPlatformPpiTable);
  119. *PpiList = gPlatformPpiTable;
  120. } else {
  121. *PpiListSize = 0;
  122. *PpiList = NULL;
  123. }
  124. }