diff options
| author | Simon Glass <[email protected]> | 2024-11-02 11:49:42 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-12-18 15:18:59 -0600 |
| commit | fc37a73e667916e15e01e0f9d189da792df2b351 (patch) | |
| tree | dfbf6aa2fd3a9af4d7900f929d06ea753b009670 /board | |
| parent | 447f18d00de80384df334acdbe5972762d3d1e1e (diff) | |
fdt: Swap the signature for board_fdt_blob_setup()
This returns a devicetree and updates a parameter with an error code.
Swap it, since this fits better with the way U-Boot normally works. It
also (more easily) allows leaving the existing pointer unchanged.
No yaks were harmed in this change, but there is a very small code-size
reduction.
For sifive, the OF_BOARD option must be set for the function to be
called, so there is no point in checking it again. Also OF_SEPARATE is
defined always.
Signed-off-by: Simon Glass <[email protected]>
Reviewed-by: Matthias Brugger <[email protected]>
Reviewed-by: Patrice Chotard <[email protected]>
[trini: Update total_compute]
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'board')
| -rw-r--r-- | board/Marvell/octeontx/board-fdt.c | 12 | ||||
| -rw-r--r-- | board/Marvell/octeontx2/board-fdt.c | 12 | ||||
| -rw-r--r-- | board/Marvell/octeontx2/board.c | 3 | ||||
| -rw-r--r-- | board/andestech/ae350/ae350.c | 23 | ||||
| -rw-r--r-- | board/armltd/total_compute/total_compute.c | 12 | ||||
| -rw-r--r-- | board/armltd/vexpress64/vexpress64.c | 33 | ||||
| -rw-r--r-- | board/broadcom/bcmstb/bcmstb.c | 7 | ||||
| -rw-r--r-- | board/emulation/qemu-arm/qemu-arm.c | 7 | ||||
| -rw-r--r-- | board/emulation/qemu-ppce500/qemu-ppce500.c | 12 | ||||
| -rw-r--r-- | board/emulation/qemu-riscv/qemu-riscv.c | 7 | ||||
| -rw-r--r-- | board/highbank/highbank.c | 7 | ||||
| -rw-r--r-- | board/raspberrypi/rpi/rpi.c | 13 | ||||
| -rw-r--r-- | board/sifive/unleashed/unleashed.c | 12 | ||||
| -rw-r--r-- | board/sifive/unmatched/unmatched.c | 11 | ||||
| -rw-r--r-- | board/starfive/visionfive2/starfive_visionfive2.c | 11 | ||||
| -rw-r--r-- | board/xen/xenguest_arm64/xenguest_arm64.c | 14 | ||||
| -rw-r--r-- | board/xilinx/common/board.c | 26 |
17 files changed, 106 insertions, 116 deletions
diff --git a/board/Marvell/octeontx/board-fdt.c b/board/Marvell/octeontx/board-fdt.c index 6642b167e19..9d913b959e0 100644 --- a/board/Marvell/octeontx/board-fdt.c +++ b/board/Marvell/octeontx/board-fdt.c @@ -296,13 +296,9 @@ int ft_board_setup(void *blob, struct bd_info *bd) return 0; } -/** - * Return the FDT base address that was passed by ATF - * - * Return: FDT base address received from ATF in x1 register - */ -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - return (void *)fdt_base_addr; + *fdtp = (void *)fdt_base_addr; + + return 0; } diff --git a/board/Marvell/octeontx2/board-fdt.c b/board/Marvell/octeontx2/board-fdt.c index 04be9fb0a9a..e5a4db00bb7 100644 --- a/board/Marvell/octeontx2/board-fdt.c +++ b/board/Marvell/octeontx2/board-fdt.c @@ -210,13 +210,9 @@ int ft_board_setup(void *blob, struct bd_info *bd) return 0; } -/** - * Return the FDT base address that was passed by ATF - * - * Return: FDT base address received from ATF in x1 register - */ -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - return (void *)fdt_base_addr; + *fdtp = (void *)fdt_base_addr; + + return 0; } diff --git a/board/Marvell/octeontx2/board.c b/board/Marvell/octeontx2/board.c index 974e9eb8200..01ba53cf68d 100644 --- a/board/Marvell/octeontx2/board.c +++ b/board/Marvell/octeontx2/board.c @@ -234,7 +234,8 @@ static int do_go_uboot(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; addr = hextoul(argv[1], NULL); - fdt = board_fdt_blob_setup(&err); + fdt = (void *)gd->fdt_blob; + err = board_fdt_blob_setup(&fdt); entry = (uboot_entry_t)addr; flush_cache((ulong)addr, 1 << 20); /* 1MiB should be enough */ dcache_disable(); diff --git a/board/andestech/ae350/ae350.c b/board/andestech/ae350/ae350.c index 5ae5baed6ba..1d9d4a929c2 100644 --- a/board/andestech/ae350/ae350.c +++ b/board/andestech/ae350/ae350.c @@ -79,21 +79,24 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) } #define ANDES_HW_DTB_ADDRESS 0xF2000000 -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { - if (fdt_magic((uintptr_t)gd->arch.firmware_fdt_addr) == FDT_MAGIC) - return (void *)(ulong)gd->arch.firmware_fdt_addr; + if (fdt_magic((uintptr_t)gd->arch.firmware_fdt_addr) == + FDT_MAGIC) { + *fdtp = (void *)(ulong)gd->arch.firmware_fdt_addr; + + return 0; + } } - if (fdt_magic(CONFIG_SYS_FDT_BASE) == FDT_MAGIC) - return (void *)CONFIG_SYS_FDT_BASE; - return (void *)ANDES_HW_DTB_ADDRESS; + if (fdt_magic(CONFIG_SYS_FDT_BASE) == FDT_MAGIC) { + *fdtp = (void *)CONFIG_SYS_FDT_BASE; + + return 0; + } - *err = -EINVAL; - return NULL; + return -EINVAL; } #ifdef CONFIG_SPL_BOARD_INIT diff --git a/board/armltd/total_compute/total_compute.c b/board/armltd/total_compute/total_compute.c index 1336d2eb163..75ba3c33d56 100644 --- a/board/armltd/total_compute/total_compute.c +++ b/board/armltd/total_compute/total_compute.c @@ -37,15 +37,13 @@ struct mm_region *mem_map = total_compute_mem_map; */ unsigned long __section(".data") fw_dtb_pointer; -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) { - *err = -ENXIO; - return NULL; - } + if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) + return -ENXIO; - return (void *)fw_dtb_pointer; + *fdtp = (void *)fw_dtb_pointer; + return 0; } int misc_init_r(void) diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c index 0119f54f0df..b5ede58757d 100644 --- a/board/armltd/vexpress64/vexpress64.c +++ b/board/armltd/vexpress64/vexpress64.c @@ -168,42 +168,37 @@ static bool is_valid_dtb(uintptr_t dtb_ptr) return fdt_subnode_offset((void *)dtb_ptr, 0, "memory") >= 0; } -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { #ifdef CONFIG_TARGET_VEXPRESS64_JUNO phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART); - *err = 0; - if (fdt_rom_addr == ~0UL) { - *err = -ENXIO; - return NULL; - } + if (fdt_rom_addr == ~0UL) + return -ENXIO; - return (void *)fdt_rom_addr; + *fdtp = (void *)fdt_rom_addr; + return 0; #endif #ifdef VEXPRESS_FDT_ADDR if (fdt_magic(VEXPRESS_FDT_ADDR) == FDT_MAGIC) { - *err = 0; - return (void *)VEXPRESS_FDT_ADDR; + *fdtp = (void *)VEXPRESS_FDT_ADDR; + return 0; } #endif if (is_valid_dtb(prior_stage_fdt_address[1])) { - *err = 0; - return (void *)prior_stage_fdt_address[1]; + *fdtp = (void *)prior_stage_fdt_address[1]; + return 0; } else if (is_valid_dtb(prior_stage_fdt_address[0])) { - *err = 0; - return (void *)prior_stage_fdt_address[0]; + *fdtp = (void *)prior_stage_fdt_address[0]; + return 0; } - if (fdt_magic(gd->fdt_blob) == FDT_MAGIC) { - *err = 0; - return (void *)gd->fdt_blob; - } + if (fdt_magic(*fdtp) == FDT_MAGIC) + return 0; - *err = -ENXIO; - return NULL; + return -ENXIO; } #endif diff --git a/board/broadcom/bcmstb/bcmstb.c b/board/broadcom/bcmstb/bcmstb.c index bc05aecc446..e655f610c84 100644 --- a/board/broadcom/bcmstb/bcmstb.c +++ b/board/broadcom/bcmstb/bcmstb.c @@ -130,9 +130,10 @@ int board_late_init(void) return 0; } -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; /* Stored the DTB address there during our init */ - return (void *)prior_stage_fdt_address; + *fdtp = (void *)prior_stage_fdt_address; + + return 0; } diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index e0e18b4dfea..31f5a775137 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -149,11 +149,12 @@ int dram_init_banksize(void) return 0; } -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; /* QEMU loads a generated DTB for us at the start of RAM. */ - return (void *)CFG_SYS_SDRAM_BASE; + *fdtp = (void *)CFG_SYS_SDRAM_BASE; + + return 0; } void enable_caches(void) diff --git a/board/emulation/qemu-ppce500/qemu-ppce500.c b/board/emulation/qemu-ppce500/qemu-ppce500.c index 58e5d5eb942..40d295dbf06 100644 --- a/board/emulation/qemu-ppce500/qemu-ppce500.c +++ b/board/emulation/qemu-ppce500/qemu-ppce500.c @@ -334,15 +334,11 @@ u32 cpu_mask(void) return (1 << cpu_numcores()) - 1; } -/** - * Return the virtual address of FDT that was passed by QEMU - * - * Return: virtual address of FDT received from QEMU in r3 register - */ -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - return get_fdt_virt(); + *fdtp = get_fdt_virt(); + + return 0; } /* See CFG_SYS_NS16550_CLK in arch/powerpc/include/asm/config.h */ diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index e5193e31e37..a90222ea6a4 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -64,9 +64,10 @@ int board_fit_config_name_match(const char *name) } #endif -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; /* Stored the DTB address there during our init */ - return (void *)(ulong)gd->arch.firmware_fdt_addr; + *fdtp = (void *)(ulong)gd->arch.firmware_fdt_addr; + + return 0; } diff --git a/board/highbank/highbank.c b/board/highbank/highbank.c index f3df83ed6c9..0ec88447384 100644 --- a/board/highbank/highbank.c +++ b/board/highbank/highbank.c @@ -97,15 +97,16 @@ int ft_board_setup(void *fdt, struct bd_info *bd) } #endif -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; /* * The ECME management processor loads the DTB from NOR flash * into DRAM (at 4KB), where it gets patched to contain the * detected memory size. */ - return (void *)0x1000; + *fdtp = (void *)0x1000; + + return 0; } static int is_highbank(void) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 9122f33d88d..c46fe4b2350 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -508,15 +508,14 @@ int board_init(void) /* * If the firmware passed a device tree use it for U-Boot. */ -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) { - *err = -ENXIO; - return NULL; - } + if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) + return -ENXIO; - return (void *)fw_dtb_pointer; + *fdtp = (void *)fw_dtb_pointer; + + return 0; } int copy_property(void *dst, void *src, char *path, char *property) diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c index 3c5dd50c369..c1c374610c3 100644 --- a/board/sifive/unleashed/unleashed.c +++ b/board/sifive/unleashed/unleashed.c @@ -114,15 +114,15 @@ int misc_init_r(void) #endif -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { - if (gd->arch.firmware_fdt_addr) - return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + if (gd->arch.firmware_fdt_addr) { + *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + + return 0; } - return (ulong *)_end; + return -EEXIST; } int board_init(void) diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c index c8696270ba2..23e03e145ee 100644 --- a/board/sifive/unmatched/unmatched.c +++ b/board/sifive/unmatched/unmatched.c @@ -10,15 +10,14 @@ #include <dm.h> #include <asm/sections.h> -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { - if (gd->arch.firmware_fdt_addr) - return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + if (gd->arch.firmware_fdt_addr) { + *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + return 0; } - return (ulong *)_end; + return -EEXIST; } int board_init(void) diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c index f6114602f88..3940d45b13f 100644 --- a/board/starfive/visionfive2/starfive_visionfive2.c +++ b/board/starfive/visionfive2/starfive_visionfive2.c @@ -115,15 +115,14 @@ int board_late_init(void) return 0; } -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { - if (gd->arch.firmware_fdt_addr) - return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + if (gd->arch.firmware_fdt_addr) { + *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; + return 0; } - return (ulong *)_end; + return -EEXIST; } int ft_board_setup(void *blob, struct bd_info *bd) diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c b/board/xen/xenguest_arm64/xenguest_arm64.c index 4c3b9c9e278..216a022aa15 100644 --- a/board/xen/xenguest_arm64/xenguest_arm64.c +++ b/board/xen/xenguest_arm64/xenguest_arm64.c @@ -44,14 +44,14 @@ int board_init(void) * x0 is the physical address of the device tree blob (dtb) in system RAM. * This is stored in rom_pointer during low level init. */ -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { - *err = 0; - if (fdt_magic(rom_pointer[0]) != FDT_MAGIC) { - *err = -ENXIO; - return NULL; - } - return (void *)rom_pointer[0]; + if (fdt_magic(rom_pointer[0]) != FDT_MAGIC) + return -ENXIO; + + *fdtp = (void *)rom_pointer[0]; + + return 0; } /* diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index a12dccd4c51..deea6c71103 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -358,17 +358,17 @@ __maybe_unused int xilinx_read_eeprom(void) } #if defined(CONFIG_OF_BOARD) -void *board_fdt_blob_setup(int *err) +int board_fdt_blob_setup(void **fdtp) { void *fdt_blob; - *err = 0; - if (IS_ENABLED(CONFIG_TARGET_XILINX_MBV)) { fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR; - if (fdt_magic(fdt_blob) == FDT_MAGIC) - return fdt_blob; + if (fdt_magic(fdt_blob) == FDT_MAGIC) { + *fdtp = fdt_blob; + return 0; + } } if (!IS_ENABLED(CONFIG_XPL_BUILD) && @@ -376,8 +376,10 @@ void *board_fdt_blob_setup(int *err) !IS_ENABLED(CONFIG_ZYNQMP_NO_DDR)) { fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR; - if (fdt_magic(fdt_blob) == FDT_MAGIC) - return fdt_blob; + if (fdt_magic(fdt_blob) == FDT_MAGIC) { + *fdtp = fdt_blob; + return 0; + } debug("DTB is not passed via %p\n", fdt_blob); } @@ -396,13 +398,15 @@ void *board_fdt_blob_setup(int *err) fdt_blob = (ulong *)_end; } - if (fdt_magic(fdt_blob) == FDT_MAGIC) - return fdt_blob; + if (fdt_magic(fdt_blob) == FDT_MAGIC) { + *fdtp = fdt_blob; + + return 0; + } debug("DTB is also not passed via %p\n", fdt_blob); - *err = -EINVAL; - return NULL; + return -EINVAL; } #endif |
