407a412465ec0e3b8a0add1a25bb532d74a38680
[platform/core/security/tef-optee_os.git] / core / arch / arm / plat-stm / platform_config.h
1 /*
2  * Copyright (c) 2014-2016, Linaro Limited
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #ifndef PLATFORM_CONFIG_H
29 #define PLATFORM_CONFIG_H
30
31 /* Below are platform/SoC settings specific to stm platform flavors */
32
33 #if defined(PLATFORM_FLAVOR_b2260)
34
35 #define CFG_TEE_CORE_NB_CORE    2
36
37 #ifndef CFG_DDR_START
38 #define CFG_DDR_START           0x40000000
39 #define CFG_DDR_SIZE            0x40000000
40 #endif
41 #ifndef CFG_DDR_TEETZ_RESERVED_START
42 #define CFG_DDR_TEETZ_RESERVED_START    0x7E000000
43 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x01E00000
44 #endif
45 #ifndef CFG_CORE_TZSRAM_EMUL_START
46 #define CFG_CORE_TZSRAM_EMUL_START      0x7FE00000
47 #endif
48
49 #define CPU_IOMEM_BASE          0x08760000
50 #define CPU_PORT_FILT_START     0x40000000
51 #define CPU_PORT_FILT_END       0xC0000000
52 #define STXHxxx_LPM_PERIPH_BASE 0x09700000
53 #define RNG_BASE                0x08A89000
54
55 #define ASC_NUM                 21
56 #define UART_CONSOLE_BASE       ST_ASC21_REGS_BASE
57
58 #elif defined(PLATFORM_FLAVOR_cannes)
59
60 #define CFG_TEE_CORE_NB_CORE    2
61
62 #ifndef CFG_DDR_START
63 #define CFG_DDR_START           0x40000000
64 #define CFG_DDR_SIZE            0x80000000
65 #endif
66 #ifndef CFG_DDR_TEETZ_RESERVED_START
67 #define CFG_DDR_TEETZ_RESERVED_START    0x93a00000
68 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x01000000
69 #endif
70 #ifndef CFG_CORE_TZSRAM_EMUL_START
71 #define CFG_CORE_TZSRAM_EMUL_START      0x94a00000
72 #endif
73
74 #define CPU_IOMEM_BASE          0x08760000
75 #define CPU_PORT_FILT_START     0x40000000
76 #define CPU_PORT_FILT_END       0xC0000000
77 #define STXHxxx_LPM_PERIPH_BASE 0x09400000
78 #define RNG_BASE                0x08A89000
79
80 #define ASC_NUM                 20
81 #define UART_CONSOLE_BASE       ST_ASC20_REGS_BASE
82
83 #elif defined(PLATFORM_FLAVOR_orly2)
84
85 #define CFG_TEE_CORE_NB_CORE    2
86
87 #ifndef CFG_DDR_START
88 #define CFG_DDR_START           0x40000000
89 #define CFG_DDR_SIZE            0x40000000
90 #define CFG_DDR1_START          0x80000000
91 #define CFG_DDR1_SIZE           0x40000000
92 #endif
93 #ifndef CFG_DDR_TEETZ_RESERVED_START
94 #define CFG_DDR_TEETZ_RESERVED_START    0x8F000000
95 #define CFG_DDR_TEETZ_RESERVED_SIZE     0x00800000
96 #endif
97
98 #define CPU_IOMEM_BASE          0xFFFE0000
99 #define CPU_PORT_FILT_START     0x40000000
100 #define CPU_PORT_FILT_END       0x80000000
101 #define STXHxxx_LPM_PERIPH_BASE 0xFE400000
102 #define RNG_BASE                0xFEE80000
103
104 #define ASC_NUM                 21
105 #define UART_CONSOLE_BASE       ST_ASC21_REGS_BASE
106
107 #else /* defined(PLATFORM_FLAVOR_xxx) */
108
109 #error "Unknown platform flavor"
110
111 #endif /* defined(PLATFORM_FLAVOR_xxx) */
112
113 /* Below are settings common to stm platform flavors */
114
115 /*
116  * CP15 Secure ConTroL Register (SCTLR
117  *
118  * - Round-Robin replac. for icache, btac, i/duTLB (bit14: RoundRobin)
119  */
120 #define CPU_SCTLR_INIT                  0x00004000
121
122 /*
123  * CP15 Auxiliary ConTroL Register (ACTRL)
124  *
125  * - core always in full SMP (FW bit0=1, SMP bit6=1)
126  * - L2 write full line of zero disabled (bit3=0)
127  *   (keep WFLZ low. Will be set once outer L2 is ready)
128  */
129
130 #define CPU_ACTLR_INIT                  0x00000041
131
132 /*
133  * CP15 NonSecure Access Control Register (NSACR)
134  *
135  * - NSec cannot change ACTRL.SMP (NS_SMP bit18=0)
136  * - Nsec can lockdown TLB (TL bit17=1)
137  * - NSec cannot access PLE (PLE bit16=0)
138  * - NSec can use SIMD/VFP (CP10/CP11) (bit15:14=2b00, bit11:10=2b11)
139  */
140 #define CPU_NSACR_INIT                  0x00020C00
141
142 /*
143  * CP15 Power Control Register (PCR)
144  *
145  * - no change latency, enable clk gating
146  */
147 #define CPU_PCR_INIT                    0x00000001
148
149
150 /*
151  * SCU Secure Access Control / NonSecure Access Control
152  *
153  * SAC:  Both secure CPU access SCU (bit[3:0]).
154  * NSAC: Both nonsec cpu access SCU (bit[3:0]), private timers (bit[7:4])
155  *       and global timers (bit[11:8]).
156  */
157 #if !defined(SCU_SAC_INIT) || !defined(SCU_NSAC_INIT)
158 #define SCU_CPUS_MASK           (SHIFT_U32(1, CFG_TEE_CORE_NB_CORE) - 1)
159
160 #define SCU_SAC_INIT    SCU_CPUS_MASK
161 #define SCU_NSAC_INIT   (SHIFT_U32(SCU_CPUS_MASK, SCU_NSAC_SCU_SHIFT) | \
162                         SHIFT_U32(SCU_CPUS_MASK, SCU_NSAC_PTIMER_SHIFT) | \
163                         SHIFT_U32(SCU_CPUS_MASK, SCU_NSAC_GTIMER_SHIFT))
164 #endif
165
166 /*
167  * PL310 TAG RAM Control Register
168  *
169  * bit[10:8]:1 - 2 cycle of write accesses latency
170  * bit[6:4]:1 - 2 cycle of read accesses latency
171  * bit[2:0]:1 - 2 cycle of setup latency
172  */
173 #ifndef PL310_TAG_RAM_CTRL_INIT
174 #define PL310_TAG_RAM_CTRL_INIT         0x00000111
175 #endif
176
177 /*
178  * PL310 DATA RAM Control Register
179  *
180  * bit[10:8]:2 - 3 cycle of write accesses latency
181  * bit[6:4]:2 - 3 cycle of read accesses latency
182  * bit[2:0]:2 - 3 cycle of setup latency
183  */
184 #ifndef PL310_DATA_RAM_CTRL_INIT
185 #define PL310_DATA_RAM_CTRL_INIT        0x00000222
186 #endif
187
188 /*
189  * PL310 Auxiliary Control Register
190  *
191  * I/Dcache prefetch enabled (bit29:28=2b11)
192  * NS can access interrupts (bit27=1)
193  * NS can lockown cache lines (bit26=1)
194  * Pseudo-random replacement policy (bit25=0)
195  * Force write allocated (default)
196  * Shared attribute internally ignored (bit22=1, bit13=0)
197  * Parity disabled (bit21=0)
198  * Event monitor disabled (bit20=0)
199  * Platform fmavor specific way config:
200  * - way size (bit19:17)
201  * - way associciativity (bit16)
202  * Store buffer device limitation enabled (bit11=1)
203  * Cacheable accesses have high prio (bit10=0)
204  * Full Line Zero (FLZ) disabled (bit0=0)
205  */
206 #ifndef PL310_AUX_CTRL_INIT
207 #define PL310_AUX_CTRL_INIT             0x3C480800
208 #endif
209
210 /*
211  * PL310 Prefetch Control Register
212  *
213  * Double linefill disabled (bit30=0)
214  * I/D prefetch enabled (bit29:28=2b11)
215  * Prefetch drop enabled (bit24=1)
216  * Incr double linefill disable (bit23=0)
217  * Prefetch offset = 7 (bit4:0)
218  */
219 #define PL310_PREFETCH_CTRL_INIT        0x31000007
220
221 /*
222  * PL310 Power Register
223  *
224  * Dynamic clock gating enabled
225  * Standby mode enabled
226  */
227 #define PL310_POWER_CTRL_INIT           0x00000003
228
229 /*
230  * SCU Control Register : CTRL = 0x00000065
231  * - ic stanby enable=1
232  * - scu standby enable=1
233  * - scu enable=1
234  */
235 #define SCU_CTRL_INIT                   0x00000065
236
237 /*
238  * TEE RAM layout without CFG_WITH_PAGER:
239  *
240  *  +---------------------------------------+  <- CFG_DDR_TEETZ_RESERVED_START
241  *  | TEE private secure |  TEE_RAM         |   ^
242  *  |   external memory  +------------------+   |
243  *  |                    |  TA_RAM          |   |
244  *  +---------------------------------------+   | CFG_DDR_TEETZ_RESERVED_SIZE
245  *  |     Non secure     |  SHM             |   |
246  *  |   shared memory    |                  |   |
247  *  +---------------------------------------+   v
248  *
249  *  TEE_RAM : default 1MByte
250  *  PUB_RAM : default 2MByte
251  *  TA_RAM  : all what is left
252  *
253  * ----------------------------------------------------------------------------
254  * TEE RAM layout with CFG_WITH_PAGER=y:
255  *
256  *  +---------------------------------------+  <- CFG_CORE_TZSRAM_EMUL_START
257  *  | TEE private highly | TEE_RAM          |   ^
258  *  |   secure memory    |                  |   | CFG_CORE_TZSRAM_EMUL_SIZE
259  *  +---------------------------------------+   v
260  *
261  *  +---------------------------------------+  <- CFG_DDR_TEETZ_RESERVED_START
262  *  | TEE private secure |  TA_RAM          |   ^
263  *  |   external memory  |                  |   |
264  *  +---------------------------------------+   | CFG_DDR_TEETZ_RESERVED_SIZE
265  *  |     Non secure     |  SHM             |   |
266  *  |   shared memory    |                  |   |
267  *  +---------------------------------------+   v
268  *
269  *  TEE_RAM : default 256kByte
270  *  TA_RAM  : all what is left in DDR TEE reserved area
271  *  PUB_RAM : default 2MByte
272  */
273
274 /* default locate shared memory at the end of the TEE reserved DDR */
275 #ifndef CFG_SHMEM_SIZE
276 #define CFG_SHMEM_SIZE          (2 * 1024 * 1024)
277 #endif
278
279 #ifndef CFG_SHMEM_START
280 #define CFG_SHMEM_START         (CFG_DDR_TEETZ_RESERVED_START + \
281                                 CFG_DDR_TEETZ_RESERVED_SIZE - \
282                                 CFG_SHMEM_SIZE)
283 #endif
284
285 #if defined(CFG_WITH_PAGER)
286
287 #define TZSRAM_BASE             CFG_CORE_TZSRAM_EMUL_START
288 #define TZSRAM_SIZE             CFG_CORE_TZSRAM_EMUL_SIZE
289
290 #define TZDRAM_BASE             CFG_DDR_TEETZ_RESERVED_START
291 #define TZDRAM_SIZE             (CFG_DDR_TEETZ_RESERVED_SIZE - CFG_SHMEM_SIZE)
292
293 #define CFG_TEE_RAM_START       TZSRAM_BASE
294 #define CFG_TEE_RAM_PH_SIZE     TZSRAM_SIZE
295
296 #define CFG_TA_RAM_START        TZDRAM_BASE
297 #define CFG_TA_RAM_SIZE         TZDRAM_SIZE
298
299 #else  /* CFG_WITH_PAGER */
300
301 #define TZDRAM_BASE             CFG_DDR_TEETZ_RESERVED_START
302 #define TZDRAM_SIZE             (CFG_DDR_TEETZ_RESERVED_SIZE - CFG_SHMEM_SIZE)
303
304 #define CFG_TEE_RAM_START       TZDRAM_BASE
305 #ifndef CFG_TEE_RAM_PH_SIZE
306 #define CFG_TEE_RAM_PH_SIZE     (1 * 1024 * 1024)
307 #endif
308
309 #define CFG_TA_RAM_START        (TZDRAM_BASE + CFG_TEE_RAM_PH_SIZE)
310 #define CFG_TA_RAM_SIZE         (TZDRAM_SIZE - CFG_TEE_RAM_PH_SIZE)
311
312 #endif /* !CFG_WITH_PAGER */
313
314 /* External DDR dies */
315 #define DRAM0_BASE              CFG_DDR_START
316 #define DRAM0_SIZE              CFG_DDR_SIZE
317 #ifdef CFG_DDR1_START
318 #define DRAM1_BASE              CFG_DDR1_START
319 #define DRAM1_SIZE              CFG_DDR1_SIZE
320 #endif
321
322 #ifndef CFG_TEE_RAM_VA_SIZE
323 #define CFG_TEE_RAM_VA_SIZE     (1024 * 1024)
324 #endif
325
326 #ifndef CFG_TEE_LOAD_ADDR
327 #define CFG_TEE_LOAD_ADDR       CFG_TEE_RAM_START
328 #endif
329
330 #define PL310_BASE              (CPU_IOMEM_BASE + 0x2000)
331 #define GIC_DIST_BASE           (CPU_IOMEM_BASE + 0x1000)
332 #define SCU_BASE                (CPU_IOMEM_BASE + 0x0000)
333 #define GIC_CPU_BASE            (CPU_IOMEM_BASE + 0x0100)
334 #define ST_ASC20_REGS_BASE      (STXHxxx_LPM_PERIPH_BASE + 0x00130000)
335 #define ST_ASC21_REGS_BASE      (STXHxxx_LPM_PERIPH_BASE + 0x00131000)
336
337 /* Make stacks aligned to data cache line length */
338 #define STACK_ALIGNMENT         32
339
340 #endif /* PLATFORM_CONFIG_H */