common: Move enable/disable_interrupts out of common.h
[oweals/u-boot.git] / arch / arm / cpu / sa1100 / cpu.c
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  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
9  * Alex Zuepke <azu@sysgo.de>
10  */
11
12 /*
13  * CPU specific code
14  */
15
16 #include <common.h>
17 #include <command.h>
18 #include <cpu_func.h>
19 #include <irq_func.h>
20 #include <asm/system.h>
21 #include <asm/io.h>
22
23 static void cache_flush(void);
24
25 int cleanup_before_linux (void)
26 {
27         /*
28          * this function is called just before we call linux
29          * it prepares the processor for linux
30          *
31          * just disable everything that can disturb booting linux
32          */
33
34         disable_interrupts();
35
36         /* turn off I-cache */
37         icache_disable();
38         dcache_disable();
39
40         /* flush I-cache */
41         cache_flush();
42
43         return (0);
44 }
45
46 /* flush I/D-cache */
47 static void cache_flush (void)
48 {
49         unsigned long i = 0;
50
51         asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i));
52 }
53
54 #define RST_BASE 0x90030000
55 #define RSRR    0x00
56 #define RCSR    0x04
57
58 __attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused)))
59 {
60         /* repeat endlessly */
61         while (1) {
62                 writel(0, RST_BASE + RCSR);
63                 writel(1, RST_BASE + RSRR);
64         }
65 }