blob: 2ef133f13310045725560a03f0ee355b6b9c9b16 [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>
Jean-Christophe PLAGNIOL-VILLARD9053b5a2009-04-05 13:02:43 +020017#include <asm/system.h>
wdenk3d818262002-09-22 23:07:35 +000018
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020019static void cache_flush(void);
wdenk3d818262002-09-22 23:07:35 +000020
wdenk3d818262002-09-22 23:07:35 +000021int 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
wdenk3d818262002-09-22 23:07:35 +000030 disable_interrupts ();
31
32 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020033 icache_disable();
34 dcache_disable();
wdenk3d818262002-09-22 23:07:35 +000035 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020036 cache_flush();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020037
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020038 return 0;
wdenk3d818262002-09-22 23:07:35 +000039}
40
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020041/* flush I/D-cache */
42static void cache_flush (void)
wdenk3d818262002-09-22 23:07:35 +000043{
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020044 unsigned long i = 0;
wdenk3d818262002-09-22 23:07:35 +000045
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020046 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
wdenk3d818262002-09-22 23:07:35 +000047}