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