1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2002
4 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
5 * Marius Groeger <mgroeger@sysgo.de>
6 *
7 * (C) Copyright 2002
8 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
9 */
10
11/*
12 * CPU specific code
13 */
14
15#include <common.h>
16#include <command.h>
17#include <cpu_func.h>
18#include <irq_func.h>
19#include <asm/system.h>
20#include <asm/io.h>
21
22static void cache_flush(void);
23
24int 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	/* ARM926E-S needs the protection unit enabled for the icache to have
36	 * been enabled	 - left for possible later use
37	 * should turn off the protection unit as well....
38	 */
39	/* turn off I/D-cache */
40	icache_disable();
41	dcache_disable();
42	/* flush I/D-cache */
43	cache_flush();
44
45	return 0;
46}
47
48/* flush I/D-cache */
49static void cache_flush (void)
50{
51	unsigned long i = 0;
52
53	asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
54	asm ("mcr p15, 0, %0, c7, c6, 0": :"r" (i));
55}
56
57#ifndef CONFIG_ARCH_INTEGRATOR
58
59__attribute__((noreturn)) void reset_cpu(void)
60{
61	writew(0x0, 0xfffece10);
62	writew(0x8, 0xfffece10);
63	for (;;)
64		;
65}
66
67#endif	/* #ifdef CONFIG_ARCH_INTEGRATOR */
68