]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
ArmPlatformPkg/ArmJunoDxe: Set the platform dependent FDT device path
[mirror_edk2.git] / ArmPlatformPkg / ArmJunoPkg / Drivers / ArmJunoDxe / ArmJunoDxe.c
index 70d632927a7e46e11d68bfa6b68a0221050cdb76..2d41cd2ee168742718bb215df7ba4ff396256002 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
 \r
 #include "ArmJunoDxeInternal.h"\r
 #include <Library/ArmShellCmdLib.h>\r
+#include <Library/AcpiLib.h>\r
+\r
+// This GUID must match the FILE_GUID in ArmPlatformPkg/ArmJunoPkg/AcpiTables/AcpiTables.inf\r
+STATIC CONST EFI_GUID mJunoAcpiTableFile = { 0xa1dd808e, 0x1e95, 0x4399, { 0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } };\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -22,8 +26,14 @@ ArmJunoEntryPoint (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  EFI_STATUS           Status;\r
-  EFI_PHYSICAL_ADDRESS HypBase;\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  HypBase;\r
+  CHAR16                *TextDevicePath;\r
+  UINTN                 TextDevicePathSize;\r
+  VOID                  *Buffer;\r
+  UINT32                Midr;\r
+  UINT32                CpuType;\r
+  UINT32                CpuRev;\r
 \r
   Status = PciEmulationEntryPoint ();\r
   if (EFI_ERROR (Status)) {\r
@@ -73,9 +83,52 @@ ArmJunoEntryPoint (
     DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r
   }\r
 \r
-  // Try to install the Flat Device Tree (FDT). This function actually installs the\r
-  // UEFI Driver Binding Protocol.\r
-  Status = JunoFdtInstall (ImageHandle);\r
+  //\r
+  // Set up the device path to the FDT.\r
+  // We detect whether we are running on a Juno r0 or Juno r1 board at\r
+  // runtime by checking the value of the MIDR register.\r
+  //\r
+\r
+  Midr    = ArmReadMidr ();\r
+  CpuType = (Midr >> ARM_CPU_TYPE_SHIFT) & ARM_CPU_TYPE_MASK;\r
+  CpuRev  = Midr & ARM_CPU_REV_MASK;\r
+  TextDevicePath = NULL;\r
+\r
+  switch (CpuType) {\r
+  case ARM_CPU_TYPE_A53:\r
+    if (CpuRev == ARM_CPU_REV (0, 0)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath);\r
+    } else if (CpuRev == ARM_CPU_REV (0, 3)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath);\r
+    }\r
+    break;\r
+\r
+  case ARM_CPU_TYPE_A57:\r
+    if (CpuRev == ARM_CPU_REV (0, 0)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath);\r
+    } else if (CpuRev == ARM_CPU_REV (1, 1)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath);\r
+    }\r
+  }\r
+\r
+  if (TextDevicePath != NULL) {\r
+    TextDevicePathSize = StrSize (TextDevicePath);\r
+    Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath);\r
+    Status = (Buffer != NULL) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    Status = EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      "ArmJunoDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", Status)\r
+      );\r
+    return Status;\r
+  }\r
+\r
+  // Try to install the ACPI Tables\r
+  Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\r
 \r
   return Status;\r
 }\r