From f6f5bf4a24c42e41774406b554a088fda8979a88 Mon Sep 17 00:00:00 2001 From: Khoi Trinh Date: Sat, 4 Jan 2025 18:30:44 -0800 Subject: [PATCH] smbios support --- arch/arm/mach-apple/board.c | 21 +++++++++++++++++++-- configs/apple_m1_defconfig | 1 - 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c index 59f536b0d3e..c0ff5a3e28a 100644 --- a/arch/arm/mach-apple/board.c +++ b/arch/arm/mach-apple/board.c @@ -709,7 +709,7 @@ void build_mem_map(void) int i; if (of_machine_is_compatible("apple,t8103") || - of_machine_is_compatible("apple,t8112")) + of_machine_is_compatible("apple,t8112")) mem_map = t8103_mem_map; else if (of_machine_is_compatible("apple,t6000") || of_machine_is_compatible("apple,t6001")) @@ -845,6 +845,8 @@ char *env_fat_get_dev_part(void) int board_late_init(void) { struct lmb lmb; + int root_node_offset; + const char* serial_number; u32 status = 0; status |= env_set("storage_interface", @@ -861,10 +863,25 @@ int board_late_init(void) status |= env_set_hex("kernel_addr_r", lmb_alloc(&lmb, SZ_128M, SZ_2M)); status |= env_set_hex("ramdisk_addr_r", lmb_alloc(&lmb, SZ_1G, SZ_2M)); status |= env_set_hex("kernel_comp_addr_r", - lmb_alloc(&lmb, KERNEL_COMP_SIZE, SZ_2M)); + lmb_alloc(&lmb, KERNEL_COMP_SIZE, SZ_2M)); status |= env_set_hex("kernel_comp_size", KERNEL_COMP_SIZE); status |= env_set_hex("scriptaddr", lmb_alloc(&lmb, SZ_4M, SZ_2M)); status |= env_set_hex("pxefile_addr_r", lmb_alloc(&lmb, SZ_4M, SZ_2M)); + + root_node_offset = fdt_path_offset((const void*) fw_dtb_pointer, "/"); + if (root_node_offset < 0) { + log_warning("late_init: fdt_path_offset() for root_node_offset returned %s\n", fdt_strerror(root_node_offset)); + status = 1; + } else { + serial_number = fdt_getprop((const void*) fw_dtb_pointer, root_node_offset, "serial-number", NULL); + if(serial_number) { + status |= env_set("serial#", serial_number); + log_info("late_init: serial number is %s\n", serial_number); + } else { + log_warning("late_init: Failed to get serial number from device tree\n"); + status = 1; + } + } if (status) log_warning("late_init: Failed to set run time variables\n"); diff --git a/configs/apple_m1_defconfig b/configs/apple_m1_defconfig index 2d79aaca90a..e04b041dd37 100644 --- a/configs/apple_m1_defconfig +++ b/configs/apple_m1_defconfig @@ -23,5 +23,4 @@ CONFIG_USB_KEYBOARD=y CONFIG_SYS_WHITE_ON_BLACK=y CONFIG_NO_FB_CLEAR=y CONFIG_VIDEO_SIMPLE=y -# CONFIG_SMBIOS is not set CONFIG_LMB_MAX_REGIONS=64