From: Marcello Sylvester Bauer <[email protected]>

Add board_fit_config_name_match() for runtime FIT configuration
selection based on server ID register.
Add ft_board_setup() to populate device tree with board properties.

Signed-off-by: Marcello Sylvester Bauer <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
---
 board/hpe/gxp/gxp_board.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---
 configs/gxp_defconfig     |  1 +
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/board/hpe/gxp/gxp_board.c b/board/hpe/gxp/gxp_board.c
index d94d9b8a19e..b37725761af 100644
--- a/board/hpe/gxp/gxp_board.c
+++ b/board/hpe/gxp/gxp_board.c
@@ -1,22 +1,78 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * GXP timer driver
+ * GXP board support
  *
  * (C) Copyright 2022 Hewlett Packard Enterprise Development LP.
  * Author: Nick Hawkins <[email protected]>
  * Author: Jean-Marie Verdun <[email protected]>
+ *
+ * Copyright (C) 2026 9elements GmbH
  */
 
+#include <linux/bitfield.h>
 #include <linux/sizes.h>
 #include <asm/io.h>
 #include <dm.h>
 #include <dm/uclass.h>
-#include <ram.h>
+#include <fdt_support.h>
+#include <init.h>
+#include <sysinfo.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #define ECHI_CMD 0xcefe0010
 
+#define GXP_XREG_BASE          0xd1000000
+#define GXP_XREG_SERVER_ID     GENMASK(23, 8)
+
+static u16 gxp_get_server_id(void)
+{
+       return FIELD_GET(GXP_XREG_SERVER_ID, readl(GXP_XREG_BASE));
+}
+
+int board_fit_config_name_match(const char *name)
+{
+       char expected[16];
+       u16 server_id;
+
+       server_id = gxp_get_server_id();
+       snprintf(expected, sizeof(expected), "gxp-0x%04x", server_id);
+
+       if (strstr(name, expected))
+               return 0;
+
+       return -1;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+       struct udevice *dev;
+       char str[64];
+       int ret;
+
+       ret = sysinfo_get(&dev);
+       if (ret)
+               return 0;
+
+       ret = sysinfo_detect(dev);
+       if (ret)
+               return 0;
+
+       ret = sysinfo_get_str(dev, SYSID_BOARD_MANUFACTURER, sizeof(str), str);
+       if (!ret)
+               fdt_setprop_string(blob, 0, "manufacturer", str);
+
+       ret = sysinfo_get_str(dev, SYSID_SM_SYSTEM_SERIAL, sizeof(str), str);
+       if (!ret)
+               fdt_setprop_string(blob, 0, "serial-number", str);
+
+       ret = sysinfo_get_str(dev, SYSID_SM_BASEBOARD_PRODUCT, sizeof(str), 
str);
+       if (!ret)
+               fdt_setprop_string(blob, 0, "part-number", str);
+
+       return 0;
+}
+
 int board_init(void)
 {
        writel(0x00080002, ECHI_CMD);
@@ -72,4 +128,3 @@ int dram_init(void)
 
        return 0;
 }
-
diff --git a/configs/gxp_defconfig b/configs/gxp_defconfig
index 5501f9aefae..fd59fc8e50e 100644
--- a/configs/gxp_defconfig
+++ b/configs/gxp_defconfig
@@ -28,6 +28,7 @@ CONFIG_BOOTCOMMAND="run spiboot"
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYSINFO=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="gxp# "
 # CONFIG_BOOTM_PLAN9 is not set

-- 
2.53.0

Reply via email to