2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-12-14 03:47:35 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2008 Texas Insturments
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
|
|
|
* Marius Groeger <mgroeger@sysgo.de>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2019-11-14 19:57:42 +00:00
|
|
|
#include <irq_func.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2013-12-14 03:47:35 +00:00
|
|
|
#include <asm/system.h>
|
2016-12-08 03:58:25 +00:00
|
|
|
#include <asm/secure.h>
|
2013-12-14 03:47:35 +00:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2017-01-02 11:48:32 +00:00
|
|
|
/*
|
|
|
|
* sdelay() - simple spin loop.
|
|
|
|
*
|
|
|
|
* Will delay execution by roughly (@loops * 2) cycles.
|
|
|
|
* This is necessary to be used before timers are accessible.
|
|
|
|
*
|
|
|
|
* A value of "0" will results in 2^64 loops.
|
|
|
|
*/
|
|
|
|
void sdelay(unsigned long loops)
|
|
|
|
{
|
|
|
|
__asm__ volatile ("1:\n" "subs %0, %0, #1\n"
|
|
|
|
"b.ne 1b" : "=r" (loops) : "0"(loops) : "cc");
|
|
|
|
}
|
|
|
|
|
2020-03-26 23:10:09 +00:00
|
|
|
void __weak board_cleanup_before_linux(void){}
|
|
|
|
|
2013-12-14 03:47:35 +00:00
|
|
|
int cleanup_before_linux(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* this function is called just before we call linux
|
|
|
|
* it prepares the processor for linux
|
|
|
|
*
|
|
|
|
* disable interrupt and turn off caches etc ...
|
|
|
|
*/
|
2020-03-26 23:10:09 +00:00
|
|
|
|
|
|
|
board_cleanup_before_linux();
|
|
|
|
|
2013-12-14 03:47:35 +00:00
|
|
|
disable_interrupts();
|
|
|
|
|
2023-02-08 20:54:27 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CMO_BY_VA_ONLY)) {
|
|
|
|
/*
|
|
|
|
* Disable D-cache.
|
|
|
|
*/
|
|
|
|
dcache_disable();
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Turn off I-cache and invalidate it
|
|
|
|
*/
|
|
|
|
icache_disable();
|
|
|
|
invalidate_icache_all();
|
2013-12-14 03:47:35 +00:00
|
|
|
|
2023-02-08 20:54:27 +00:00
|
|
|
/*
|
|
|
|
* turn off D-cache
|
|
|
|
* dcache_disable() in turn flushes the d-cache and disables
|
|
|
|
* MMU
|
|
|
|
*/
|
|
|
|
dcache_disable();
|
|
|
|
invalidate_dcache_all();
|
|
|
|
}
|
2013-12-14 03:47:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-12-08 03:58:25 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARMV8_PSCI
|
|
|
|
static void relocate_secure_section(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_ARMV8_SECURE_BASE
|
|
|
|
size_t sz = __secure_end - __secure_start;
|
|
|
|
|
|
|
|
memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
|
|
|
|
flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
|
|
|
|
CONFIG_ARMV8_SECURE_BASE + sz + 1);
|
|
|
|
invalidate_icache_all();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void armv8_setup_psci(void)
|
|
|
|
{
|
2022-02-28 12:48:39 +00:00
|
|
|
if (current_el() != 3)
|
|
|
|
return;
|
|
|
|
|
2016-12-08 03:58:25 +00:00
|
|
|
relocate_secure_section();
|
|
|
|
secure_ram_addr(psci_setup_vectors)();
|
|
|
|
secure_ram_addr(psci_arch_init)();
|
|
|
|
}
|
|
|
|
#endif
|