2018-05-06 17:58:06 -04:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-08-29 22:00:43 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
|
|
|
* Marius Groeger <mgroeger@sysgo.de>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002
|
2009-05-13 10:54:10 +02:00
|
|
|
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
2003-08-29 22:00:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPU specific code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-11-14 12:57:37 -07:00
|
|
|
#include <cpu_func.h>
|
2019-11-14 12:57:42 -07:00
|
|
|
#include <irq_func.h>
|
2020-05-10 11:39:56 -06:00
|
|
|
#include <asm/cache.h>
|
2009-04-05 13:02:43 +02:00
|
|
|
#include <asm/system.h>
|
2003-08-29 22:00:43 +00:00
|
|
|
|
2009-04-05 13:06:31 +02:00
|
|
|
static void cache_flush(void);
|
2003-08-29 22:00:43 +00:00
|
|
|
|
2022-01-29 10:23:02 -05:00
|
|
|
/************************************************************
|
|
|
|
* sdelay() - simple spin loop. Will be constant time as
|
|
|
|
* its generally used in bypass conditions only. This
|
|
|
|
* is necessary until timers are accessible.
|
|
|
|
*
|
|
|
|
* not inline to increase chances its in cache when called
|
|
|
|
*************************************************************/
|
|
|
|
void sdelay(unsigned long loops)
|
|
|
|
{
|
|
|
|
__asm__ volatile ("1:\n" "subs %0, %1, #1\n"
|
|
|
|
"bne 1b":"=r" (loops):"0"(loops));
|
|
|
|
}
|
|
|
|
|
2003-08-29 22:00:43 +00:00
|
|
|
int cleanup_before_linux (void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* this function is called just before we call linux
|
|
|
|
* it prepares the processor for linux
|
|
|
|
*
|
|
|
|
* we turn off caches etc ...
|
|
|
|
*/
|
|
|
|
|
2019-11-14 12:57:40 -07:00
|
|
|
disable_interrupts();
|
2003-08-29 22:00:43 +00:00
|
|
|
|
|
|
|
|
2009-04-05 13:06:31 +02:00
|
|
|
/* turn off I/D-cache */
|
|
|
|
icache_disable();
|
|
|
|
dcache_disable();
|
2012-02-06 22:42:10 +05:30
|
|
|
l2_cache_disable();
|
|
|
|
|
2003-08-29 22:00:43 +00:00
|
|
|
/* flush I/D-cache */
|
2009-04-05 13:06:31 +02:00
|
|
|
cache_flush();
|
2005-09-25 01:48:28 +02:00
|
|
|
|
2009-04-05 13:06:31 +02:00
|
|
|
return 0;
|
2003-08-29 22:00:43 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 13:06:31 +02:00
|
|
|
/* flush I/D-cache */
|
|
|
|
static void cache_flush (void)
|
2008-07-10 10:46:33 -04:00
|
|
|
{
|
2019-05-03 09:41:00 -04:00
|
|
|
#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
|
2009-04-05 13:06:31 +02:00
|
|
|
unsigned long i = 0;
|
2008-07-10 10:46:33 -04:00
|
|
|
|
2009-04-05 13:06:31 +02:00
|
|
|
asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
|
arm, arm926ejs: make thumb mode compileable
in thumb mode compiler says for example for arch/arm/lib/cache-cp15.c
when enabling CONFIG_SYS_THUMB_BUILD:
{standard input}: Assembler messages:
{standard input}:373: Error: selected processor does not support Thumb mode `mrc p15,0,r4,c1,c0,0'
{standard input}:416: Error: selected processor does not support Thumb mode `mcr p15,0,r3,c2,c0,0'
so, if caches are disabled, do not use this command on arm926ejs.
used on at91 in SPL, to reduce size of SPL.
Signed-off-by: Heiko Schocher <hs@denx.de>
2014-11-18 09:41:56 +01:00
|
|
|
#endif
|
2003-08-29 22:00:43 +00:00
|
|
|
}
|