xref: /optee_os/core/arch/arm/plat-stm/tz_a9init.S (revision 2ffdd194063da02d2e82a5f671893fb19ba7846c)
1/*
2 * Copyright (c) 2014-2016, STMicroelectronics International N.V.
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#include <arm32.h>
29#include <arm32_macros.S>
30#include <asm.S>
31#include <kernel/tz_ssvce_def.h>
32#include <kernel/unwind.h>
33#include <platform_config.h>
34
35.section .text
36.balign 4
37.code 32
38
39/*
40 * void arm_cl2_enable(vaddr_t pl310_base) - Memory Cache Level2 Enable Function
41 *
42 * If PL310 supports FZLW, enable also FZL in A9 core
43 *
44 * Use scratables registers R0-R3.
45 * No stack usage.
46 * LR store return address.
47 * Trap CPU in case of error.
48 * TODO: to be moved to PL310 code (tz_svce_pl310.S ?)
49 */
50FUNC arm_cl2_enable , :
51UNWIND(	.fnstart)
52
53	/* Enable PL310 ctrl -> only set lsb bit */
54	mov  r1, #0x1
55	str  r1, [r0, #PL310_CTRL]
56
57	/* if L2 FLZW enable, enable in L1 */
58	ldr  r1, [r0, #PL310_AUX_CTRL]
59	tst  r1, #(1 << 0) /* test AUX_CTRL[FLZ] */
60	read_actlr r0
61	orrne r0, r0, #(1 << 3) /* enable ACTLR[FLZW] */
62	write_actlr r0
63
64	mov pc, lr
65
66UNWIND(	.fnend)
67END_FUNC arm_cl2_enable
68
69/*
70 * Cortex A9 configuration early configuration
71 *
72 * Use scratables registers R0-R3.
73 * No stack usage.
74 * LR store return address.
75 * Trap CPU in case of error.
76 */
77FUNC plat_cpu_reset_early , :
78UNWIND(	.fnstart)
79
80	movw r0, #(CPU_SCTLR_INIT & 0xFFFF)
81	movt r0, #((CPU_SCTLR_INIT >> 16) & 0xFFFF)
82	write_sctlr r0
83
84	movw r0, #(CPU_ACTLR_INIT & 0xFFFF)
85	movt r0, #((CPU_ACTLR_INIT >> 16) & 0xFFFF)
86	write_actlr r0
87
88	movw r0, #(CPU_NSACR_INIT & 0xFFFF)
89	movt r0, #((CPU_NSACR_INIT >> 16) & 0xFFFF)
90	write_nsacr r0
91
92	movw r0, #(CPU_PCR_INIT & 0xFFFF)
93	movt r0, #((CPU_PCR_INIT >> 16) & 0xFFFF)
94	write_pcr r0
95
96	mov pc, lr
97
98UNWIND(	.fnend)
99END_FUNC plat_cpu_reset_early
100
101