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>
15 #include <asm/system.h>
16 #include <asm/secure.h>
17 #include <linux/compiler.h>
20 * sdelay() - simple spin loop.
22 * Will delay execution by roughly (@loops * 2) cycles.
23 * This is necessary to be used before timers are accessible.
25 * A value of "0" will results in 2^64 loops.
27 void sdelay(unsigned long loops)
29 __asm__ volatile ("1:\n" "subs %0, %0, #1\n"
30 "b.ne 1b" : "=r" (loops) : "0"(loops) : "cc");
33 int cleanup_before_linux(void)
36 * this function is called just before we call linux
37 * it prepares the processor for linux
39 * disable interrupt and turn off caches etc ...
44 * Turn off I-cache and invalidate it
47 invalidate_icache_all();
51 * dcache_disable() in turn flushes the d-cache and disables MMU
54 invalidate_dcache_all();
59 #ifdef CONFIG_ARMV8_PSCI
60 static void relocate_secure_section(void)
62 #ifdef CONFIG_ARMV8_SECURE_BASE
63 size_t sz = __secure_end - __secure_start;
65 memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
66 flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
67 CONFIG_ARMV8_SECURE_BASE + sz + 1);
68 invalidate_icache_all();
72 void armv8_setup_psci(void)
74 relocate_secure_section();
75 secure_ram_addr(psci_setup_vectors)();
76 secure_ram_addr(psci_arch_init)();