]> 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 7f92931518efcf4d8349b36d7aa8e9c65253cb3e..2d41cd2ee168742718bb215df7ba4ff396256002 100644 (file)
@@ -26,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
@@ -77,11 +83,52 @@ ArmJunoEntryPoint (
     DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r
   }\r
 \r
-  // Try to install the ACPI Tables\r
-  Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\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