Now that the code to detect the Juno revision is in
the header, convert the ArmJunoDxe to use it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeremy Linton <jeremy.lin...@arm.com>
---
 .../ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c     | 52 ++++------------------
 1 file changed, 8 insertions(+), 44 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c 
b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
index 756c275..780e56a 100644
--- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
+++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
@@ -37,14 +37,6 @@
 //
 #define SKY2_MAC_ADDRESS_BOOTARG_LEN  47
 
-//
-// Hardware platform identifiers
-//
-typedef enum {
-  UNKNOWN,
-  JUNO_R0,
-  JUNO_R1
-} JUNO_REVISION;
 
 //
 // Function prototypes
@@ -229,13 +221,9 @@ ArmJunoEntryPoint (
   CHAR16                *TextDevicePath;
   UINTN                 TextDevicePathSize;
   VOID                  *Buffer;
-  UINT32                Midr;
-  UINT32                CpuType;
-  UINT32                CpuRev;
-  JUNO_REVISION         JunoRevision;
+  UINT32                JunoRevision;
   EFI_EVENT             EndOfDxeEvent;
-
-  JunoRevision = UNKNOWN;
+  
   Status = PciEmulationEntryPoint ();
   if (EFI_ERROR (Status)) {
     return Status;
@@ -300,38 +288,14 @@ ArmJunoEntryPoint (
     DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));
   }
 
-  //
-  // We detect whether we are running on a Juno r0 or Juno r1 board at
-  // runtime by checking the value of the MIDR register.
-  //
-
-  Midr     = ArmReadMidr ();
-  CpuType  = (Midr >> ARM_CPU_TYPE_SHIFT) & ARM_CPU_TYPE_MASK;
-  CpuRev   = Midr & ARM_CPU_REV_MASK;
-
-  switch (CpuType) {
-  case ARM_CPU_TYPE_A53:
-    if (CpuRev == ARM_CPU_REV (0, 0)) {
-      JunoRevision = JUNO_R0;
-    } else if (CpuRev == ARM_CPU_REV (0, 3)) {
-      JunoRevision = JUNO_R1;
-    }
-    break;
-
-  case ARM_CPU_TYPE_A57:
-    if (CpuRev == ARM_CPU_REV (0, 0)) {
-      JunoRevision = JUNO_R0;
-    } else if (CpuRev == ARM_CPU_REV (1, 1)) {
-      JunoRevision = JUNO_R1;
-    }
-  }
+  GetJunoRevision(JunoRevision);
 
   //
   // Try to install the ACPI Tables
   //
-  if (JunoRevision == JUNO_R0) {
+  if (JunoRevision == JUNO_REVISION_R0) {
     Status = LocateAndInstallAcpiFromFvConditional (&mJunoAcpiTableFile, 
AcpiTableJunoR0Check);
-  } else if (JunoRevision == JUNO_R1) {
+  } else if (JunoRevision == JUNO_REVISION_R1) {
     Status = LocateAndInstallAcpiFromFvConditional (&mJunoAcpiTableFile, 
AcpiTableJunoR1Check);
   }
   ASSERT_EFI_ERROR (Status);
@@ -340,7 +304,7 @@ ArmJunoEntryPoint (
   //
   // Set the R1 two boot options if not already done.
   //
-  if (JunoRevision == JUNO_R1) {
+  if (JunoRevision == JUNO_REVISION_R1) {
     Status = SetJunoR1DefaultBootEntries ();
     if (EFI_ERROR (Status)) {
       return Status;
@@ -363,11 +327,11 @@ ArmJunoEntryPoint (
   // Set up the device path to the FDT.
   //
   switch (JunoRevision) {
-  case JUNO_R0:
+  case JUNO_REVISION_R0:
     TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR0FdtDevicePath);
     break;
 
-  case JUNO_R1:
+  case JUNO_REVISION_R1:
     TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR1A57x2FdtDevicePath);
     break;
 
-- 
2.4.3


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to