PlatInitDxe.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /** @file
  2. Copyright (c) 2017, Linaro Limited. All rights reserved.
  3. Copyright (c) 2017, Marvell International Ltd. and its affiliates
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Guid/EventGroup.h>
  7. #include <IndustryStandard/MvSmc.h>
  8. #include <Library/ArmadaIcuLib.h>
  9. #include <Library/ArmSmcLib.h>
  10. #include <Library/DebugLib.h>
  11. #include <Library/MppLib.h>
  12. #include <Library/MvComPhyLib.h>
  13. #include <Library/PcdLib.h>
  14. #include <Library/UefiDriverEntryPoint.h>
  15. #include <Library/UefiBootServicesTableLib.h>
  16. #include <Library/UtmiPhyLib.h>
  17. STATIC EFI_EVENT mArmada7k8kExitBootServicesEvent;
  18. /**
  19. Disable extra EL3 handling of the PMU interrupts for DT world.
  20. @param[in] Event Event structure
  21. @param[in] Context Notification context
  22. **/
  23. STATIC
  24. VOID
  25. EFIAPI
  26. Armada7k8kExitBootServicesHandler (
  27. IN EFI_EVENT Event,
  28. IN VOID *Context
  29. )
  30. {
  31. ARM_SMC_ARGS SmcRegs = {0};
  32. SmcRegs.Arg0 = MV_SMC_ID_PMU_IRQ_DISABLE;
  33. ArmCallSmc (&SmcRegs);
  34. }
  35. /**
  36. Check if we boot with DT and trigger EBS event in such case.
  37. @param[in] Event Event structure
  38. @param[in] Context Notification context
  39. **/
  40. STATIC
  41. VOID
  42. EFIAPI
  43. Armada7k8kOnReadyToBootHandler (
  44. IN EFI_EVENT Event,
  45. IN VOID *Context
  46. )
  47. {
  48. EFI_STATUS Status;
  49. VOID *Interface;
  50. // Ensure the event will be triggered only once
  51. gBS->CloseEvent (Event);
  52. Status = gBS->LocateProtocol (&gEdkiiPlatformHasAcpiGuid,
  53. NULL,
  54. (VOID **)&Interface);
  55. if (!EFI_ERROR (Status)) {
  56. /* ACPI is enabled, so leave the current settings intact. */
  57. return;
  58. }
  59. //
  60. // In case DT is selected, create EBS event for disabling
  61. // extra EL3 handling of the PMU interrupts in EL3.
  62. //
  63. Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES,
  64. TPL_NOTIFY,
  65. Armada7k8kExitBootServicesHandler,
  66. NULL,
  67. &mArmada7k8kExitBootServicesEvent);
  68. ASSERT_EFI_ERROR (Status);
  69. }
  70. EFI_STATUS
  71. EFIAPI
  72. ArmadaPlatInitDxeEntryPoint (
  73. IN EFI_HANDLE ImageHandle,
  74. IN EFI_SYSTEM_TABLE *SystemTable
  75. )
  76. {
  77. ARM_SMC_ARGS SmcRegs = {0};
  78. EFI_STATUS Status;
  79. EFI_EVENT Event;
  80. DEBUG ((DEBUG_ERROR,
  81. "\n%a %a Init\n\n",
  82. (CHAR8 *)PcdGetPtr (PcdProductManufacturer),
  83. (CHAR8 *)PcdGetPtr (PcdProductPlatformName)));
  84. Status = gBS->InstallProtocolInterface (&ImageHandle,
  85. &gMarvellPlatformInitCompleteProtocolGuid,
  86. EFI_NATIVE_INTERFACE,
  87. NULL);
  88. ASSERT_EFI_ERROR (Status);
  89. MvComPhyInit ();
  90. UtmiPhyInit ();
  91. MppInitialize ();
  92. ArmadaIcuInitialize ();
  93. Status = ArmadaBoardInit ();
  94. ASSERT_EFI_ERROR (Status);
  95. /*
  96. * Enable EL3 PMU interrupt handler and
  97. * register the ReadyToBoot event.
  98. */
  99. SmcRegs.Arg0 = MV_SMC_ID_PMU_IRQ_ENABLE;
  100. ArmCallSmc (&SmcRegs);
  101. Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL,
  102. TPL_CALLBACK,
  103. Armada7k8kOnReadyToBootHandler,
  104. NULL,
  105. &gEfiEventReadyToBootGuid,
  106. &Event);
  107. ASSERT_EFI_ERROR (Status);
  108. return EFI_SUCCESS;
  109. }