1 // SPDX-License-Identifier: GPL-2.0
3 * (C) Copyright 2012 Stephen Warren
5 * See file CREDITS for list of people who contributed to this
11 #include <dm/device.h>
12 #include <fdt_support.h>
15 #include <asm/armv8/mmu.h>
17 static struct mm_region bcm283x_mem_map[] = {
22 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
28 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
30 PTE_BLOCK_PXN | PTE_BLOCK_UXN
37 static struct mm_region bcm2711_mem_map[] = {
42 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
48 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
50 PTE_BLOCK_PXN | PTE_BLOCK_UXN
57 struct mm_region *mem_map = bcm283x_mem_map;
60 * I/O address space varies on different chip versions.
61 * We set the base address by inspecting the DTB.
63 static const struct udevice_id board_ids[] = {
64 { .compatible = "brcm,bcm2837", .data = (ulong)&bcm283x_mem_map},
65 { .compatible = "brcm,bcm2838", .data = (ulong)&bcm2711_mem_map},
66 { .compatible = "brcm,bcm2711", .data = (ulong)&bcm2711_mem_map},
70 static void _rpi_update_mem_map(struct mm_region *pd)
74 for (i = 0; i < 2; i++) {
75 mem_map[i].virt = pd[i].virt;
76 mem_map[i].phys = pd[i].phys;
77 mem_map[i].size = pd[i].size;
78 mem_map[i].attrs = pd[i].attrs;
82 static void rpi_update_mem_map(void)
86 const struct udevice_id *of_match = board_ids;
88 while (of_match->compatible) {
89 ret = fdt_node_check_compatible(gd->fdt_blob, 0,
90 of_match->compatible);
92 mm = (struct mm_region *)of_match->data;
93 _rpi_update_mem_map(mm);
101 static void rpi_update_mem_map(void) {}
104 unsigned long rpi_bcm283x_base = 0x3f000000;
106 int arch_cpu_init(void)
113 int mach_cpu_init(void)
118 rpi_update_mem_map();
120 /* Get IO base from device tree */
121 soc_offset = fdt_path_offset(gd->fdt_blob, "/soc");
125 ret = fdt_read_range((void *)gd->fdt_blob, soc_offset, 0, NULL,
130 rpi_bcm283x_base = io_base;
135 #ifdef CONFIG_ARMV7_LPAE
136 void enable_caches(void)