xref: /openbmc/u-boot/arch/arm/cpu/arm926ejs/cpu.c (revision 9702ec00)
1 /*
2  * (C) Copyright 2002
3  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4  * Marius Groeger <mgroeger@sysgo.de>
5  *
6  * (C) Copyright 2002
7  * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
8  *
9  * SPDX-License-Identifier:	GPL-2.0+
10  */
11 
12 /*
13  * CPU specific code
14  */
15 
16 #include <common.h>
17 #include <command.h>
18 #include <asm/system.h>
19 
20 static void cache_flush(void);
21 
22 int cleanup_before_linux (void)
23 {
24 	/*
25 	 * this function is called just before we call linux
26 	 * it prepares the processor for linux
27 	 *
28 	 * we turn off caches etc ...
29 	 */
30 
31 	disable_interrupts ();
32 
33 
34 	/* turn off I/D-cache */
35 	icache_disable();
36 	dcache_disable();
37 	l2_cache_disable();
38 
39 	/* flush I/D-cache */
40 	cache_flush();
41 
42 	return 0;
43 }
44 
45 /* flush I/D-cache */
46 static void cache_flush (void)
47 {
48 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
49 	unsigned long i = 0;
50 
51 	asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
52 #endif
53 }
54