Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 Texas Insturments |
| 3 | * |
| 4 | * (C) Copyright 2002 |
| 5 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 6 | * Marius Groeger <mgroeger@sysgo.de> |
| 7 | * |
| 8 | * (C) Copyright 2002 |
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 9 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * CPU specific code |
| 16 | */ |
| 17 | |
| 18 | #include <common.h> |
| 19 | #include <command.h> |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 20 | #include <asm/system.h> |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 21 | |
| 22 | static void cache_flush (void); |
| 23 | |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [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 | |
| 33 | disable_interrupts (); |
| 34 | |
| 35 | /* turn off I/D-cache */ |
| 36 | icache_disable(); |
| 37 | dcache_disable(); |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 38 | /* flush I/D-cache */ |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 39 | cache_flush(); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
Guennadi Liakhovetski | 9b07773 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 44 | /* flush I/D-cache */ |
| 45 | static void cache_flush (void) |
| 46 | { |
| 47 | /* invalidate both caches and flush btb */ |
| 48 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (0)); |
| 49 | /* mem barrier to sync things */ |
| 50 | asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0)); |
| 51 | } |