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/cache.h>
18 #include <asm/system.h>
19 #include <asm/secure.h>
20 #include <linux/compiler.h>
23 * sdelay() - simple spin loop.
25 * Will delay execution by roughly (@loops * 2) cycles.
26 * This is necessary to be used before timers are accessible.
28 * A value of "0" will results in 2^64 loops.
30 void sdelay(unsigned long loops)
32 __asm__ volatile ("1:\n" "subs %0, %0, #1\n"
33 "b.ne 1b" : "=r" (loops) : "0"(loops) : "cc");
36 void __weak board_cleanup_before_linux(void){}
38 int cleanup_before_linux(void)
41 * this function is called just before we call linux
42 * it prepares the processor for linux
44 * disable interrupt and turn off caches etc ...
47 board_cleanup_before_linux();
52 * Turn off I-cache and invalidate it
55 invalidate_icache_all();
59 * dcache_disable() in turn flushes the d-cache and disables MMU
62 invalidate_dcache_all();
67 #ifdef CONFIG_ARMV8_PSCI
68 static void relocate_secure_section(void)
70 #ifdef CONFIG_ARMV8_SECURE_BASE
71 size_t sz = __secure_end - __secure_start;
73 memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
74 flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
75 CONFIG_ARMV8_SECURE_BASE + sz + 1);
76 invalidate_icache_all();
80 void armv8_setup_psci(void)
82 relocate_secure_section();
83 secure_ram_addr(psci_setup_vectors)();
84 secure_ram_addr(psci_arch_init)();