blob: a90ce3047bd27f2f100512ce6239073ac6c92fa9 [file] [log] [blame]
wdenk7eaacc52003-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 Zundelf1b3f2b2009-05-13 10:54:10 +02007 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk7eaacc52003-08-29 22:00:43 +00008 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenk7eaacc52003-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-VILLARD9053b5a2009-04-05 13:02:43 +020018#include <asm/system.h>
wdenk7eaacc52003-08-29 22:00:43 +000019
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020020static void cache_flush(void);
wdenk7eaacc52003-08-29 22:00:43 +000021
wdenk7eaacc52003-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
wdenk7eaacc52003-08-29 22:00:43 +000031 disable_interrupts ();
32
wdenk7eaacc52003-08-29 22:00:43 +000033
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020034 /* turn off I/D-cache */
35 icache_disable();
36 dcache_disable();
Michael Walle5ae3eec2012-02-06 22:42:10 +053037 l2_cache_disable();
38
wdenk7eaacc52003-08-29 22:00:43 +000039 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020040 cache_flush();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020041
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020042 return 0;
wdenk7eaacc52003-08-29 22:00:43 +000043}
44
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020045/* flush I/D-cache */
46static void cache_flush (void)
Hugo Villeneuve82a84372008-07-10 10:46:33 -040047{
Heiko Schocherb642d832014-11-18 09:41:56 +010048#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020049 unsigned long i = 0;
Hugo Villeneuve82a84372008-07-10 10:46:33 -040050
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020051 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
Heiko Schocherb642d832014-11-18 09:41:56 +010052#endif
wdenk7eaacc52003-08-29 22:00:43 +000053}