From 7aec2926b926ad90d09fb026af0ee04c4c831237 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Thu, 26 Feb 2015 10:57:27 +0000 Subject: [PATCH] ArmPlatformPkg/ArmJunoDxe: Set the platform dependent FDT device path The MIDR register of the CPU on which the UEFI firmware is running on is used to infer if the platform is a Juno r0 or a Juno r1. The right device path to the platform FDT is then stored in the "gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths" dynamic PCD. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron Reviewed-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16939 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Include/Chipset/AArch64.h | 4 +- ArmPkg/Include/Chipset/ArmV7.h | 5 +- ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec | 6 +- ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 29 ++++------ ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf | 5 ++ .../Drivers/ArmJunoDxe/ArmJunoDxe.c | 55 +++++++++++++++++-- .../Drivers/ArmJunoDxe/ArmJunoDxe.inf | 7 ++- .../Drivers/ArmJunoDxe/ArmJunoDxeInternal.h | 5 +- 8 files changed, 90 insertions(+), 26 deletions(-) diff --git a/ArmPkg/Include/Chipset/AArch64.h b/ArmPkg/Include/Chipset/AArch64.h index 0400740247..47993ec9fc 100644 --- a/ArmPkg/Include/Chipset/AArch64.h +++ b/ArmPkg/Include/Chipset/AArch64.h @@ -1,7 +1,7 @@ /** @file Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -44,12 +44,14 @@ #define SCR_AW (1 << 5) // MIDR - Main ID Register definitions +#define ARM_CPU_TYPE_SHIFT 4 #define ARM_CPU_TYPE_MASK 0xFFF #define ARM_CPU_TYPE_AEMv8 0xD0F #define ARM_CPU_TYPE_A53 0xD03 #define ARM_CPU_TYPE_A57 0xD07 #define ARM_CPU_TYPE_A15 0xC0F #define ARM_CPU_TYPE_A9 0xC09 +#define ARM_CPU_TYPE_A7 0xC07 #define ARM_CPU_TYPE_A5 0xC05 #define ARM_CPU_REV_MASK ((0xF << 20) | (0xF) ) diff --git a/ArmPkg/Include/Chipset/ArmV7.h b/ArmPkg/Include/Chipset/ArmV7.h index ceb32170ed..4fb06636e0 100644 --- a/ArmPkg/Include/Chipset/ArmV7.h +++ b/ArmPkg/Include/Chipset/ArmV7.h @@ -1,7 +1,7 @@ /** @file Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2015, ARM Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -75,12 +75,15 @@ #define SCR_AW (1 << 5) // MIDR - Main ID Register definitions +#define ARM_CPU_TYPE_SHIFT 4 #define ARM_CPU_TYPE_MASK 0xFFF #define ARM_CPU_TYPE_AEMv8 0xD0F #define ARM_CPU_TYPE_A53 0xD03 #define ARM_CPU_TYPE_A57 0xD07 #define ARM_CPU_TYPE_A15 0xC0F +#define ARM_CPU_TYPE_A12 0xC0D #define ARM_CPU_TYPE_A9 0xC09 +#define ARM_CPU_TYPE_A7 0xC07 #define ARM_CPU_TYPE_A5 0xC05 #define ARM_CPU_REV_MASK ((0xF << 20) | (0xF) ) diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec index 051ffbbb60..2ce207ef30 100644 --- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec +++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2013-2015, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -34,3 +34,7 @@ [PcdsFixedAtBuild.common] gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress|0x7FFB0000|UINT32|0x00000004 gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress|0x7FFC0000|UINT32|0x00000005 + + # Juno Device Trees are loaded from NOR Flash + gArmJunoTokenSpaceGuid.PcdR0FdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno_r0.dtb"|VOID*|0x00000006 + gArmJunoTokenSpaceGuid.PcdR1FdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno_r1.dtb"|VOID*|0x00000007 diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc index 1639bf4269..9b12528922 100644 --- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc +++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2014, ARM Limited. All rights reserved. +# Copyright (c) 2013-2015, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -59,6 +59,9 @@ PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf +[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVER] + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + [BuildOptions] *_*_*_PLATFORM_FLAGS == -I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include -I$(WORKSPACE)/ArmPlatformPkg/ArmJunoPkg/Include @@ -132,22 +135,6 @@ # List of Device Paths that support BootMonFs gArmPlatformTokenSpaceGuid.PcdBootMonFsSupportedDevicePaths|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)" - # - # Define the device path to the FDT for its installation - # -!ifdef $(JUNO_EMULATOR) - # From DRAM - gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(30F57E4A-69CE-4FB7-B7A1-4C7CE49D57A6)/MemoryMapped(0x0,0x88000000,0x88200000)" -!else -!ifdef $(JUNO_MODEL) - # From semi-hosting - gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/juno.dtb" -!else - # From NOR flash - gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno.dtb" -!endif -!endif - # # ARM OS Loader # @@ -174,6 +161,14 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|1920 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|1080 +[PcdsDynamicDefault.common] + # + # The size of a dynamic PCD of the (VOID*) type can not be increased at run + # time from its size at build time. Set the "PcdFdtDevicePaths" PCD to a 128 + # character "empty" string, to allow to be able to set FDT text device paths + # up to 128 characters long. + # + gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L" " ################################################################################ # diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf index b36c77ab90..f399c91ffe 100644 --- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf +++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf @@ -85,7 +85,12 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE + APRIORI DXE { + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + } + INF MdeModulePkg/Core/Dxe/DxeMain.inf + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf # # PI DXE Drivers producing Architectural Protocols (EFI Services) diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c index 7f92931518..2d41cd2ee1 100644 --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c @@ -26,8 +26,14 @@ ArmJunoEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS HypBase; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS HypBase; + CHAR16 *TextDevicePath; + UINTN TextDevicePathSize; + VOID *Buffer; + UINT32 Midr; + UINT32 CpuType; + UINT32 CpuRev; Status = PciEmulationEntryPoint (); if (EFI_ERROR (Status)) { @@ -77,11 +83,52 @@ ArmJunoEntryPoint ( DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n")); } - // Try to install the ACPI Tables - Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile); + // + // Set up the device path to the FDT. + // 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; + TextDevicePath = NULL; + + switch (CpuType) { + case ARM_CPU_TYPE_A53: + if (CpuRev == ARM_CPU_REV (0, 0)) { + TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath); + } else if (CpuRev == ARM_CPU_REV (0, 3)) { + TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath); + } + break; + + case ARM_CPU_TYPE_A57: + if (CpuRev == ARM_CPU_REV (0, 0)) { + TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath); + } else if (CpuRev == ARM_CPU_REV (1, 1)) { + TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath); + } + } + + if (TextDevicePath != NULL) { + TextDevicePathSize = StrSize (TextDevicePath); + Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath); + Status = (Buffer != NULL) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL; + } else { + Status = EFI_NOT_FOUND; + } + if (EFI_ERROR (Status)) { + DEBUG ( + (EFI_D_ERROR, + "ArmJunoDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", Status) + ); return Status; } + // Try to install the ACPI Tables + Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile); + return Status; } diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf index d29703b20f..323ed5f49d 100644 --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf @@ -32,6 +32,7 @@ [LibraryClasses] AcpiLib + ArmLib ArmShellCmdRunAxfLib BaseMemoryLib BdsLib @@ -68,7 +69,11 @@ gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress - gArmPlatformTokenSpaceGuid.PcdFdtDevicePath + gArmJunoTokenSpaceGuid.PcdR0FdtDevicePath + gArmJunoTokenSpaceGuid.PcdR1FdtDevicePath + +[Pcd] + gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths [Depex] TRUE diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxeInternal.h b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxeInternal.h index a9f58dd00b..c7b1865877 100644 --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxeInternal.h +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxeInternal.h @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2013-2014, ARM Limited. All rights reserved. +* Copyright (c) 2013-2015, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -17,6 +17,9 @@ #include +#include +#include +#include #include #include #include -- 2.39.2