1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2008 Texas Insturments
6 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Marius Groeger <mgroeger@sysgo.de>
10 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
17 #include <asm/system.h>
18 #include <asm/secure.h>
19 #include <linux/compiler.h>
22 * sdelay() - simple spin loop.
24 * Will delay execution by roughly (@loops * 2) cycles.
25 * This is necessary to be used before timers are accessible.
27 * A value of "0" will results in 2^64 loops.
29 void sdelay(unsigned long loops)
31 __asm__ volatile ("1:\n" "subs %0, %0, #1\n"
32 "b.ne 1b" : "=r" (loops) : "0"(loops) : "cc");
35 void __weak board_cleanup_before_linux(void){}
37 int cleanup_before_linux(void)
40 * this function is called just before we call linux
41 * it prepares the processor for linux
43 * disable interrupt and turn off caches etc ...
46 board_cleanup_before_linux();
51 * Turn off I-cache and invalidate it
54 invalidate_icache_all();
58 * dcache_disable() in turn flushes the d-cache and disables MMU
61 invalidate_dcache_all();
66 #ifdef CONFIG_ARMV8_PSCI
67 static void relocate_secure_section(void)
69 #ifdef CONFIG_ARMV8_SECURE_BASE
70 size_t sz = __secure_end - __secure_start;
72 memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
73 flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
74 CONFIG_ARMV8_SECURE_BASE + sz + 1);
75 invalidate_icache_all();
79 void armv8_setup_psci(void)
81 relocate_secure_section();
82 secure_ram_addr(psci_setup_vectors)();
83 secure_ram_addr(psci_arch_init)();