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) || \
117 defined(PLATFORM_FLAVOR_mx6dlsabresd)
119 #define SCU_BASE 0x00A00000
120 #define PL310_BASE 0x00A02000
121 #define SRC_BASE 0x020D8000
122 #define SRC_SCR 0x000
123 #define SRC_GPR1 0x020
124 #define SRC_SCR_CPU_ENABLE_ALL SHIFT_U32(0x7, 22)
125 #define SRC_SCR_CORE1_RST_OFFSET 14
126 #define SRC_SCR_CORE1_ENABLE_OFFSET 22
127 #define GIC_BASE 0x00A00000
128 #define GICC_OFFSET 0x100
129 #define GICD_OFFSET 0x1000
130 #define GIC_CPU_BASE (GIC_BASE + GICC_OFFSET)
131 #define GIC_DIST_BASE (GIC_BASE + GICD_OFFSET)
133 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
134 defined(PLATFORM_FLAVOR_mx6qsabresd)
135 #define UART1_BASE 0x02020000
136 #define UART2_BASE 0x021E8000
138 #define UART1_BASE 0x02020000
139 #define UART3_BASE 0x021EC000
140 #define UART5_BASE 0x021F4000
143 /* Central Security Unit register values */
144 #define CSU_BASE 0x021C0000
145 #define CSU_CSL_START 0x0
146 #define CSU_CSL_END 0xA0
147 #define CSU_CSL5 0x14
148 #define CSU_CSL16 0x40
149 #define CSU_ACCESS_ALL 0x00FF00FF
150 #define CSU_SETTING_LOCK 0x01000100
152 #if defined(PLATFORM_FLAVOR_mx6qsabrelite)
153 #define CONSOLE_UART_BASE UART2_BASE
155 #if defined(PLATFORM_FLAVOR_mx6qsabresd)
156 #define CONSOLE_UART_BASE UART1_BASE
158 #if defined(PLATFORM_FLAVOR_mx6dlsabresd)
159 #define CONSOLE_UART_BASE UART1_BASE
161 #define DRAM0_BASE 0x10000000
162 #define DRAM0_SIZE 0x40000000
164 #define CFG_TEE_RAM_VA_SIZE (1024 * 1024)
166 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
167 defined(PLATFORM_FLAVOR_mx6qsabresd)
168 #define CFG_TEE_CORE_NB_CORE 4
170 #define CFG_TEE_CORE_NB_CORE 2
173 #define DDR_PHYS_START DRAM0_BASE
174 #define DDR_SIZE DRAM0_SIZE
176 #define CFG_DDR_START DDR_PHYS_START
177 #define CFG_DDR_SIZE DDR_SIZE
180 * PL310 TAG RAM Control Register
182 * bit[10:8]:1 - 2 cycle of write accesses latency
183 * bit[6:4]:1 - 2 cycle of read accesses latency
184 * bit[2:0]:1 - 2 cycle of setup latency
186 #ifndef PL310_TAG_RAM_CTRL_INIT
187 #define PL310_TAG_RAM_CTRL_INIT 0x00000111
191 * PL310 DATA RAM Control Register
193 * bit[10:8]:2 - 3 cycle of write accesses latency
194 * bit[6:4]:2 - 3 cycle of read accesses latency
195 * bit[2:0]:2 - 3 cycle of setup latency
197 #ifndef PL310_DATA_RAM_CTRL_INIT
198 #define PL310_DATA_RAM_CTRL_INIT 0x00000222
202 * PL310 Auxiliary Control Register
204 * I/Dcache prefetch enabled (bit29:28=2b11)
205 * NS can access interrupts (bit27=1)
206 * NS can lockown cache lines (bit26=1)
207 * Pseudo-random replacement policy (bit25=0)
208 * Force write allocated (default)
209 * Shared attribute internally ignored (bit22=1, bit13=0)
210 * Parity disabled (bit21=0)
211 * Event monitor disabled (bit20=0)
212 * Platform fmavor specific way config:
213 * - 64kb way size (bit19:17=3b011)
214 * - 16-way associciativity (bit16=1)
215 * Store buffer device limitation enabled (bit11=1)
216 * Cacheable accesses have high prio (bit10=0)
217 * Full Line Zero (FLZ) disabled (bit0=0)
219 #ifndef PL310_AUX_CTRL_INIT
220 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
221 defined(PLATFORM_FLAVOR_mx6qsabresd)
222 #define PL310_AUX_CTRL_INIT 0x3C470800
224 #define PL310_AUX_CTRL_INIT 0x3C440800
229 * PL310 Prefetch Control Register
231 * Double linefill disabled (bit30=0)
232 * I/D prefetch enabled (bit29:28=2b11)
233 * Prefetch drop enabled (bit24=1)
234 * Incr double linefill disable (bit23=0)
235 * Prefetch offset = 7 (bit4:0)
237 #define PL310_PREFETCH_CTRL_INIT 0x31000007
240 * PL310 Power Register
242 * Dynamic clock gating enabled
243 * Standby mode enabled
245 #define PL310_POWER_CTRL_INIT 0x00000003
248 * SCU Invalidate Register
250 * Invalidate all registers
252 #define SCU_INV_CTRL_INIT 0xFFFFFFFF
255 * SCU Access Register
256 * - both secure CPU access SCU
258 #define SCU_SAC_CTRL_INIT 0x0000000F
261 * SCU NonSecure Access Register
262 * - both nonsec cpu access SCU, private and global timer
264 #define SCU_NSAC_CTRL_INIT 0x00000FFF
266 /* define the memory areas */
268 #ifdef CFG_WITH_PAGER
273 * +---------------------------------------+ <- CFG_CORE_TZSRAM_EMUL_START
274 * | TEE private highly | TEE_RAM | ^
275 * | secure memory | | | CFG_CORE_TZSRAM_EMUL_SIZE
276 * +---------------------------------------+ v
278 * +---------------------------------------+ <- CFG_DDR_TEETZ_RESERVED_START
279 * | TEE private secure | TA_RAM | ^
280 * | external memory | | |
281 * +---------------------------------------+ | CFG_DDR_TEETZ_RESERVED_SIZE
282 * | Non secure | SHM | |
283 * | shared memory | | |
284 * +---------------------------------------+ v
286 * TEE_RAM : default 256kByte
287 * TA_RAM : all what is left in DDR TEE reserved area
288 * PUB_RAM : default 2MByte
291 /* emulated SRAM, at start of secure DDR */
293 #define CFG_CORE_TZSRAM_EMUL_START 0x4E000000
295 #define TZSRAM_BASE CFG_CORE_TZSRAM_EMUL_START
296 #define TZSRAM_SIZE CFG_CORE_TZSRAM_EMUL_SIZE
298 /* Location of trusted dram */
300 #define CFG_DDR_TEETZ_RESERVED_START 0x4E100000
301 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x01F00000
303 #define CFG_PUB_RAM_SIZE (1 * 1024 * 1024)
304 #define CFG_TEE_RAM_PH_SIZE TZSRAM_SIZE
306 #define TZDRAM_BASE (CFG_DDR_TEETZ_RESERVED_START)
307 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
310 #define CFG_TA_RAM_START TZDRAM_BASE
311 #define CFG_TA_RAM_SIZE TZDRAM_SIZE
313 #define CFG_SHMEM_START (CFG_DDR_TEETZ_RESERVED_START + \
315 #define CFG_SHMEM_SIZE CFG_PUB_RAM_SIZE
317 #define CFG_TEE_RAM_START TZSRAM_BASE
319 #ifndef CFG_TEE_LOAD_ADDR
320 #define CFG_TEE_LOAD_ADDR TZSRAM_BASE
323 #else /* CFG_WITH_PAGER */
328 * +---------------------------------------+ <- CFG_DDR_TEETZ_RESERVED_START
329 * | TEE private secure | TEE_RAM | ^
330 * | external memory +------------------+ |
332 * +---------------------------------------+ | CFG_DDR_TEETZ_RESERVED_SIZE
333 * | Non secure | SHM | |
334 * | shared memory | | |
335 * +---------------------------------------+ v
337 * TEE_RAM : default 1MByte
338 * PUB_RAM : default 2MByte
339 * TA_RAM : all what is left
342 #define CFG_DDR_TEETZ_RESERVED_START 0x4E000000
343 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x02000000
345 #define CFG_PUB_RAM_SIZE (1 * 1024 * 1024)
346 #define CFG_TEE_RAM_PH_SIZE (1 * 1024 * 1024)
348 #define TZDRAM_BASE (CFG_DDR_TEETZ_RESERVED_START)
349 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
352 #define CFG_TA_RAM_START (CFG_DDR_TEETZ_RESERVED_START + \
354 #define CFG_TA_RAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - \
355 CFG_TEE_RAM_PH_SIZE - \
358 #define CFG_SHMEM_START (CFG_DDR_TEETZ_RESERVED_START + \
360 #define CFG_SHMEM_SIZE CFG_PUB_RAM_SIZE
362 #define CFG_TEE_RAM_START TZDRAM_BASE
364 #ifndef CFG_TEE_LOAD_ADDR
365 #define CFG_TEE_LOAD_ADDR TZDRAM_BASE
368 #endif /* CFG_WITH_PAGER */
371 #error "Unknown platform flavor"
372 #endif /* defined(PLATFORM_FLAVOR_mx6ulevk) */
376 * PL310 TAG RAM Control Register
378 * bit[10:8]:1 - 2 cycle of write accesses latency
379 * bit[6:4]:1 - 2 cycle of read accesses latency
380 * bit[2:0]:1 - 2 cycle of setup latency
382 #define PL310_TAG_RAM_CTRL_INIT 0x00000111
385 * DATA RAM Control Register
387 * bit[10:8]:2 - 3 cycle of write accesses latency
388 * bit[6:4]:2 - 3 cycle of read accesses latency
389 * bit[2:0]:2 - 3 cycle of setup latency
391 #define PL310_DATA_RAM_CTRL_INIT 0x00000222
394 * Auxiliary Control Register
396 * I/Dcache prefetch enabled (bit29:28=2b11)
397 * NS can access interrupts (bit27=1)
398 * NS can lockown cache lines (bit26=1)
399 * Pseudo-random replacement policy (bit25=0)
400 * Force write allocated (default)
401 * Shared attribute internally ignored (bit22=1, bit13=0)
402 * Parity disabled (bit21=0)
403 * Event monitor disabled (bit20=0)
404 * 64kB ways, 16-way associativity (bit19:17=3b011 bit16=1)
405 * Store buffer device limitation enabled (bit11=1)
406 * Cacheable accesses have high prio (bit10=0)
407 * Full Line Zero (FLZ) disabled (bit0=0)
409 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
410 defined(PLATFORM_FLAVOR_mx6qsabresd)
411 #define PL310_AUX_CTRL_INIT 0x3C470800
413 #define PL310_AUX_CTRL_INIT 0x3C440800
417 * Prefetch Control Register
419 * Double linefill disabled (bit30=0)
420 * I/D prefetch enabled (bit29:28=2b11)
421 * Prefetch drop enabled (bit24=1)
422 * Incr double linefill disable (bit23=0)
423 * Prefetch offset = 7 (bit4:0)
425 #define PL310_PREFETCH_CTRL_INIT 0x31000007
428 * Power Register = 0x00000003
430 * Dynamic clock gating enabled
431 * Standby mode enabled
433 #define PL310_POWER_CTRL_INIT 0x00000003
437 #endif /*PLATFORM_CONFIG_H*/