xref: /optee_os/core/arch/arm/plat-zynq7k/plat_init.S (revision 9f34db38245c9b3a4e6e7e63eb78a75e23ab2da3)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * All rights reserved.
5 * Copyright (c) 2016, Wind River Systems.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/*
32 * Entry points for the A9 inits, A9 revision specific or not.
33 * It is assume no stack is available when these routines are called.
34 * It is assume each routine is called with return address in LR
35 * and with ARM registers R0, R1, R2, R3 being scratchable.
36 */
37
38#include <arm32.h>
39#include <arm32_macros.S>
40#include <arm32_macros_cortex_a9.S>
41#include <asm.S>
42#include <kernel/tz_ssvce_def.h>
43#include <platform_config.h>
44
45#define ZYNQ_SLCR_L2C_RAM	0xF8000A1C
46
47.section .text
48.balign 4
49.code 32
50
51/*
52 * Cortex A9 early configuration
53 *
54 * Use registers R0-R3.
55 * No stack usage.
56 * LR store return address.
57 * Trap CPU in case of error.
58 */
59FUNC plat_cpu_reset_early , :
60	/*
61	 * Disallow NSec to mask FIQ [bit4: FW=0]
62	 * Allow NSec to manage Imprecise Abort [bit5: AW=1]
63	 * Imprecise Abort trapped to Abort Mode [bit3: EA=0]
64	 * In Sec world, FIQ trapped to FIQ Mode [bit2: FIQ=0]
65	 * IRQ always trapped to IRQ Mode [bit1: IRQ=0]
66	 * Secure World [bit0: NS=0]
67	 */
68	mov r0, #SCR_AW
69	write_scr r0		/* write Secure Configuration Register */
70
71	/*
72	 * Mandated HW config loaded
73	 *
74	 * SCTLR = 0x00004000
75	 * - Round-Robin replac. for icache, btac, i/duTLB (bit14: RoundRobin)
76	 *
77	 * ACTRL = 0x00000041
78	 * - core always in full SMP (FW bit0=1, SMP bit6=1)
79	 * - L2 write full line of zero disabled (bit3=0)
80	 *   (keep WFLZ low. Will be set once outer L2 is ready)
81	 *
82	 * NSACR = 0x00020C00
83	 * - NSec cannot change ACTRL.SMP (NS_SMP bit18=0)
84	 * - Nsec can lockdown TLB (TL bit17=1)
85	 * - NSec cannot access PLE (PLE bit16=0)
86	 * - NSec can use SIMD/VFP (CP10/CP11) (bit15:14=2b00, bit11:10=2b11)
87	 *
88	 * PCR = 0x00000001
89	 * - no change latency, enable clk gating
90	 */
91	mov_imm r0, 0x00004000
92	write_sctlr r0
93
94	mov_imm r0, 0x00000041
95	write_actlr r0
96
97	mov_imm r0, 0x00020C00
98	write_nsacr r0
99
100	mov_imm r0, 0x00000001
101	write_pcr r0
102
103	mov pc, lr
104END_FUNC plat_cpu_reset_early
105