blob: 305713e78615ac058d20dcde5abea2aa98756bd0 [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>
Simon Glass8f3f7612019-11-14 12:57:42 -070018#include <irq_func.h>
Jean-Christophe PLAGNIOL-VILLARD9053b5a2009-04-05 13:02:43 +020019#include <asm/system.h>
wdenk3d818262002-09-22 23:07:35 +000020
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020021static void cache_flush(void);
wdenk3d818262002-09-22 23:07:35 +000022
wdenk3d818262002-09-22 23:07:35 +000023int cleanup_before_linux (void)
24{
25 /*
26 * this function is called just before we call linux
27 * it prepares the processor for linux
28 *
29 * we turn off caches etc ...
30 */
31
Simon Glassf87959b2019-11-14 12:57:40 -070032 disable_interrupts();
wdenk3d818262002-09-22 23:07:35 +000033
34 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020035 icache_disable();
36 dcache_disable();
wdenk3d818262002-09-22 23:07:35 +000037 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020038 cache_flush();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020039
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020040 return 0;
wdenk3d818262002-09-22 23:07:35 +000041}
42
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020043/* flush I/D-cache */
44static void cache_flush (void)
wdenk3d818262002-09-22 23:07:35 +000045{
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020046 unsigned long i = 0;
wdenk3d818262002-09-22 23:07:35 +000047
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020048 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
wdenk3d818262002-09-22 23:07:35 +000049}