From: Michal Simek Date: Tue, 23 Jun 2026 12:53:35 +0000 (+0200) Subject: arm64: versal2: Move SoC detection out of board code X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=ad911ccef01f023087d1df1e980d6a3b5d940938;p=thirdparty%2Fu-boot.git arm64: versal2: Move SoC detection out of board code soc_detection() and soc_name_decode() read the PMC_TAP version/idcode registers and decode the platform. This is SoC information rather than board policy, and a firmware interface could provide it instead, so it does not belong in board code. Move both functions, together with the shared platform_id and platform_version state, into arch/arm/mach-versal2 where they still override the weak stubs in the Xilinx common board code. The board file drops the now unused linux/bitfield.h include. Signed-off-by: Michal Simek Link: https://patch.msgid.link/c332ab27f66f1c808f32a4bcb453d9e8da543331.1782219202.git.michal.simek@amd.com --- diff --git a/arch/arm/mach-versal2/cpu.c b/arch/arm/mach-versal2/cpu.c index 07bb1a61b17..6cc6592b0fc 100644 --- a/arch/arm/mach-versal2/cpu.c +++ b/arch/arm/mach-versal2/cpu.c @@ -8,15 +8,21 @@ #include #include +#include #include +#include #include #include #include #include +#include #include #include #include #include +#include +#include +#include "../../../board/xilinx/common/board.h" DECLARE_GLOBAL_DATA_PTR; @@ -195,6 +201,75 @@ void versal2_timer_setup(void) debug("timer 0x%llx\n", get_ticks()); } +static u32 platform_id, platform_version; + +char *soc_name_decode(void) +{ + char *name, *platform_name; + + switch (platform_id) { + case VERSAL2_SPP: + platform_name = "spp"; + break; + case VERSAL2_EMU: + platform_name = "emu"; + break; + case VERSAL2_SPP_MMD: + platform_name = "spp-mmd"; + break; + case VERSAL2_EMU_MMD: + platform_name = "emu-mmd"; + break; + case VERSAL2_QEMU: + platform_name = "qemu"; + break; + default: + return NULL; + } + + /* + * --rev.-el are 9 chars + * max platform name is emu-mmd which is 7 chars + * platform version number are 1+1 + * el is 1 char + * Plus 1 char for NULL byte + */ + name = calloc(1, strlen(CONFIG_SYS_BOARD) + 20); + if (!name) + return NULL; + + sprintf(name, "%s-%s-rev%d.%d-el%d", CONFIG_SYS_BOARD, + platform_name, platform_version / 10, + platform_version % 10, current_el()); + + return name; +} + +bool soc_detection(void) +{ + u32 version, ps_version; + + version = readl(PMC_TAP_VERSION); + platform_id = FIELD_GET(PLATFORM_MASK, version); + ps_version = FIELD_GET(PS_VERSION_MASK, version); + + debug("idcode %x, version %x, usercode %x\n", + readl(PMC_TAP_IDCODE), version, + readl(PMC_TAP_USERCODE)); + + debug("pmc_ver %lx, ps version %x, rtl version %lx\n", + FIELD_GET(PMC_VERSION_MASK, version), + ps_version, + FIELD_GET(RTL_VERSION_MASK, version)); + + platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version); + + debug("Platform id: %d version: %d.%d\n", platform_id, + platform_version / 10, platform_version % 10); + + return true; +} + U_BOOT_DRVINFO(soc_amd_versal2) = { .name = "soc_amd_versal2", }; diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c index 7f2fb4c1ec6..2afd283b8dd 100644 --- a/board/amd/versal2/board.c +++ b/board/amd/versal2/board.c @@ -31,8 +31,6 @@ #include #include "../../xilinx/common/board.h" -#include -#include #include #include #include @@ -61,75 +59,6 @@ int board_init(void) return 0; } -static u32 platform_id, platform_version; - -char *soc_name_decode(void) -{ - char *name, *platform_name; - - switch (platform_id) { - case VERSAL2_SPP: - platform_name = "spp"; - break; - case VERSAL2_EMU: - platform_name = "emu"; - break; - case VERSAL2_SPP_MMD: - platform_name = "spp-mmd"; - break; - case VERSAL2_EMU_MMD: - platform_name = "emu-mmd"; - break; - case VERSAL2_QEMU: - platform_name = "qemu"; - break; - default: - return NULL; - } - - /* - * --rev.-el are 9 chars - * max platform name is emu-mmd which is 7 chars - * platform version number are 1+1 - * el is 1 char - * Plus 1 char for NULL byte - */ - name = calloc(1, strlen(CONFIG_SYS_BOARD) + 20); - if (!name) - return NULL; - - sprintf(name, "%s-%s-rev%d.%d-el%d", CONFIG_SYS_BOARD, - platform_name, platform_version / 10, - platform_version % 10, current_el()); - - return name; -} - -bool soc_detection(void) -{ - u32 version, ps_version; - - version = readl(PMC_TAP_VERSION); - platform_id = FIELD_GET(PLATFORM_MASK, version); - ps_version = FIELD_GET(PS_VERSION_MASK, version); - - debug("idcode %x, version %x, usercode %x\n", - readl(PMC_TAP_IDCODE), version, - readl(PMC_TAP_USERCODE)); - - debug("pmc_ver %lx, ps version %x, rtl version %lx\n", - FIELD_GET(PMC_VERSION_MASK, version), - ps_version, - FIELD_GET(RTL_VERSION_MASK, version)); - - platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version); - - debug("Platform id: %d version: %d.%d\n", platform_id, - platform_version / 10, platform_version % 10); - - return true; -} - int board_early_init_r(void) { if (current_el() != 3)