1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2021 Mark Kettenis <kettenis@openbsd.org>
8 #include <efi_loader.h>
10 #include <asm/armv8/mmu.h>
11 #include <asm/global_data.h>
13 #include <asm/system.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 static struct mm_region apple_mem_map[] = {
23 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
25 PTE_BLOCK_PXN | PTE_BLOCK_UXN
31 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
33 PTE_BLOCK_PXN | PTE_BLOCK_UXN
39 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
41 PTE_BLOCK_PXN | PTE_BLOCK_UXN
47 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
48 PTE_BLOCK_INNER_SHARE |
49 PTE_BLOCK_PXN | PTE_BLOCK_UXN
55 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
56 PTE_BLOCK_INNER_SHARE |
57 PTE_BLOCK_PXN | PTE_BLOCK_UXN
63 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
66 /* Empty entry for framebuffer */
74 struct mm_region *mem_map = apple_mem_map;
88 ret = fdtdec_setup_mem_size_base();
92 /* Update RAM mapping */
93 index = ARRAY_SIZE(apple_mem_map) - 3;
94 apple_mem_map[index].virt = gd->ram_base;
95 apple_mem_map[index].phys = gd->ram_base;
96 apple_mem_map[index].size = gd->ram_size;
98 node = ofnode_path("/chosen/framebuffer");
99 if (!ofnode_valid(node))
102 base = ofnode_get_addr_size(node, "reg", &size);
103 if (base == FDT_ADDR_T_NONE)
106 /* Add framebuffer mapping */
107 index = ARRAY_SIZE(apple_mem_map) - 2;
108 apple_mem_map[index].virt = base;
109 apple_mem_map[index].phys = base;
110 apple_mem_map[index].size = size;
111 apple_mem_map[index].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
112 PTE_BLOCK_INNER_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN;
117 int dram_init_banksize(void)
119 return fdtdec_setup_memory_banksize();
122 extern long fw_dtb_pointer;
124 void *board_fdt_blob_setup(int *err)
126 /* Return DTB pointer passed by m1n1 */
128 return (void *)fw_dtb_pointer;
131 ulong board_get_usable_ram_top(ulong total_size)
134 * Top part of RAM is used by firmware for things like the
135 * framebuffer. This gives us plenty of room to play with.