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> |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 17 | #include <asm/system.h> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 18 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 19 | static void cache_flush(void); |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 20 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 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 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 30 | disable_interrupts (); |
| 31 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 32 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 33 | /* turn off I/D-cache */ |
| 34 | icache_disable(); |
| 35 | dcache_disable(); |
Michael Walle | 5ae3eec | 2012-02-06 22:42:10 +0530 | [diff] [blame] | 36 | l2_cache_disable(); |
| 37 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 38 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 39 | cache_flush(); |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 40 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 41 | return 0; |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 44 | /* flush I/D-cache */ |
| 45 | static void cache_flush (void) |
Hugo Villeneuve | 82a8437 | 2008-07-10 10:46:33 -0400 | [diff] [blame] | 46 | { |
Heiko Schocher | b642d83 | 2014-11-18 09:41:56 +0100 | [diff] [blame] | 47 | #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 48 | unsigned long i = 0; |
Hugo Villeneuve | 82a8437 | 2008-07-10 10:46:33 -0400 | [diff] [blame] | 49 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 50 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); |
Heiko Schocher | b642d83 | 2014-11-18 09:41:56 +0100 | [diff] [blame] | 51 | #endif |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 52 | } |