blob: e37e87b68d14d394dfdb9980cbca40345f5ccc52 [file] [log] [blame]
wdenk6f213472003-08-29 22:00:43 +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>
wdenk6f213472003-08-29 22:00:43 +00008 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenk6f213472003-08-29 22:00:43 +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>
wdenk6f213472003-08-29 22:00:43 +000019
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020020static void cache_flush(void);
wdenk6f213472003-08-29 22:00:43 +000021
wdenk6f213472003-08-29 22:00:43 +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
wdenk6f213472003-08-29 22:00:43 +000031 disable_interrupts ();
32
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020033
wdenk6f213472003-08-29 22:00:43 +000034 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020035 icache_disable();
36 dcache_disable();
Michael Walle67953022012-02-06 22:42:10 +053037 l2_cache_disable();
38
wdenk6f213472003-08-29 22:00:43 +000039 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020040 cache_flush();
Wolfgang Denk74f43042005-09-25 01:48:28 +020041
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020042 return 0;
wdenk6f213472003-08-29 22:00:43 +000043}
44
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020045/* flush I/D-cache */
46static void cache_flush (void)
wdenk6f213472003-08-29 22:00:43 +000047{
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020048 unsigned long i = 0;
wdenk6f213472003-08-29 22:00:43 +000049
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020050 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
wdenk6f213472003-08-29 22:00:43 +000051}