blob: 0c8d92d737a28f59a597ebf82310d7b5ea9e2f4f [file] [log] [blame]
Wolfgang Denk74f43042005-09-25 01:48:28 +02001/*
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 Zundel792a09e2009-05-13 10:54:10 +02007 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
Wolfgang Denk74f43042005-09-25 01:48:28 +02008 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02009 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk74f43042005-09-25 01:48:28 +020010 */
11
12/*
13 * CPU specific code
14 */
15
16#include <common.h>
17#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020018#include <asm/system.h>
Wolfgang Denk74f43042005-09-25 01:48:28 +020019
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020020static void cache_flush(void);
Wolfgang Denk74f43042005-09-25 01:48:28 +020021
Wolfgang Denk74f43042005-09-25 01:48:28 +020022int 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
Wolfgang Denk74f43042005-09-25 01:48:28 +020031 disable_interrupts ();
32
Wolfgang Denkfe7eb5d2005-09-25 02:00:47 +020033 /* ARM926E-S needs the protection unit enabled for the icache to have
34 * been enabled - left for possible later use
Wolfgang Denk74f43042005-09-25 01:48:28 +020035 * should turn off the protection unit as well....
Wolfgang Denkfe7eb5d2005-09-25 02:00:47 +020036 */
Wolfgang Denk74f43042005-09-25 01:48:28 +020037 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020038 icache_disable();
39 dcache_disable();
Wolfgang Denk74f43042005-09-25 01:48:28 +020040 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020041 cache_flush();
42
43 return 0;
Wolfgang Denk74f43042005-09-25 01:48:28 +020044}
45
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020046/* flush I/D-cache */
47static void cache_flush (void)
Wolfgang Denk74f43042005-09-25 01:48:28 +020048{
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020049 unsigned long i = 0;
Wolfgang Denk74f43042005-09-25 01:48:28 +020050
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020051 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
52 asm ("mcr p15, 0, %0, c7, c6, 0": :"r" (i));
Wolfgang Denk74f43042005-09-25 01:48:28 +020053}