blob: 6651898de235925b824f09cc409d80505650f7ac [file] [log] [blame]
wdenk4a9cbbe2002-08-27 09:48:53 +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
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Alex Zuepke <azu@sysgo.de>
9 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020010 * SPDX-License-Identifier: GPL-2.0+
wdenk4a9cbbe2002-08-27 09:48:53 +000011 */
12
13/*
14 * CPU specific code
15 */
16
17#include <common.h>
18#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020019#include <asm/system.h>
wdenk4a9cbbe2002-08-27 09:48:53 +000020
Wolfgang Denkd87080b2006-03-31 18:32:53 +020021#ifdef CONFIG_USE_IRQ
22DECLARE_GLOBAL_DATA_PTR;
23#endif
24
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020025static void cache_flush(void);
26
wdenk4a9cbbe2002-08-27 09:48:53 +000027int cleanup_before_linux (void)
28{
29 /*
30 * this function is called just before we call linux
31 * it prepares the processor for linux
32 *
33 * just disable everything that can disturb booting linux
34 */
35
wdenk4a9cbbe2002-08-27 09:48:53 +000036 disable_interrupts ();
37
38 /* turn off I-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020039 icache_disable();
40 dcache_disable();
wdenk4a9cbbe2002-08-27 09:48:53 +000041
42 /* flush I-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020043 cache_flush();
wdenk4a9cbbe2002-08-27 09:48:53 +000044
45 return (0);
46}
47
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020048/* flush I/D-cache */
49static void cache_flush (void)
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020050{
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020051 unsigned long i = 0;
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020052
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020053 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
wdenk4a9cbbe2002-08-27 09:48:53 +000054}