blob: 61e182305738859e6e35d74688967a86bd49f923 [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
wdenk3d818262002-09-22 23:07:35 +000015#include <command.h>
Simon Glass1d91ba72019-11-14 12:57:37 -070016#include <cpu_func.h>
Simon Glass8f3f7612019-11-14 12:57:42 -070017#include <irq_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
Simon Glassf87959b2019-11-14 12:57:40 -070031 disable_interrupts();
wdenk3d818262002-09-22 23:07:35 +000032
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}