Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 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 | ||||
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 8 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 9 | */ |
10 | |||||
11 | /* | ||||
12 | * CPU specific code | ||||
13 | */ | ||||
14 | |||||
15 | #include <common.h> | ||||
16 | #include <command.h> | ||||
Simon Glass | 9edefc2 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 17 | #include <cpu_func.h> |
Simon Glass | 36bf446 | 2019-11-14 12:57:42 -0700 | [diff] [blame] | 18 | #include <irq_func.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 19 | #include <asm/cache.h> |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 20 | #include <asm/system.h> |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 21 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 22 | static void cache_flush(void); |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 23 | |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 24 | int cleanup_before_linux (void) |
25 | { | ||||
26 | /* | ||||
27 | * this function is called just before we call linux | ||||
28 | * it prepares the processor for linux | ||||
29 | * | ||||
30 | * we turn off caches etc ... | ||||
31 | */ | ||||
32 | |||||
Simon Glass | 9d3915b | 2019-11-14 12:57:40 -0700 | [diff] [blame] | 33 | disable_interrupts(); |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 34 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 35 | |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 36 | /* turn off I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 37 | icache_disable(); |
38 | dcache_disable(); | ||||
Michael Walle | 6795302 | 2012-02-06 22:42:10 +0530 | [diff] [blame] | 39 | l2_cache_disable(); |
40 | |||||
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 41 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 42 | cache_flush(); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 43 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 44 | return 0; |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 45 | } |
46 | |||||
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 47 | /* flush I/D-cache */ |
48 | static void cache_flush (void) | ||||
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 49 | { |
Trevor Woerner | 1001502 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 50 | #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 51 | unsigned long i = 0; |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 52 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 53 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); |
Heiko Schocher | 99197a9 | 2014-11-18 09:41:56 +0100 | [diff] [blame] | 54 | #endif |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 55 | } |