]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal: Add platform detection code to versal_virt
authorMichal Simek <michal.simek@xilinx.com>
Thu, 6 Jun 2019 13:00:35 +0000 (15:00 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 6 Jun 2019 13:00:35 +0000 (15:00 +0200)
Detect which platform U-Boot is running at and based on that choose DTS
file which U-Boot uses for own configuration.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/mach-versal/cpu.c
arch/arm/mach-versal/include/mach/hardware.h
board/xilinx/versal/board.c

index f0d047d3232f7e871fa8a9b45345bd012ccbe33d..3505b4638ed82c914c50bdabefb60fe354f66e2f 100644 (file)
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <asm/armv8/mmu.h>
 #include <asm/io.h>
+#include <asm/sections.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
 
@@ -113,11 +114,18 @@ void *board_fdt_blob_setup(void)
 {
        static void *fw_dtb = (void *)CONFIG_VERSAL_OF_BOARD_DTB_ADDR;
 
-       if (fdt_magic(fw_dtb) != FDT_MAGIC) {
-               printf("DTB is not passed via %llx\n", (u64)fw_dtb);
-               return NULL;
-       }
+       if (fdt_magic(fw_dtb) == FDT_MAGIC)
+               return fw_dtb;
+
+       printf("DTB is not passed via 0x%llx\n", (u64)fw_dtb);
+
+       /* Try to look at FDT is at end of image */
+       fw_dtb = (ulong *)&_end;
+
+       if (fdt_magic(fw_dtb) == FDT_MAGIC)
+               return fw_dtb;
 
-       return fw_dtb;
+       printf("DTB is also not passed via 0x%llx\n", (u64)fw_dtb);
+       return NULL;
 }
 #endif
index e26beab2e9cde409b1e0ddfab043593a7f45cead..ac1bad02ec1cb7c2658601d0a7c2aa0751c566ab 100644 (file)
@@ -52,6 +52,15 @@ struct rpu_regs {
 
 #define rpu_base ((struct rpu_regs *)VERSAL_RPU_BASEADDR)
 
+#define VERSAL_PMC_TAP_BASEADDR        0xF11A0000
+
+struct pmc_tap_regs {
+       u32 idcode; /* 0x0 */
+       u32 version; /* 0x4 */
+};
+
+#define pmc_base_base ((struct pmc_tap_regs *)VERSAL_PMC_TAP_BASEADDR)
+
 #define VERSAL_CRP_BASEADDR    0xF1260000
 
 struct crp_regs {
index 757286a0415c87212949fe3dc82684c0500840ea..c4b15a6a9f660f9bee696c53b1179c6864c493a6 100644 (file)
@@ -201,3 +201,46 @@ int dram_init(void)
 void reset_cpu(ulong addr)
 {
 }
+
+#define PMC_TAP_VERSION_PLATFORM_MASK  0xF
+#define PMC_TAP_VERSION_PLATFORM_SHIFT 24
+
+/* pmc_tap_version platform */
+#define PMC_TAP_VERSION_SILICON        0
+#define PMC_TAP_VERSION_SPP    1
+#define PMC_TAP_VERSION_EMU    2
+#define PMC_TAP_VERSION_QEMU   3
+
+int __maybe_unused board_fit_config_name_match(const char *name)
+{
+       u32 version, platform;
+       char *platform_name = NULL;
+
+       version = readl(&pmc_base_base->version);
+       platform = (version >> PMC_TAP_VERSION_PLATFORM_SHIFT) &
+                  PMC_TAP_VERSION_PLATFORM_MASK;
+
+       switch (platform) {
+       case PMC_TAP_VERSION_SILICON:
+               platform_name = "versal-tenzing"; /* For now */
+               debug("Running on Silicon\n");
+               break;
+       case PMC_TAP_VERSION_SPP:
+               platform_name = "versal-spp";
+               break;
+       case PMC_TAP_VERSION_EMU:
+               platform_name = "versal-emu";
+               break;
+       case PMC_TAP_VERSION_QEMU:
+               platform_name = "versal-qemu"; /* Internal QEMU */
+               debug("Running on QEMU which is suspicious\n");
+               break;
+       }
+
+       if (!strncmp(name, platform_name, sizeof(platform_name))) {
+               printf("Selecting DTB %s for board %s\n", name, platform_name);
+               return 0;
+       }
+
+       return -1;
+}