blob: 2d816512154d51eb4083d696acc9cdb91ee5c4b6 [file] [log] [blame]
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +02001/*
2 * (C) Copyright 2004 Texas Insturments
3 *
4 * (C) Copyright 2002
5 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Marius Groeger <mgroeger@sysgo.de>
7 *
8 * (C) Copyright 2002
Detlev Zundel792a09e2009-05-13 10:54:10 +02009 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020010 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020012 */
13
14/*
15 * CPU specific code
16 */
17
18#include <common.h>
19#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD677e62f2009-04-05 13:02:43 +020020#include <asm/system.h>
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020021
22static void cache_flush (void);
23
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020024int cleanup_before_linux (void)
25{
26 /*
27 * this function is called just before we call linux
28 * it prepares the processor for linux
29 *
30 * we turn off caches etc ...
31 */
32
33 disable_interrupts ();
34
35 /* turn off I/D-cache */
36 icache_disable();
37 dcache_disable();
Jean-Christophe PLAGNIOL-VILLARDb3acb6c2009-04-05 13:06:31 +020038 /* flush I/D-cache */
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020039 cache_flush();
40
41 return 0;
42}
43
Guennadi Liakhovetski9b077732008-08-31 00:39:46 +020044/* flush I/D-cache */
45static void cache_flush (void)
46{
47 /* invalidate both caches and flush btb */
48 asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (0));
49 /* mem barrier to sync things */
50 asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0));
51}