xref: /aosp_15_r20/trusty/kernel/platform/vexpress-a15/secondary_boot.S (revision 344aa361028b423587d4ef3fa52a23d194628137)
1*344aa361SAndroid Build Coastguard Worker/*
2*344aa361SAndroid Build Coastguard Worker * Copyright (c) 2013, Google Inc. All rights reserved.
3*344aa361SAndroid Build Coastguard Worker *
4*344aa361SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining
5*344aa361SAndroid Build Coastguard Worker * a copy of this software and associated documentation files
6*344aa361SAndroid Build Coastguard Worker * (the "Software"), to deal in the Software without restriction,
7*344aa361SAndroid Build Coastguard Worker * including without limitation the rights to use, copy, modify, merge,
8*344aa361SAndroid Build Coastguard Worker * publish, distribute, sublicense, and/or sell copies of the Software,
9*344aa361SAndroid Build Coastguard Worker * and to permit persons to whom the Software is furnished to do so,
10*344aa361SAndroid Build Coastguard Worker * subject to the following conditions:
11*344aa361SAndroid Build Coastguard Worker *
12*344aa361SAndroid Build Coastguard Worker * The above copyright notice and this permission notice shall be
13*344aa361SAndroid Build Coastguard Worker * included in all copies or substantial portions of the Software.
14*344aa361SAndroid Build Coastguard Worker *
15*344aa361SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*344aa361SAndroid Build Coastguard Worker * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*344aa361SAndroid Build Coastguard Worker * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18*344aa361SAndroid Build Coastguard Worker * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19*344aa361SAndroid Build Coastguard Worker * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20*344aa361SAndroid Build Coastguard Worker * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21*344aa361SAndroid Build Coastguard Worker * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*344aa361SAndroid Build Coastguard Worker */
23*344aa361SAndroid Build Coastguard Worker
24*344aa361SAndroid Build Coastguard Worker#include <asm.h>
25*344aa361SAndroid Build Coastguard Worker#include <platform/vexpress-a15.h>
26*344aa361SAndroid Build Coastguard Worker#include <platform/gic.h>
27*344aa361SAndroid Build Coastguard Worker#if WITH_LIB_SM
28*344aa361SAndroid Build Coastguard Worker#include <lib/sm/monitor.h>
29*344aa361SAndroid Build Coastguard Worker#endif
30*344aa361SAndroid Build Coastguard Worker
31*344aa361SAndroid Build Coastguard Worker#define GICC_CTLR               (0x0000)
32*344aa361SAndroid Build Coastguard Worker#define GICC_IAR                (0x000c)
33*344aa361SAndroid Build Coastguard Worker#define GICC_EOIR               (0x0010)
34*344aa361SAndroid Build Coastguard Worker
35*344aa361SAndroid Build Coastguard Worker.section ".text"
36*344aa361SAndroid Build Coastguard Worker
37*344aa361SAndroid Build Coastguard WorkerFUNCTION(platform_secondary_entry)
38*344aa361SAndroid Build Coastguard Worker	/* clear wakeup sgi */
39*344aa361SAndroid Build Coastguard Worker	ldr	r4, =GICBASE(0) + GICC_OFFSET
40*344aa361SAndroid Build Coastguard Worker	ldr	r5, [r4, #GICC_IAR]
41*344aa361SAndroid Build Coastguard Worker	str	r5, [r4, #GICC_EOIR]
42*344aa361SAndroid Build Coastguard Worker
43*344aa361SAndroid Build Coastguard Worker	b	_start
44*344aa361SAndroid Build Coastguard Worker
45*344aa361SAndroid Build Coastguard Worker
46*344aa361SAndroid Build Coastguard Worker#if WITH_LIB_SM
47*344aa361SAndroid Build Coastguard Worker
48*344aa361SAndroid Build Coastguard WorkerFUNCTION(platform_mon_initial_ns_return)
49*344aa361SAndroid Build Coastguard Worker	/* figure out our cpu number */
50*344aa361SAndroid Build Coastguard Worker	mrc	p15, 0, ip, c0, c0, 5 /* read MPIDR */
51*344aa361SAndroid Build Coastguard Worker
52*344aa361SAndroid Build Coastguard Worker	/* mask off the bottom 12 bits to test cluster number:cpu number */
53*344aa361SAndroid Build Coastguard Worker	ubfx	ip, ip, #0, #12
54*344aa361SAndroid Build Coastguard Worker
55*344aa361SAndroid Build Coastguard Worker	/* if we're not cpu 0:0, wait for ns reset addr */
56*344aa361SAndroid Build Coastguard Worker	cmp	ip, #0
57*344aa361SAndroid Build Coastguard Worker	moveq	lr, #~0
58*344aa361SAndroid Build Coastguard Worker	beq	mon_initial_ns_return
59*344aa361SAndroid Build Coastguard Worker
60*344aa361SAndroid Build Coastguard Worker	ldr	r4, =SECONDARY_BOOT_ADDR
61*344aa361SAndroid Build Coastguard Worker	ldr	r5, =platform_secondary_entry_paddr
62*344aa361SAndroid Build Coastguard Worker	ldr	r5, [r5]
63*344aa361SAndroid Build Coastguard Worker	dsb
64*344aa361SAndroid Build Coastguard Worker1:
65*344aa361SAndroid Build Coastguard Worker	wfi
66*344aa361SAndroid Build Coastguard Worker	ldr	lr, [r4]
67*344aa361SAndroid Build Coastguard Worker	cmp	lr, r5
68*344aa361SAndroid Build Coastguard Worker	beq	1b
69*344aa361SAndroid Build Coastguard Worker	tst	lr, lr
70*344aa361SAndroid Build Coastguard Worker	beq	1b
71*344aa361SAndroid Build Coastguard Worker
72*344aa361SAndroid Build Coastguard Worker	b	mon_initial_ns_return
73*344aa361SAndroid Build Coastguard Worker#endif
74*344aa361SAndroid Build Coastguard Worker
75*344aa361SAndroid Build Coastguard Worker.ltorg
76*344aa361SAndroid Build Coastguard Worker
77