Update from upstream to 2.4.0 version
[platform/core/security/tef-optee_os.git] / core / arch / arm / plat-imx / platform_config.h
1 /*
2  * Copyright (C) 2015 Freescale Semiconductor, Inc.
3  * All rights reserved.
4  * Copyright (c) 2016, Wind River Systems.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
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.
16  *
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.
28  */
29
30 #ifndef PLATFORM_CONFIG_H
31 #define PLATFORM_CONFIG_H
32
33 #define STACK_ALIGNMENT                 64
34
35 /* For i.MX 6UltraLite EVK board */
36
37 #if defined(PLATFORM_FLAVOR_mx6ulevk)
38
39 #ifdef CFG_WITH_PAGER
40 #error "Pager not supported for platform mx6ulevk"
41 #endif
42 #ifdef CFG_WITH_LPAE
43 #error "LPAE not supported for now"
44 #endif
45
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
53
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
60
61 #define AIPS_TZ1_BASE_ADDR      0x02000000
62 #define AIPS1_OFF_BASE_ADDR     (AIPS_TZ1_BASE_ADDR + 0x80000)
63
64 #define DRAM0_BASE                      0x80000000
65 #define DRAM0_SIZE                      0x20000000
66
67 #define CFG_TEE_CORE_NB_CORE            1
68
69 #define DDR_PHYS_START                  DRAM0_BASE
70 #define DDR_SIZE                        DRAM0_SIZE
71
72 #define CFG_DDR_START                   DDR_PHYS_START
73 #define CFG_DDR_SIZE                    DDR_SIZE
74
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
78
79 /* Location of trusted dram on imx */
80 #define TZDRAM_BASE                     (0x9c100000)
81 #define TZDRAM_SIZE                     (0x03000000)
82
83 #define CFG_TEE_RAM_VA_SIZE             (1024 * 1024)
84
85 #ifndef CFG_TEE_LOAD_ADDR
86 #define CFG_TEE_LOAD_ADDR               CFG_TEE_RAM_START
87 #endif
88
89 /*
90  * Everything is in TZDRAM.
91  * +------------------+
92  * |        | TEE_RAM |
93  * + TZDRAM +---------+
94  * |        | TA_RAM  |
95  * +--------+---------+
96  */
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)
103
104 #define CONSOLE_UART_BASE               (UART0_BASE)
105
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
112
113 /* For i.MX6 Quad SABRE Lite and Smart Device board */
114
115 #elif defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
116         defined(PLATFORM_FLAVOR_mx6qsabresd) || \
117         defined(PLATFORM_FLAVOR_mx6dlsabresd)
118
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)
132
133 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
134         defined(PLATFORM_FLAVOR_mx6qsabresd)
135 #define UART1_BASE                      0x02020000
136 #define UART2_BASE                      0x021E8000
137 #else
138 #define UART1_BASE                      0x02020000
139 #define UART3_BASE                      0x021EC000
140 #define UART5_BASE                      0x021F4000
141 #endif
142
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
151
152 #if defined(PLATFORM_FLAVOR_mx6qsabrelite)
153 #define CONSOLE_UART_BASE               UART2_BASE
154 #endif
155 #if defined(PLATFORM_FLAVOR_mx6qsabresd)
156 #define CONSOLE_UART_BASE               UART1_BASE
157 #endif
158 #if defined(PLATFORM_FLAVOR_mx6dlsabresd)
159 #define CONSOLE_UART_BASE               UART1_BASE
160 #endif
161 #define DRAM0_BASE                      0x10000000
162 #define DRAM0_SIZE                      0x40000000
163
164 #define CFG_TEE_RAM_VA_SIZE             (1024 * 1024)
165
166 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
167         defined(PLATFORM_FLAVOR_mx6qsabresd)
168 #define CFG_TEE_CORE_NB_CORE            4
169 #else
170 #define CFG_TEE_CORE_NB_CORE            2
171 #endif
172
173 #define DDR_PHYS_START                  DRAM0_BASE
174 #define DDR_SIZE                        DRAM0_SIZE
175
176 #define CFG_DDR_START                   DDR_PHYS_START
177 #define CFG_DDR_SIZE                    DDR_SIZE
178
179 /*
180  * PL310 TAG RAM Control Register
181  *
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
185  */
186 #ifndef PL310_TAG_RAM_CTRL_INIT
187 #define PL310_TAG_RAM_CTRL_INIT         0x00000111
188 #endif
189
190 /*
191  * PL310 DATA RAM Control Register
192  *
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
196  */
197 #ifndef PL310_DATA_RAM_CTRL_INIT
198 #define PL310_DATA_RAM_CTRL_INIT        0x00000222
199 #endif
200
201 /*
202  * PL310 Auxiliary Control Register
203  *
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)
218  */
219 #ifndef PL310_AUX_CTRL_INIT
220 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
221         defined(PLATFORM_FLAVOR_mx6qsabresd)
222 #define PL310_AUX_CTRL_INIT             0x3C470800
223 #else
224 #define PL310_AUX_CTRL_INIT             0x3C440800
225 #endif
226 #endif
227
228 /*
229  * PL310 Prefetch Control Register
230  *
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)
236  */
237 #define PL310_PREFETCH_CTRL_INIT        0x31000007
238
239 /*
240  * PL310 Power Register
241  *
242  * Dynamic clock gating enabled
243  * Standby mode enabled
244  */
245 #define PL310_POWER_CTRL_INIT           0x00000003
246
247 /*
248  * SCU Invalidate Register
249  *
250  * Invalidate all registers
251  */
252 #define SCU_INV_CTRL_INIT               0xFFFFFFFF
253
254 /*
255  * SCU Access Register
256  * - both secure CPU access SCU
257  */
258 #define SCU_SAC_CTRL_INIT               0x0000000F
259
260 /*
261  * SCU NonSecure Access Register
262  * - both nonsec cpu access SCU, private and global timer
263  */
264 #define SCU_NSAC_CTRL_INIT              0x00000FFF
265
266 /* define the memory areas */
267
268 #ifdef CFG_WITH_PAGER
269
270 /*
271  * TEE/TZ RAM layout:
272  *
273  *  +---------------------------------------+  <- CFG_CORE_TZSRAM_EMUL_START
274  *  | TEE private highly | TEE_RAM          |   ^
275  *  |   secure memory    |                  |   | CFG_CORE_TZSRAM_EMUL_SIZE
276  *  +---------------------------------------+   v
277  *
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
285  *
286  *  TEE_RAM : default 256kByte
287  *  TA_RAM  : all what is left in DDR TEE reserved area
288  *  PUB_RAM : default 2MByte
289  */
290
291 /* emulated SRAM, at start of secure DDR */
292
293 #define CFG_CORE_TZSRAM_EMUL_START      0x4E000000
294
295 #define TZSRAM_BASE                     CFG_CORE_TZSRAM_EMUL_START
296 #define TZSRAM_SIZE                     CFG_CORE_TZSRAM_EMUL_SIZE
297
298 /* Location of trusted dram */
299
300 #define CFG_DDR_TEETZ_RESERVED_START    0x4E100000
301 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x01F00000
302
303 #define CFG_PUB_RAM_SIZE                (1 * 1024 * 1024)
304 #define CFG_TEE_RAM_PH_SIZE             TZSRAM_SIZE
305
306 #define TZDRAM_BASE                     (CFG_DDR_TEETZ_RESERVED_START)
307 #define TZDRAM_SIZE                     (CFG_DDR_TEETZ_RESERVED_SIZE - \
308                                 CFG_PUB_RAM_SIZE)
309
310 #define CFG_TA_RAM_START                TZDRAM_BASE
311 #define CFG_TA_RAM_SIZE                 TZDRAM_SIZE
312
313 #define CFG_SHMEM_START                 (CFG_DDR_TEETZ_RESERVED_START + \
314                                                 TZDRAM_SIZE)
315 #define CFG_SHMEM_SIZE                  CFG_PUB_RAM_SIZE
316
317 #define CFG_TEE_RAM_START               TZSRAM_BASE
318
319 #ifndef CFG_TEE_LOAD_ADDR
320 #define CFG_TEE_LOAD_ADDR               TZSRAM_BASE
321 #endif
322
323 #else /* CFG_WITH_PAGER */
324
325 /*
326  * TEE/TZ RAM layout:
327  *
328  *  +---------------------------------------+  <- CFG_DDR_TEETZ_RESERVED_START
329  *  | TEE private secure |  TEE_RAM         |   ^
330  *  |   external memory  +------------------+   |
331  *  |                    |  TA_RAM          |   |
332  *  +---------------------------------------+   | CFG_DDR_TEETZ_RESERVED_SIZE
333  *  |     Non secure     |  SHM             |   |
334  *  |   shared memory    |                  |   |
335  *  +---------------------------------------+   v
336  *
337  *  TEE_RAM : default 1MByte
338  *  PUB_RAM : default 2MByte
339  *  TA_RAM  : all what is left
340  */
341
342 #define CFG_DDR_TEETZ_RESERVED_START    0x4E000000
343 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x02000000
344
345 #define CFG_PUB_RAM_SIZE                (1 * 1024 * 1024)
346 #define CFG_TEE_RAM_PH_SIZE             (1 * 1024 * 1024)
347
348 #define TZDRAM_BASE                     (CFG_DDR_TEETZ_RESERVED_START)
349 #define TZDRAM_SIZE                     (CFG_DDR_TEETZ_RESERVED_SIZE - \
350                                 CFG_PUB_RAM_SIZE)
351
352 #define CFG_TA_RAM_START                (CFG_DDR_TEETZ_RESERVED_START + \
353                                 CFG_TEE_RAM_PH_SIZE)
354 #define CFG_TA_RAM_SIZE                 (CFG_DDR_TEETZ_RESERVED_SIZE - \
355                                 CFG_TEE_RAM_PH_SIZE - \
356                                 CFG_PUB_RAM_SIZE)
357
358 #define CFG_SHMEM_START                 (CFG_DDR_TEETZ_RESERVED_START + \
359                                 TZDRAM_SIZE)
360 #define CFG_SHMEM_SIZE                  CFG_PUB_RAM_SIZE
361
362 #define CFG_TEE_RAM_START               TZDRAM_BASE
363
364 #ifndef CFG_TEE_LOAD_ADDR
365 #define CFG_TEE_LOAD_ADDR               TZDRAM_BASE
366 #endif
367
368 #endif /* CFG_WITH_PAGER */
369
370 #else
371 #error "Unknown platform flavor"
372 #endif /* defined(PLATFORM_FLAVOR_mx6ulevk) */
373
374 #ifdef CFG_PL310
375 /*
376  * PL310 TAG RAM Control Register
377  *
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
381  */
382 #define PL310_TAG_RAM_CTRL_INIT         0x00000111
383
384 /*
385  * DATA RAM Control Register
386  *
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
390  */
391 #define PL310_DATA_RAM_CTRL_INIT        0x00000222
392
393 /*
394  * Auxiliary Control Register
395  *
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)
408  */
409 #if defined(PLATFORM_FLAVOR_mx6qsabrelite) || \
410         defined(PLATFORM_FLAVOR_mx6qsabresd)
411 #define PL310_AUX_CTRL_INIT             0x3C470800
412 #else
413 #define PL310_AUX_CTRL_INIT             0x3C440800
414 #endif
415
416 /*
417  * Prefetch Control Register
418  *
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)
424  */
425 #define PL310_PREFETCH_CTRL_INIT        0x31000007
426
427 /*
428  * Power Register = 0x00000003
429  *
430  * Dynamic clock gating enabled
431  * Standby mode enabled
432  */
433 #define PL310_POWER_CTRL_INIT           0x00000003
434
435 #endif
436
437 #endif /*PLATFORM_CONFIG_H*/