blob: 980a734d1b351431f64b3c2df800a76609b2769c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk3d818262002-09-22 23:07:35 +00002/*
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 Zundelf1b3f2b2009-05-13 10:54:10 +02008 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk3d818262002-09-22 23:07:35 +00009 */
10
11/*
12 * CPU specific code
13 */
14
15#include <common.h>
16#include <command.h>
Simon Glass1d91ba72019-11-14 12:57:37 -070017#include <cpu_func.h>
Jean-Christophe PLAGNIOL-VILLARD9053b5a2009-04-05 13:02:43 +020018#include <asm/system.h>
wdenk3d818262002-09-22 23:07:35 +000019
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-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-VILLARDe6b5f1b2009-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-VILLARDe6b5f1b2009-04-05 13:06:31 +020037 cache_flush();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020038
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020039 return 0;
wdenk3d818262002-09-22 23:07:35 +000040}
41
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-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-VILLARDe6b5f1b2009-04-05 13:06:31 +020045 unsigned long i = 0;
wdenk3d818262002-09-22 23:07:35 +000046
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020047 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
wdenk3d818262002-09-22 23:07:35 +000048}