1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com>
7 #include <asm/arch/boot.h>
8 #include <linux/libfdt.h>
10 #include <asm/arch/mem.h>
11 #include <asm/arch/sm.h>
12 #include <asm/armv8/mmu.h>
13 #include <asm/unaligned.h>
14 #include <efi_loader.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 __weak int board_init(void)
29 offset = fdt_path_offset(gd->fdt_blob, "/memory");
33 val = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
34 if (len < sizeof(*val) * 2)
37 /* Use unaligned access since cache is still disabled */
38 gd->ram_size = get_unaligned_be64(&val[1]);
43 __weak int meson_ft_board_setup(void *blob, bd_t *bd)
48 int ft_board_setup(void *blob, bd_t *bd)
50 meson_init_reserved_memory(blob);
52 return meson_ft_board_setup(blob, bd);
55 void meson_board_add_reserved_memory(void *fdt, u64 start, u64 size)
59 ret = fdt_add_mem_rsv(fdt, start, size);
61 printf("Could not reserve zone @ 0x%llx\n", start);
63 if (IS_ENABLED(CONFIG_EFI_LOADER)) {
64 efi_add_memory_map(start,
65 ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
66 EFI_RESERVED_MEMORY_TYPE, false);
70 static void meson_set_boot_source(void)
74 switch (meson_get_boot_device()) {
75 case BOOT_DEVICE_EMMC:
79 case BOOT_DEVICE_NAND:
99 env_set("boot_source", source);
102 __weak int meson_board_late_init(void)
107 int board_late_init(void)
109 meson_set_boot_source();
111 return meson_board_late_init();
114 void reset_cpu(ulong addr)