1 // SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/boot.h>
11 #include <asm/arch/eth.h>
12 #include <asm/arch/gx.h>
13 #include <asm/arch/mem.h>
14 #include <asm/arch/meson-vpu.h>
15 #include <asm/global_data.h>
17 #include <asm/armv8/mmu.h>
18 #include <linux/printk.h>
19 #include <linux/sizes.h>
21 DECLARE_GLOBAL_DATA_PTR;
23 int meson_get_boot_device(void)
25 return readl(GX_AO_SEC_GP_CFG0) & GX_AO_BOOT_DEVICE;
28 /* Configure the reserved memory zones exported by the secure registers
29 * into EFI and DTB reserved memory entries.
31 void meson_init_reserved_memory(void *fdt)
33 u64 bl31_size, bl31_start;
34 u64 bl32_size, bl32_start;
38 * Get ARM Trusted Firmware reserved memory zones in :
39 * - AO_SEC_GP_CFG3: bl32 & bl31 size in KiB, can be 0
40 * - AO_SEC_GP_CFG5: bl31 physical start address, can be NULL
41 * - AO_SEC_GP_CFG4: bl32 physical start address, can be NULL
43 reg = readl(GX_AO_SEC_GP_CFG3);
45 bl31_size = ((reg & GX_AO_BL31_RSVMEM_SIZE_MASK)
46 >> GX_AO_BL31_RSVMEM_SIZE_SHIFT) * SZ_1K;
47 bl32_size = (reg & GX_AO_BL32_RSVMEM_SIZE_MASK) * SZ_1K;
49 bl31_start = readl(GX_AO_SEC_GP_CFG5);
50 bl32_start = readl(GX_AO_SEC_GP_CFG4);
53 * Early Meson GX Firmware revisions did not provide the reserved
54 * memory zones in the registers, keep fixed memory zone handling.
56 if (IS_ENABLED(CONFIG_MESON_GX) &&
57 !reg && !bl31_start && !bl32_start) {
58 bl31_start = 0x10000000;
62 /* Add first 16MiB reserved zone */
63 meson_board_add_reserved_memory(fdt, 0, GX_FIRMWARE_MEM_SIZE);
65 /* Add BL31 reserved zone */
66 if (bl31_start && bl31_size)
67 meson_board_add_reserved_memory(fdt, bl31_start, bl31_size);
69 /* Add BL32 reserved zone */
70 if (bl32_start && bl32_size)
71 meson_board_add_reserved_memory(fdt, bl32_start, bl32_size);
73 #if defined(CONFIG_VIDEO_MESON)
74 meson_vpu_rsv_fb(fdt);
78 phys_size_t get_effective_memsize(void)
80 /* Size is reported in MiB, convert it in bytes */
81 return ((readl(GX_AO_SEC_GP_CFG0) & GX_AO_MEM_SIZE_MASK)
82 >> GX_AO_MEM_SIZE_SHIFT) * SZ_1M;
85 static struct mm_region gx_mem_map[] = {
90 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
96 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
98 PTE_BLOCK_PXN | PTE_BLOCK_UXN
100 /* List terminator */
105 struct mm_region *mem_map = gx_mem_map;