blob: fb0ea5e817ffdcdb4af562657d668d87591c241a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Wolfgang Denkadf20a12005-09-25 01:48:28 +02002/*
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>
Wolfgang Denkadf20a12005-09-25 01:48:28 +02009 */
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>
Albert ARIBAUD21505f92014-04-15 16:13:48 +020020#include <asm/io.h>
Wolfgang Denkadf20a12005-09-25 01:48:28 +020021
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020022static void cache_flush(void);
Wolfgang Denkadf20a12005-09-25 01:48:28 +020023
Wolfgang Denkadf20a12005-09-25 01:48:28 +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
Simon Glassf87959b2019-11-14 12:57:40 -070033 disable_interrupts();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020034
Wolfgang Denkc856ccc2005-09-25 02:00:47 +020035 /* ARM926E-S needs the protection unit enabled for the icache to have
36 * been enabled - left for possible later use
Wolfgang Denkadf20a12005-09-25 01:48:28 +020037 * should turn off the protection unit as well....
Wolfgang Denkc856ccc2005-09-25 02:00:47 +020038 */
Wolfgang Denkadf20a12005-09-25 01:48:28 +020039 /* turn off I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020040 icache_disable();
41 dcache_disable();
Wolfgang Denkadf20a12005-09-25 01:48:28 +020042 /* flush I/D-cache */
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020043 cache_flush();
44
45 return 0;
Wolfgang Denkadf20a12005-09-25 01:48:28 +020046}
47
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020048/* flush I/D-cache */
49static void cache_flush (void)
Wolfgang Denkadf20a12005-09-25 01:48:28 +020050{
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020051 unsigned long i = 0;
Wolfgang Denkadf20a12005-09-25 01:48:28 +020052
Jean-Christophe PLAGNIOL-VILLARDe6b5f1b2009-04-05 13:06:31 +020053 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
54 asm ("mcr p15, 0, %0, c7, c6, 0": :"r" (i));
Wolfgang Denkadf20a12005-09-25 01:48:28 +020055}
Albert ARIBAUD21505f92014-04-15 16:13:48 +020056
Masahiro Yamada665ab672015-04-21 21:59:38 +090057#ifndef CONFIG_ARCH_INTEGRATOR
Albert ARIBAUD21505f92014-04-15 16:13:48 +020058
59__attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused)))
60{
61 writew(0x0, 0xfffece10);
62 writew(0x8, 0xfffece10);
63 for (;;)
64 ;
65}
66
Masahiro Yamada665ab672015-04-21 21:59:38 +090067#endif /* #ifdef CONFIG_ARCH_INTEGRATOR */