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