blob: 1a9eb72bb9783fd720f77efea9187d5cdb117270 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasuta523af62017-11-25 23:24:01 +01002/*
3 * Renesas RCar Gen3 memory map tables
4 *
5 * Copyright (C) 2017 Marek Vasut <marek.vasut@gmail.com>
Marek Vasuta523af62017-11-25 23:24:01 +01006 */
7
8#include <common.h>
9#include <asm/armv8/mmu.h>
10
Marek Vasute5cb6bd2018-10-31 15:06:50 +010011#define GEN3_NR_REGIONS 16
12
13static struct mm_region gen3_mem_map[GEN3_NR_REGIONS] = {
Marek Vasuta523af62017-11-25 23:24:01 +010014 {
15 .virt = 0x0UL,
16 .phys = 0x0UL,
Marek Vasut7beccc52018-02-15 13:19:33 +010017 .size = 0x40000000UL,
18 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
19 PTE_BLOCK_NON_SHARE |
20 PTE_BLOCK_PXN | PTE_BLOCK_UXN
21 }, {
22 .virt = 0x40000000UL,
23 .phys = 0x40000000UL,
Hiroyuki Yokoyama23b9b362018-11-22 11:50:44 +090024 .size = 0x03F00000UL,
25 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
26 PTE_BLOCK_INNER_SHARE
27 }, {
28 .virt = 0x47E00000UL,
29 .phys = 0x47E00000UL,
30 .size = 0x78200000UL,
Marek Vasuta523af62017-11-25 23:24:01 +010031 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
32 PTE_BLOCK_INNER_SHARE
33 }, {
Marek Vasut7beccc52018-02-15 13:19:33 +010034 .virt = 0xc0000000UL,
35 .phys = 0xc0000000UL,
36 .size = 0x40000000UL,
Marek Vasuta523af62017-11-25 23:24:01 +010037 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
38 PTE_BLOCK_NON_SHARE |
39 PTE_BLOCK_PXN | PTE_BLOCK_UXN
40 }, {
Marek Vasutc1ec3472018-10-02 21:42:49 +020041 .virt = 0x100000000UL,
42 .phys = 0x100000000UL,
43 .size = 0xf00000000UL,
44 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
45 PTE_BLOCK_INNER_SHARE
46 }, {
Marek Vasuta523af62017-11-25 23:24:01 +010047 /* List terminator */
48 0,
49 }
50};
51
Marek Vasut7beccc52018-02-15 13:19:33 +010052struct mm_region *mem_map = gen3_mem_map;
Marek Vasute5cb6bd2018-10-31 15:06:50 +010053
54DECLARE_GLOBAL_DATA_PTR;
55
56void enable_caches(void)
57{
58 u64 start, size;
59 int bank, i = 0;
60
61 /* Create map for RPC access */
62 gen3_mem_map[i].virt = 0x0ULL;
63 gen3_mem_map[i].phys = 0x0ULL;
64 gen3_mem_map[i].size = 0x40000000ULL;
65 gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
66 PTE_BLOCK_NON_SHARE |
67 PTE_BLOCK_PXN | PTE_BLOCK_UXN;
68 i++;
69
70 /* Generate entires for DRAM in 32bit address space */
71 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
72 start = gd->bd->bi_dram[bank].start;
73 size = gd->bd->bi_dram[bank].size;
74
75 /* Skip empty DRAM banks */
76 if (!size)
77 continue;
78
79 /* Skip DRAM above 4 GiB */
80 if (start >> 32ULL)
81 continue;
82
83 /* Mark memory reserved by ATF as cacheable too. */
84 if (start == 0x48000000) {
Takeshi Kihara10854bc2018-12-04 12:51:01 +090085 /* Unmark protection area (0x43F00000 to 0x47DFFFFF) */
86 gen3_mem_map[i].virt = 0x40000000ULL;
87 gen3_mem_map[i].phys = 0x40000000ULL;
88 gen3_mem_map[i].size = 0x03F00000ULL;
89 gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
90 PTE_BLOCK_INNER_SHARE;
91 i++;
92
93 start = 0x47E00000ULL;
94 size += 0x00200000ULL;
Marek Vasute5cb6bd2018-10-31 15:06:50 +010095 }
96
97 gen3_mem_map[i].virt = start;
98 gen3_mem_map[i].phys = start;
99 gen3_mem_map[i].size = size;
100 gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
101 PTE_BLOCK_INNER_SHARE;
102 i++;
103 }
104
105 /* Create map for register access */
106 gen3_mem_map[i].virt = 0xc0000000ULL;
107 gen3_mem_map[i].phys = 0xc0000000ULL;
108 gen3_mem_map[i].size = 0x40000000ULL;
109 gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
110 PTE_BLOCK_NON_SHARE |
111 PTE_BLOCK_PXN | PTE_BLOCK_UXN;
112 i++;
113
114 /* Generate entires for DRAM in 64bit address space */
115 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
116 start = gd->bd->bi_dram[bank].start;
117 size = gd->bd->bi_dram[bank].size;
118
119 /* Skip empty DRAM banks */
120 if (!size)
121 continue;
122
123 /* Skip DRAM below 4 GiB */
124 if (!(start >> 32ULL))
125 continue;
126
127 gen3_mem_map[i].virt = start;
128 gen3_mem_map[i].phys = start;
129 gen3_mem_map[i].size = size;
130 gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
131 PTE_BLOCK_INNER_SHARE;
132 i++;
133 }
134
135 /* Zero out the remaining regions. */
136 for (; i < GEN3_NR_REGIONS; i++) {
137 gen3_mem_map[i].virt = 0;
138 gen3_mem_map[i].phys = 0;
139 gen3_mem_map[i].size = 0;
140 gen3_mem_map[i].attrs = 0;
141 }
142
Takeshi Kihara5055a4e2018-12-04 11:53:24 +0900143 if (!icache_status())
144 icache_enable();
145
Marek Vasute5cb6bd2018-10-31 15:06:50 +0100146 dcache_enable();
147}