[U-Boot] [PATCH] arm64: versal: Add platform detection code to versal_virt

Michal Simek monstr at monstr.eu
Tue Oct 8 07:36:43 UTC 2019


st 11. 9. 2019 v 9:51 odesílatel Michal Simek <michal.simek at xilinx.com> napsal:
>
> 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 at xilinx.com>
> ---
>
>  arch/arm/mach-versal/cpu.c                   | 18 +++++---
>  arch/arm/mach-versal/include/mach/hardware.h |  9 ++++
>  board/xilinx/versal/board.c                  | 43 ++++++++++++++++++++
>  3 files changed, 65 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-versal/cpu.c b/arch/arm/mach-versal/cpu.c
> index f0d047d3232f..3505b4638ed8 100644
> --- a/arch/arm/mach-versal/cpu.c
> +++ b/arch/arm/mach-versal/cpu.c
> @@ -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
> diff --git a/arch/arm/mach-versal/include/mach/hardware.h b/arch/arm/mach-versal/include/mach/hardware.h
> index e26beab2e9cd..ac1bad02ec1c 100644
> --- a/arch/arm/mach-versal/include/mach/hardware.h
> +++ b/arch/arm/mach-versal/include/mach/hardware.h
> @@ -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 {
> diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
> index 5718e1aa7e47..12ea7a0d0589 100644
> --- a/board/xilinx/versal/board.c
> +++ b/board/xilinx/versal/board.c
> @@ -217,3 +217,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;
> +}
> --
> 2.17.1
>

This requires rework in connection to platform detection that's why not applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


More information about the U-Boot mailing list