]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal-net: Move SoC detection out of board code
authorMichal Simek <michal.simek@amd.com>
Tue, 23 Jun 2026 12:53:36 +0000 (14:53 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 8 Jul 2026 06:55:51 +0000 (08:55 +0200)
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-versal-net 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 <michal.simek@amd.com>
Link: https://patch.msgid.link/8757111cb254543d61541fb030d51f62c3c555a8.1782219202.git.michal.simek@amd.com
arch/arm/mach-versal-net/cpu.c
board/xilinx/versal-net/board.c

index bce66124c47b3a7bc2bfb2d2c564f6f835f15a08..2974d89f90285ae73f37ed190d17322fc46188db 100644 (file)
@@ -8,7 +8,9 @@
 
 #include <init.h>
 #include <log.h>
+#include <malloc.h>
 #include <time.h>
+#include <vsprintf.h>
 #include <asm/armv8/mmu.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
@@ -17,6 +19,9 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/cache.h>
 #include <dm/platdata.h>
+#include <linux/bitfield.h>
+#include <linux/string.h>
+#include "../../../board/xilinx/common/board.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -131,6 +136,92 @@ void versal_net_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 VERSAL_NET_SPP:
+               platform_name = "ipp";
+               break;
+       case VERSAL_NET_EMU:
+               platform_name = "emu";
+               break;
+       case VERSAL_NET_QEMU:
+               platform_name = "qemu";
+               break;
+       default:
+               return NULL;
+       }
+
+       /*
+        * --rev. are 6 chars
+        * max platform name is qemu which is 4 chars
+        * platform version number are 1+1
+        * Plus 1 char for \n
+        */
+       name = calloc(1, strlen(CONFIG_SYS_BOARD) + 13);
+       if (!name)
+               return NULL;
+
+       sprintf(name, "%s-%s-rev%d.%d", CONFIG_SYS_BOARD,
+               platform_name, platform_version / 10,
+               platform_version % 10);
+
+       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);
+
+       if (platform_id == VERSAL_NET_SPP ||
+           platform_id == VERSAL_NET_EMU) {
+               if (ps_version == PS_VERSION_PRODUCTION) {
+                       /*
+                        * ES1 version ends at 1.9 version where there was +9
+                        * used because of IPP/SPP conversion. Production
+                        * version have platform_version started from 0 again
+                        * that's why adding +20 to continue with the same line.
+                        * It means the last ES1 version ends at 1.9 version and
+                        * new PRODUCTION line starts at 2.0.
+                        */
+                       platform_version += 20;
+               } else {
+                       /*
+                        * 9 is diff for
+                        * 0 means 0.9 version
+                        * 1 means 1.0 version
+                        * 2 means 1.1 version
+                        * etc,
+                        */
+                       platform_version += 9;
+               }
+       }
+
+       debug("Platform id: %d version: %d.%d\n", platform_id,
+             platform_version / 10, platform_version % 10);
+
+       return true;
+}
+
 U_BOOT_DRVINFO(soc_xilinx_versal_net) = {
        .name = "soc_xilinx_versal_net",
 };
index a40039a1dc8e6bc183b70e624576b6d802031bd6..3c69edc22606734d32d7ba0f99094229ca6b1c68 100644 (file)
@@ -25,7 +25,6 @@
 #include <versalpl.h>
 #include "../common/board.h"
 
-#include <linux/bitfield.h>
 #include <debug_uart.h>
 #include <generated/dt.h>
 
@@ -49,92 +48,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 VERSAL_NET_SPP:
-               platform_name = "ipp";
-               break;
-       case VERSAL_NET_EMU:
-               platform_name = "emu";
-               break;
-       case VERSAL_NET_QEMU:
-               platform_name = "qemu";
-               break;
-       default:
-               return NULL;
-       }
-
-       /*
-        * --rev. are 6 chars
-        * max platform name is qemu which is 4 chars
-        * platform version number are 1+1
-        * Plus 1 char for \n
-        */
-       name = calloc(1, strlen(CONFIG_SYS_BOARD) + 13);
-       if (!name)
-               return NULL;
-
-       sprintf(name, "%s-%s-rev%d.%d", CONFIG_SYS_BOARD,
-               platform_name, platform_version / 10,
-               platform_version % 10);
-
-       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);
-
-       if (platform_id == VERSAL_NET_SPP ||
-           platform_id == VERSAL_NET_EMU) {
-               if (ps_version == PS_VERSION_PRODUCTION) {
-                       /*
-                        * ES1 version ends at 1.9 version where there was +9
-                        * used because of IPP/SPP conversion. Production
-                        * version have platform_version started from 0 again
-                        * that's why adding +20 to continue with the same line.
-                        * It means the last ES1 version ends at 1.9 version and
-                        * new PRODUCTION line starts at 2.0.
-                        */
-                       platform_version += 20;
-               } else {
-                       /*
-                        * 9 is diff for
-                        * 0 means 0.9 version
-                        * 1 means 1.0 version
-                        * 2 means 1.1 version
-                        * etc,
-                        */
-                       platform_version += 9;
-               }
-       }
-
-       debug("Platform id: %d version: %d.%d\n", platform_id,
-             platform_version / 10, platform_version % 10);
-
-       return true;
-}
-
 int board_early_init_f(void)
 {
        if (IS_ENABLED(CONFIG_DEBUG_UART)) {