blob: c3f1ee1fd102cd614d3cee5ee6b65f2752d82495 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk7eaacc52003-08-29 22:00:43 +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>
wdenk7eaacc52003-08-29 22:00:43 +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>
wdenk7eaacc52003-08-29 22:00:43 +000018
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020019static void cache_flush(void);
wdenk7eaacc52003-08-29 22:00:43 +000020
wdenk7eaacc52003-08-29 22:00:43 +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
wdenk7eaacc52003-08-29 22:00:43 +000030 disable_interrupts ();
31
wdenk7eaacc52003-08-29 22:00:43 +000032
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020033 /* turn off I/D-cache */
34 icache_disable();
35 dcache_disable();
Michael Walle5ae3eec2012-02-06 22:42:10 +053036 l2_cache_disable();
37
wdenk7eaacc52003-08-29 22:00:43 +000038 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020039 cache_flush();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020040
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020041 return 0;
wdenk7eaacc52003-08-29 22:00:43 +000042}
43
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020044/* flush I/D-cache */
45static void cache_flush (void)
Hugo Villeneuve82a84372008-07-10 10:46:33 -040046{
Heiko Schocherb642d832014-11-18 09:41:56 +010047#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020048 unsigned long i = 0;
Hugo Villeneuve82a84372008-07-10 10:46:33 -040049
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020050 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
Heiko Schocherb642d832014-11-18 09:41:56 +010051#endif
wdenk7eaacc52003-08-29 22:00:43 +000052}