2 * Copyright (C) 2015 Freescale Semiconductor, Inc.
4 * Copyright (c) 2016, Wind River Systems.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 #ifndef PLATFORM_CONFIG_H
31 #define PLATFORM_CONFIG_H
33 #define STACK_ALIGNMENT 64
35 /* For i.MX 6UltraLite EVK board */
37 #if defined(PLATFORM_FLAVOR_mx6ulevk)
40 #error "Pager not supported for platform mx6ulevk"
43 #error "LPAE not supported for now"
46 #define GIC_BASE 0xA00000
47 #define GIC_SIZE 0x8000
48 #define GICC_OFFSET 0x2000
49 #define GICD_OFFSET 0x1000
50 #define UART0_BASE 0x2020000
51 #define UART1_BASE 0x21E8000
52 #define UART2_BASE 0x21EC000
54 #define AHB1_BASE 0x02000000
55 #define AHB1_SIZE 0x100000
56 #define AHB2_BASE 0x02100000
57 #define AHB2_SIZE 0x100000
58 #define AHB3_BASE 0x02200000
59 #define AHB3_SIZE 0x100000
61 #define AIPS_TZ1_BASE_ADDR 0x02000000
62 #define AIPS1_OFF_BASE_ADDR (AIPS_TZ1_BASE_ADDR + 0x80000)
64 #define DRAM0_BASE 0x80000000
65 #define DRAM0_SIZE 0x20000000
67 #define CFG_TEE_CORE_NB_CORE 1
69 #define DDR_PHYS_START DRAM0_BASE
70 #define DDR_SIZE DRAM0_SIZE
72 #define CFG_DDR_START DDR_PHYS_START
73 #define CFG_DDR_SIZE DDR_SIZE
75 /* Full GlobalPlatform test suite requires CFG_SHMEM_SIZE to be at least 2MB */
76 #define CFG_SHMEM_START (TZDRAM_BASE - 0x100000)
77 #define CFG_SHMEM_SIZE 0x100000
79 /* Location of trusted dram on imx */
80 #define TZDRAM_BASE (0x9c100000)
81 #define TZDRAM_SIZE (0x03000000)
83 #define CFG_TEE_RAM_VA_SIZE (1024 * 1024)
85 #ifndef CFG_TEE_LOAD_ADDR
86 #define CFG_TEE_LOAD_ADDR CFG_TEE_RAM_START
90 * Everything is in TZDRAM.
91 * +------------------+
93 * + TZDRAM +---------+
95 * +--------+---------+
97 #define CFG_TEE_RAM_PH_SIZE CFG_TEE_RAM_VA_SIZE
98 #define CFG_TEE_RAM_START TZDRAM_BASE
99 #define CFG_TA_RAM_START ROUNDUP((TZDRAM_BASE + CFG_TEE_RAM_VA_SIZE), \
100 CORE_MMU_DEVICE_SIZE)
101 #define CFG_TA_RAM_SIZE ROUNDDOWN((TZDRAM_SIZE - CFG_TEE_RAM_VA_SIZE), \
102 CORE_MMU_DEVICE_SIZE)
104 #define CONSOLE_UART_BASE (UART0_BASE)
106 /* Central Security Unit register values */
107 #define CSU_BASE 0x021C0000
108 #define CSU_CSL_START 0x0
109 #define CSU_CSL_END 0xA0
110 #define CSU_ACCESS_ALL 0x00FF00FF
111 #define CSU_SETTING_LOCK 0x01000100
113 /* For i.MX6 Quad SABRE Lite and Smart Device board */
115 #elif defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
116 defined(PLATFORM_FLAVOR_mx6qsabresd)
118 #define SCU_BASE 0x00A00000
119 #define PL310_BASE 0x00A02000
120 #define SRC_BASE 0x020D8000
121 #define SRC_SCR 0x000
122 #define SRC_GPR1 0x020
123 #define SRC_SCR_CPU_ENABLE_ALL SHIFT_U32(0x7, 22)
124 #define SRC_SCR_CORE1_RST_OFFSET 14
125 #define SRC_SCR_CORE1_ENABLE_OFFSET 22
126 #define GIC_BASE 0x00A00000
127 #define GICC_OFFSET 0x100
128 #define GICD_OFFSET 0x1000
129 #define GIC_CPU_BASE (GIC_BASE + GICC_OFFSET)
130 #define GIC_DIST_BASE (GIC_BASE + GICD_OFFSET)
131 #define UART1_BASE 0x02020000
132 #define UART2_BASE 0x021E8000
134 /* Central Security Unit register values */
135 #define CSU_BASE 0x021C0000
136 #define CSU_CSL_START 0x0
137 #define CSU_CSL_END 0xA0
138 #define CSU_CSL5 0x14
139 #define CSU_CSL16 0x40
140 #define CSU_ACCESS_ALL 0x00FF00FF
141 #define CSU_SETTING_LOCK 0x01000100
143 #if defined(PLATFORM_FLAVOR_mx6qsabrelite)
144 #define CONSOLE_UART_BASE UART2_BASE
146 #if defined(PLATFORM_FLAVOR_mx6qsabresd)
147 #define CONSOLE_UART_BASE UART1_BASE
149 #define DRAM0_BASE 0x10000000
150 #define DRAM0_SIZE 0x40000000
152 #define CFG_TEE_RAM_VA_SIZE (1024 * 1024)
154 #define CFG_TEE_CORE_NB_CORE 4
156 #define DDR_PHYS_START DRAM0_BASE
157 #define DDR_SIZE DRAM0_SIZE
159 #define CFG_DDR_START DDR_PHYS_START
160 #define CFG_DDR_SIZE DDR_SIZE
163 * PL310 TAG RAM Control Register
165 * bit[10:8]:1 - 2 cycle of write accesses latency
166 * bit[6:4]:1 - 2 cycle of read accesses latency
167 * bit[2:0]:1 - 2 cycle of setup latency
169 #ifndef PL310_TAG_RAM_CTRL_INIT
170 #define PL310_TAG_RAM_CTRL_INIT 0x00000111
174 * PL310 DATA RAM Control Register
176 * bit[10:8]:2 - 3 cycle of write accesses latency
177 * bit[6:4]:2 - 3 cycle of read accesses latency
178 * bit[2:0]:2 - 3 cycle of setup latency
180 #ifndef PL310_DATA_RAM_CTRL_INIT
181 #define PL310_DATA_RAM_CTRL_INIT 0x00000222
185 * PL310 Auxiliary Control Register
187 * I/Dcache prefetch enabled (bit29:28=2b11)
188 * NS can access interrupts (bit27=1)
189 * NS can lockown cache lines (bit26=1)
190 * Pseudo-random replacement policy (bit25=0)
191 * Force write allocated (default)
192 * Shared attribute internally ignored (bit22=1, bit13=0)
193 * Parity disabled (bit21=0)
194 * Event monitor disabled (bit20=0)
195 * Platform fmavor specific way config:
196 * - 64kb way size (bit19:17=3b011)
197 * - 16-way associciativity (bit16=1)
198 * Store buffer device limitation enabled (bit11=1)
199 * Cacheable accesses have high prio (bit10=0)
200 * Full Line Zero (FLZ) disabled (bit0=0)
202 #ifndef PL310_AUX_CTRL_INIT
203 #define PL310_AUX_CTRL_INIT 0x3C470800
207 * PL310 Prefetch Control Register
209 * Double linefill disabled (bit30=0)
210 * I/D prefetch enabled (bit29:28=2b11)
211 * Prefetch drop enabled (bit24=1)
212 * Incr double linefill disable (bit23=0)
213 * Prefetch offset = 7 (bit4:0)
215 #define PL310_PREFETCH_CTRL_INIT 0x31000007
218 * PL310 Power Register
220 * Dynamic clock gating enabled
221 * Standby mode enabled
223 #define PL310_POWER_CTRL_INIT 0x00000003
226 * SCU Invalidate Register
228 * Invalidate all registers
230 #define SCU_INV_CTRL_INIT 0xFFFFFFFF
233 * SCU Access Register
234 * - both secure CPU access SCU
236 #define SCU_SAC_CTRL_INIT 0x0000000F
239 * SCU NonSecure Access Register
240 * - both nonsec cpu access SCU, private and global timer
242 #define SCU_NSAC_CTRL_INIT 0x00000FFF
244 /* define the memory areas */
246 #ifdef CFG_WITH_PAGER
251 * +---------------------------------------+ <- CFG_CORE_TZSRAM_EMUL_START
252 * | TEE private highly | TEE_RAM | ^
253 * | secure memory | | | CFG_CORE_TZSRAM_EMUL_SIZE
254 * +---------------------------------------+ v
256 * +---------------------------------------+ <- CFG_DDR_TEETZ_RESERVED_START
257 * | TEE private secure | TA_RAM | ^
258 * | external memory | | |
259 * +---------------------------------------+ | CFG_DDR_TEETZ_RESERVED_SIZE
260 * | Non secure | SHM | |
261 * | shared memory | | |
262 * +---------------------------------------+ v
264 * TEE_RAM : default 256kByte
265 * TA_RAM : all what is left in DDR TEE reserved area
266 * PUB_RAM : default 2MByte
269 /* emulated SRAM, at start of secure DDR */
271 #define CFG_CORE_TZSRAM_EMUL_START 0x4E000000
273 #define TZSRAM_BASE CFG_CORE_TZSRAM_EMUL_START
274 #define TZSRAM_SIZE CFG_CORE_TZSRAM_EMUL_SIZE
276 /* Location of trusted dram */
278 #define CFG_DDR_TEETZ_RESERVED_START 0x4E100000
279 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x01F00000
281 #define CFG_PUB_RAM_SIZE (1 * 1024 * 1024)
282 #define CFG_TEE_RAM_PH_SIZE TZSRAM_SIZE
284 #define TZDRAM_BASE (CFG_DDR_TEETZ_RESERVED_START)
285 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
288 #define CFG_TA_RAM_START TZDRAM_BASE
289 #define CFG_TA_RAM_SIZE TZDRAM_SIZE
291 #define CFG_SHMEM_START (CFG_DDR_TEETZ_RESERVED_START + \
293 #define CFG_SHMEM_SIZE CFG_PUB_RAM_SIZE
295 #define CFG_TEE_RAM_START TZSRAM_BASE
297 #ifndef CFG_TEE_LOAD_ADDR
298 #define CFG_TEE_LOAD_ADDR TZSRAM_BASE
301 #else /* CFG_WITH_PAGER */
306 * +---------------------------------------+ <- CFG_DDR_TEETZ_RESERVED_START
307 * | TEE private secure | TEE_RAM | ^
308 * | external memory +------------------+ |
310 * +---------------------------------------+ | CFG_DDR_TEETZ_RESERVED_SIZE
311 * | Non secure | SHM | |
312 * | shared memory | | |
313 * +---------------------------------------+ v
315 * TEE_RAM : default 1MByte
316 * PUB_RAM : default 2MByte
317 * TA_RAM : all what is left
320 #define CFG_DDR_TEETZ_RESERVED_START 0x4E000000
321 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x02000000
323 #define CFG_PUB_RAM_SIZE (1 * 1024 * 1024)
324 #define CFG_TEE_RAM_PH_SIZE (1 * 1024 * 1024)
326 #define TZDRAM_BASE (CFG_DDR_TEETZ_RESERVED_START)
327 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
330 #define CFG_TA_RAM_START (CFG_DDR_TEETZ_RESERVED_START + \
332 #define CFG_TA_RAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
333 CFG_TEE_RAM_PH_SIZE - \
336 #define CFG_SHMEM_START (CFG_DDR_TEETZ_RESERVED_START + \
338 #define CFG_SHMEM_SIZE CFG_PUB_RAM_SIZE
340 #define CFG_TEE_RAM_START TZDRAM_BASE
342 #ifndef CFG_TEE_LOAD_ADDR
343 #define CFG_TEE_LOAD_ADDR TZDRAM_BASE
346 #endif /* CFG_WITH_PAGER */
349 #error "Unknown platform flavor"
350 #endif /* defined(PLATFORM_FLAVOR_mx6ulevk) */
354 * PL310 TAG RAM Control Register
356 * bit[10:8]:1 - 2 cycle of write accesses latency
357 * bit[6:4]:1 - 2 cycle of read accesses latency
358 * bit[2:0]:1 - 2 cycle of setup latency
360 #define PL310_TAG_RAM_CTRL_INIT 0x00000111
363 * DATA RAM Control Register
365 * bit[10:8]:2 - 3 cycle of write accesses latency
366 * bit[6:4]:2 - 3 cycle of read accesses latency
367 * bit[2:0]:2 - 3 cycle of setup latency
369 #define PL310_DATA_RAM_CTRL_INIT 0x00000222
372 * Auxiliary Control Register
374 * I/Dcache prefetch enabled (bit29:28=2b11)
375 * NS can access interrupts (bit27=1)
376 * NS can lockown cache lines (bit26=1)
377 * Pseudo-random replacement policy (bit25=0)
378 * Force write allocated (default)
379 * Shared attribute internally ignored (bit22=1, bit13=0)
380 * Parity disabled (bit21=0)
381 * Event monitor disabled (bit20=0)
382 * 64kB ways, 16-way associativity (bit19:17=3b011 bit16=1)
383 * Store buffer device limitation enabled (bit11=1)
384 * Cacheable accesses have high prio (bit10=0)
385 * Full Line Zero (FLZ) disabled (bit0=0)
387 #define PL310_AUX_CTRL_INIT 0x3C470800
390 * Prefetch Control Register
392 * Double linefill disabled (bit30=0)
393 * I/D prefetch enabled (bit29:28=2b11)
394 * Prefetch drop enabled (bit24=1)
395 * Incr double linefill disable (bit23=0)
396 * Prefetch offset = 7 (bit4:0)
398 #define PL310_PREFETCH_CTRL_INIT 0x31000007
401 * Power Register = 0x00000003
403 * Dynamic clock gating enabled
404 * Standby mode enabled
406 #define PL310_POWER_CTRL_INIT 0x00000003
410 #endif /*PLATFORM_CONFIG_H*/