Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 7eaacc5 | 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 | f1b3f2b | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 8 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
wdenk | 7eaacc5 | 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 | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 17 | #include <cpu_func.h> |
Simon Glass | 8f3f761 | 2019-11-14 12:57:42 -0700 | [diff] [blame] | 18 | #include <irq_func.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 19 | #include <asm/cache.h> |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 20 | #include <asm/system.h> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 21 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 22 | static void cache_flush(void); |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 23 | |
wdenk | 7eaacc5 | 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 | f87959b | 2019-11-14 12:57:40 -0700 | [diff] [blame] | 33 | disable_interrupts(); |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 34 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 35 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 36 | /* turn off I/D-cache */ |
37 | icache_disable(); | ||||
38 | dcache_disable(); | ||||
Michael Walle | 5ae3eec | 2012-02-06 22:42:10 +0530 | [diff] [blame] | 39 | l2_cache_disable(); |
40 | |||||
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 41 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 42 | cache_flush(); |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 43 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 44 | return 0; |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 45 | } |
46 | |||||
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 47 | /* flush I/D-cache */ |
48 | static void cache_flush (void) | ||||
Hugo Villeneuve | 82a8437 | 2008-07-10 10:46:33 -0400 | [diff] [blame] | 49 | { |
Trevor Woerner | 43ec7e0 | 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 | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 51 | unsigned long i = 0; |
Hugo Villeneuve | 82a8437 | 2008-07-10 10:46:33 -0400 | [diff] [blame] | 52 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 53 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); |
Heiko Schocher | b642d83 | 2014-11-18 09:41:56 +0100 | [diff] [blame] | 54 | #endif |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 55 | } |