xref: /openbmc/u-boot/arch/arm/cpu/armv8/cpu.c (revision 2a6713b0)
1 /*
2  * (C) Copyright 2008 Texas Insturments
3  *
4  * (C) Copyright 2002
5  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6  * Marius Groeger <mgroeger@sysgo.de>
7  *
8  * (C) Copyright 2002
9  * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
10  *
11  * SPDX-License-Identifier:	GPL-2.0+
12  */
13 
14 #include <common.h>
15 #include <command.h>
16 #include <asm/system.h>
17 #include <asm/secure.h>
18 #include <linux/compiler.h>
19 
20 int cleanup_before_linux(void)
21 {
22 	/*
23 	 * this function is called just before we call linux
24 	 * it prepares the processor for linux
25 	 *
26 	 * disable interrupt and turn off caches etc ...
27 	 */
28 	disable_interrupts();
29 
30 	/*
31 	 * Turn off I-cache and invalidate it
32 	 */
33 	icache_disable();
34 	invalidate_icache_all();
35 
36 	/*
37 	 * turn off D-cache
38 	 * dcache_disable() in turn flushes the d-cache and disables MMU
39 	 */
40 	dcache_disable();
41 	invalidate_dcache_all();
42 
43 	return 0;
44 }
45 
46 #ifdef CONFIG_ARMV8_PSCI
47 static void relocate_secure_section(void)
48 {
49 #ifdef CONFIG_ARMV8_SECURE_BASE
50 	size_t sz = __secure_end - __secure_start;
51 
52 	memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
53 	flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
54 			   CONFIG_ARMV8_SECURE_BASE + sz + 1);
55 	invalidate_icache_all();
56 #endif
57 }
58 
59 void armv8_setup_psci(void)
60 {
61 	relocate_secure_section();
62 	secure_ram_addr(psci_setup_vectors)();
63 	secure_ram_addr(psci_arch_init)();
64 }
65 #endif
66