wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 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 | ||||
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 7 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 10 | */ |
11 | |||||
12 | /* | ||||
13 | * CPU specific code | ||||
14 | */ | ||||
15 | |||||
16 | #include <common.h> | ||||
17 | #include <command.h> | ||||
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 18 | #include <asm/system.h> |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 19 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 20 | static void cache_flush(void); |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 21 | |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 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 | |||||
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 31 | disable_interrupts (); |
32 | |||||
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 33 | |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 34 | /* turn off I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 35 | icache_disable(); |
36 | dcache_disable(); | ||||
Michael Walle | 6795302 | 2012-02-06 22:42:10 +0530 | [diff] [blame] | 37 | l2_cache_disable(); |
38 | |||||
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 39 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 40 | cache_flush(); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 41 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 42 | return 0; |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 43 | } |
44 | |||||
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 45 | /* flush I/D-cache */ |
46 | static void cache_flush (void) | ||||
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 47 | { |
Heiko Schocher | 99197a9 | 2014-11-18 09:41:56 +0100 | [diff] [blame^] | 48 | #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 49 | unsigned long i = 0; |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 50 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 51 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); |
Heiko Schocher | 99197a9 | 2014-11-18 09:41:56 +0100 | [diff] [blame^] | 52 | #endif |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 53 | } |