2 * Copyright (c) 2014-2016, Linaro Limited
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
28 #ifndef PLATFORM_CONFIG_H
29 #define PLATFORM_CONFIG_H
31 /* Below are platform/SoC settings specific to stm platform flavors */
33 #if defined(PLATFORM_FLAVOR_b2260)
35 #define CFG_TEE_CORE_NB_CORE 2
38 #define CFG_DDR_START 0x40000000
39 #define CFG_DDR_SIZE 0x40000000
41 #ifndef CFG_DDR_TEETZ_RESERVED_START
42 #define CFG_DDR_TEETZ_RESERVED_START 0x7E000000
43 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x01E00000
45 #ifndef CFG_CORE_TZSRAM_EMUL_START
46 #define CFG_CORE_TZSRAM_EMUL_START 0x7FE00000
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
56 #define UART_CONSOLE_BASE ST_ASC21_REGS_BASE
58 #elif defined(PLATFORM_FLAVOR_cannes)
60 #define CFG_TEE_CORE_NB_CORE 2
63 #define CFG_DDR_START 0x40000000
64 #define CFG_DDR_SIZE 0x80000000
66 #ifndef CFG_DDR_TEETZ_RESERVED_START
67 #define CFG_DDR_TEETZ_RESERVED_START 0x93a00000
68 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x01000000
70 #ifndef CFG_CORE_TZSRAM_EMUL_START
71 #define CFG_CORE_TZSRAM_EMUL_START 0x94a00000
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
81 #define UART_CONSOLE_BASE ST_ASC20_REGS_BASE
83 #elif defined(PLATFORM_FLAVOR_orly2)
85 #define CFG_TEE_CORE_NB_CORE 2
88 #define CFG_DDR_START 0x40000000
89 #define CFG_DDR_SIZE 0x40000000
90 #define CFG_DDR1_START 0x80000000
91 #define CFG_DDR1_SIZE 0x40000000
93 #ifndef CFG_DDR_TEETZ_RESERVED_START
94 #define CFG_DDR_TEETZ_RESERVED_START 0x8F000000
95 #define CFG_DDR_TEETZ_RESERVED_SIZE 0x00800000
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
105 #define UART_CONSOLE_BASE ST_ASC21_REGS_BASE
107 #else /* defined(PLATFORM_FLAVOR_xxx) */
109 #error "Unknown platform flavor"
111 #endif /* defined(PLATFORM_FLAVOR_xxx) */
113 /* Below are settings common to stm platform flavors */
116 * CP15 Secure ConTroL Register (SCTLR
118 * - Round-Robin replac. for icache, btac, i/duTLB (bit14: RoundRobin)
120 #define CPU_SCTLR_INIT 0x00004000
123 * CP15 Auxiliary ConTroL Register (ACTRL)
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)
130 #define CPU_ACTLR_INIT 0x00000041
133 * CP15 NonSecure Access Control Register (NSACR)
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)
140 #define CPU_NSACR_INIT 0x00020C00
143 * CP15 Power Control Register (PCR)
145 * - no change latency, enable clk gating
147 #define CPU_PCR_INIT 0x00000001
151 * SCU Secure Access Control / NonSecure Access Control
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]).
157 #if !defined(SCU_SAC_INIT) || !defined(SCU_NSAC_INIT)
158 #define SCU_CPUS_MASK (SHIFT_U32(1, CFG_TEE_CORE_NB_CORE) - 1)
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))
167 * PL310 TAG RAM Control Register
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
173 #ifndef PL310_TAG_RAM_CTRL_INIT
174 #define PL310_TAG_RAM_CTRL_INIT 0x00000111
178 * PL310 DATA RAM Control Register
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
184 #ifndef PL310_DATA_RAM_CTRL_INIT
185 #define PL310_DATA_RAM_CTRL_INIT 0x00000222
189 * PL310 Auxiliary Control Register
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)
206 #ifndef PL310_AUX_CTRL_INIT
207 #define PL310_AUX_CTRL_INIT 0x3C480800
211 * PL310 Prefetch Control Register
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)
219 #define PL310_PREFETCH_CTRL_INIT 0x31000007
222 * PL310 Power Register
224 * Dynamic clock gating enabled
225 * Standby mode enabled
227 #define PL310_POWER_CTRL_INIT 0x00000003
230 * SCU Control Register : CTRL = 0x00000065
231 * - ic stanby enable=1
232 * - scu standby enable=1
235 #define SCU_CTRL_INIT 0x00000065
238 * TEE RAM layout without CFG_WITH_PAGER:
240 * +---------------------------------------+ <- CFG_DDR_TEETZ_RESERVED_START
241 * | TEE private secure | TEE_RAM | ^
242 * | external memory +------------------+ |
244 * +---------------------------------------+ | CFG_DDR_TEETZ_RESERVED_SIZE
245 * | Non secure | SHM | |
246 * | shared memory | | |
247 * +---------------------------------------+ v
249 * TEE_RAM : default 1MByte
250 * PUB_RAM : default 2MByte
251 * TA_RAM : all what is left
253 * ----------------------------------------------------------------------------
254 * TEE RAM layout with CFG_WITH_PAGER=y:
256 * +---------------------------------------+ <- CFG_CORE_TZSRAM_EMUL_START
257 * | TEE private highly | TEE_RAM | ^
258 * | secure memory | | | CFG_CORE_TZSRAM_EMUL_SIZE
259 * +---------------------------------------+ v
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
269 * TEE_RAM : default 256kByte
270 * TA_RAM : all what is left in DDR TEE reserved area
271 * PUB_RAM : default 2MByte
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)
279 #ifndef CFG_SHMEM_START
280 #define CFG_SHMEM_START (CFG_DDR_TEETZ_RESERVED_START + \
281 CFG_DDR_TEETZ_RESERVED_SIZE - \
285 #if defined(CFG_WITH_PAGER)
287 #define TZSRAM_BASE CFG_CORE_TZSRAM_EMUL_START
288 #define TZSRAM_SIZE CFG_CORE_TZSRAM_EMUL_SIZE
290 #define TZDRAM_BASE CFG_DDR_TEETZ_RESERVED_START
291 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - CFG_SHMEM_SIZE)
293 #define CFG_TEE_RAM_START TZSRAM_BASE
294 #define CFG_TEE_RAM_PH_SIZE TZSRAM_SIZE
296 #define CFG_TA_RAM_START TZDRAM_BASE
297 #define CFG_TA_RAM_SIZE TZDRAM_SIZE
299 #else /* CFG_WITH_PAGER */
301 #define TZDRAM_BASE CFG_DDR_TEETZ_RESERVED_START
302 #define TZDRAM_SIZE (CFG_DDR_TEETZ_RESERVED_SIZE - CFG_SHMEM_SIZE)
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)
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)
312 #endif /* !CFG_WITH_PAGER */
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
322 #ifndef CFG_TEE_RAM_VA_SIZE
323 #define CFG_TEE_RAM_VA_SIZE (1024 * 1024)
326 #ifndef CFG_TEE_LOAD_ADDR
327 #define CFG_TEE_LOAD_ADDR CFG_TEE_RAM_START
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)
337 /* Make stacks aligned to data cache line length */
338 #define STACK_ALIGNMENT 32
340 #endif /* PLATFORM_CONFIG_H */