8e55ee8765bfacfae99f0d88396739d89c47fb2f
[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
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
133
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
142
143 #if defined(PLATFORM_FLAVOR_mx6qsabrelite)
144 #define CONSOLE_UART_BASE               UART2_BASE
145 #endif
146 #if defined(PLATFORM_FLAVOR_mx6qsabresd)
147 #define CONSOLE_UART_BASE               UART1_BASE
148 #endif
149 #define DRAM0_BASE                      0x10000000
150 #define DRAM0_SIZE                      0x40000000
151
152 #define CFG_TEE_RAM_VA_SIZE             (1024 * 1024)
153
154 #define CFG_TEE_CORE_NB_CORE            4
155
156 #define DDR_PHYS_START                  DRAM0_BASE
157 #define DDR_SIZE                        DRAM0_SIZE
158
159 #define CFG_DDR_START                   DDR_PHYS_START
160 #define CFG_DDR_SIZE                    DDR_SIZE
161
162 /*
163  * PL310 TAG RAM Control Register
164  *
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
168  */
169 #ifndef PL310_TAG_RAM_CTRL_INIT
170 #define PL310_TAG_RAM_CTRL_INIT         0x00000111
171 #endif
172
173 /*
174  * PL310 DATA RAM Control Register
175  *
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
179  */
180 #ifndef PL310_DATA_RAM_CTRL_INIT
181 #define PL310_DATA_RAM_CTRL_INIT        0x00000222
182 #endif
183
184 /*
185  * PL310 Auxiliary Control Register
186  *
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)
201  */
202 #ifndef PL310_AUX_CTRL_INIT
203 #define PL310_AUX_CTRL_INIT             0x3C470800
204 #endif
205
206 /*
207  * PL310 Prefetch Control Register
208  *
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)
214  */
215 #define PL310_PREFETCH_CTRL_INIT        0x31000007
216
217 /*
218  * PL310 Power Register
219  *
220  * Dynamic clock gating enabled
221  * Standby mode enabled
222  */
223 #define PL310_POWER_CTRL_INIT           0x00000003
224
225 /*
226  * SCU Invalidate Register
227  *
228  * Invalidate all registers
229  */
230 #define SCU_INV_CTRL_INIT               0xFFFFFFFF
231
232 /*
233  * SCU Access Register
234  * - both secure CPU access SCU
235  */
236 #define SCU_SAC_CTRL_INIT               0x0000000F
237
238 /*
239  * SCU NonSecure Access Register
240  * - both nonsec cpu access SCU, private and global timer
241  */
242 #define SCU_NSAC_CTRL_INIT              0x00000FFF
243
244 /* define the memory areas */
245
246 #ifdef CFG_WITH_PAGER
247
248 /*
249  * TEE/TZ RAM layout:
250  *
251  *  +---------------------------------------+  <- CFG_CORE_TZSRAM_EMUL_START
252  *  | TEE private highly | TEE_RAM          |   ^
253  *  |   secure memory    |                  |   | CFG_CORE_TZSRAM_EMUL_SIZE
254  *  +---------------------------------------+   v
255  *
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
263  *
264  *  TEE_RAM : default 256kByte
265  *  TA_RAM  : all what is left in DDR TEE reserved area
266  *  PUB_RAM : default 2MByte
267  */
268
269 /* emulated SRAM, at start of secure DDR */
270
271 #define CFG_CORE_TZSRAM_EMUL_START      0x4E000000
272
273 #define TZSRAM_BASE                     CFG_CORE_TZSRAM_EMUL_START
274 #define TZSRAM_SIZE                     CFG_CORE_TZSRAM_EMUL_SIZE
275
276 /* Location of trusted dram */
277
278 #define CFG_DDR_TEETZ_RESERVED_START    0x4E100000
279 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x01F00000
280
281 #define CFG_PUB_RAM_SIZE                (1 * 1024 * 1024)
282 #define CFG_TEE_RAM_PH_SIZE             TZSRAM_SIZE
283
284 #define TZDRAM_BASE                     (CFG_DDR_TEETZ_RESERVED_START)
285 #define TZDRAM_SIZE                     (CFG_DDR_TEETZ_RESERVED_SIZE - \
286                                 CFG_PUB_RAM_SIZE)
287
288 #define CFG_TA_RAM_START                TZDRAM_BASE
289 #define CFG_TA_RAM_SIZE                 TZDRAM_SIZE
290
291 #define CFG_SHMEM_START                 (CFG_DDR_TEETZ_RESERVED_START + \
292                                                 TZDRAM_SIZE)
293 #define CFG_SHMEM_SIZE                  CFG_PUB_RAM_SIZE
294
295 #define CFG_TEE_RAM_START               TZSRAM_BASE
296
297 #ifndef CFG_TEE_LOAD_ADDR
298 #define CFG_TEE_LOAD_ADDR               TZSRAM_BASE
299 #endif
300
301 #else /* CFG_WITH_PAGER */
302
303 /*
304  * TEE/TZ RAM layout:
305  *
306  *  +---------------------------------------+  <- CFG_DDR_TEETZ_RESERVED_START
307  *  | TEE private secure |  TEE_RAM         |   ^
308  *  |   external memory  +------------------+   |
309  *  |                    |  TA_RAM          |   |
310  *  +---------------------------------------+   | CFG_DDR_TEETZ_RESERVED_SIZE
311  *  |     Non secure     |  SHM             |   |
312  *  |   shared memory    |                  |   |
313  *  +---------------------------------------+   v
314  *
315  *  TEE_RAM : default 1MByte
316  *  PUB_RAM : default 2MByte
317  *  TA_RAM  : all what is left
318  */
319
320 #define CFG_DDR_TEETZ_RESERVED_START    0x4E000000
321 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x02000000
322
323 #define CFG_PUB_RAM_SIZE                (1 * 1024 * 1024)
324 #define CFG_TEE_RAM_PH_SIZE             (1 * 1024 * 1024)
325
326 #define TZDRAM_BASE                     (CFG_DDR_TEETZ_RESERVED_START)
327 #define TZDRAM_SIZE                     (CFG_DDR_TEETZ_RESERVED_SIZE - \
328                                 CFG_PUB_RAM_SIZE)
329
330 #define CFG_TA_RAM_START                (CFG_DDR_TEETZ_RESERVED_START + \
331                                 CFG_TEE_RAM_PH_SIZE)
332 #define CFG_TA_RAM_SIZE                 (CFG_DDR_TEETZ_RESERVED_SIZE - \
333                                 CFG_TEE_RAM_PH_SIZE - \
334                                 CFG_PUB_RAM_SIZE)
335
336 #define CFG_SHMEM_START                 (CFG_DDR_TEETZ_RESERVED_START + \
337                                 TZDRAM_SIZE)
338 #define CFG_SHMEM_SIZE                  CFG_PUB_RAM_SIZE
339
340 #define CFG_TEE_RAM_START               TZDRAM_BASE
341
342 #ifndef CFG_TEE_LOAD_ADDR
343 #define CFG_TEE_LOAD_ADDR               TZDRAM_BASE
344 #endif
345
346 #endif /* CFG_WITH_PAGER */
347
348 #else
349 #error "Unknown platform flavor"
350 #endif /* defined(PLATFORM_FLAVOR_mx6ulevk) */
351
352 #ifdef CFG_PL310
353 /*
354  * PL310 TAG RAM Control Register
355  *
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
359  */
360 #define PL310_TAG_RAM_CTRL_INIT         0x00000111
361
362 /*
363  * DATA RAM Control Register
364  *
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
368  */
369 #define PL310_DATA_RAM_CTRL_INIT        0x00000222
370
371 /*
372  * Auxiliary Control Register
373  *
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)
386  */
387 #define PL310_AUX_CTRL_INIT             0x3C470800
388
389 /*
390  * Prefetch Control Register
391  *
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)
397  */
398 #define PL310_PREFETCH_CTRL_INIT        0x31000007
399
400 /*
401  * Power Register = 0x00000003
402  *
403  * Dynamic clock gating enabled
404  * Standby mode enabled
405  */
406 #define PL310_POWER_CTRL_INIT           0x00000003
407
408 #endif
409
410 #endif /*PLATFORM_CONFIG_H*/