blob: d73b51dced897a0eb5cc785e1f9a9aa9ee8257e1 [file] [log] [blame]
wdenk3d818262002-09-22 23:07:35 +00001/*
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 Zundel792a09e2009-05-13 10:54:10 +02007 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk3d818262002-09-22 23:07:35 +00008 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenk3d818262002-09-22 23:07:35 +000010 */
11
12/*
13 * CPU specific code
14 */
15
16#include <common.h>
17#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020018#include <asm/system.h>
wdenk3d818262002-09-22 23:07:35 +000019
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020020static void cache_flush(void);
wdenk3d818262002-09-22 23:07:35 +000021
wdenk3d818262002-09-22 23:07:35 +000022int 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
wdenk3d818262002-09-22 23:07:35 +000031 disable_interrupts ();
32
33 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020034 icache_disable();
35 dcache_disable();
wdenk3d818262002-09-22 23:07:35 +000036 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020037 cache_flush();
Wolfgang Denk74f43042005-09-25 01:48:28 +020038
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020039 return 0;
wdenk3d818262002-09-22 23:07:35 +000040}
41
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020042/* flush I/D-cache */
43static void cache_flush (void)
wdenk3d818262002-09-22 23:07:35 +000044{
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020045 unsigned long i = 0;
wdenk3d818262002-09-22 23:07:35 +000046
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020047 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
wdenk3d818262002-09-22 23:07:35 +000048}