wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 4 | * Marius Groeger <mgroeger@sysgo.de> |
| 5 | * |
| 6 | * (C) Copyright 2002 |
| 7 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 8 | * Alex Zuepke <azu@sysgo.de> |
| 9 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * CPU specific code |
| 15 | */ |
| 16 | |
| 17 | #include <common.h> |
| 18 | #include <command.h> |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 19 | #include <asm/system.h> |
Albert ARIBAUD | cd6cc34 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 20 | #include <asm/io.h> |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 21 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 22 | static void cache_flush(void); |
| 23 | |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 24 | int 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 | * just disable everything that can disturb booting linux |
| 31 | */ |
| 32 | |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 33 | disable_interrupts (); |
| 34 | |
| 35 | /* turn off I-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 36 | icache_disable(); |
| 37 | dcache_disable(); |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 38 | |
| 39 | /* flush I-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 40 | cache_flush(); |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 41 | |
| 42 | return (0); |
| 43 | } |
| 44 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 45 | /* flush I/D-cache */ |
| 46 | static void cache_flush (void) |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 47 | { |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 48 | unsigned long i = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 49 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 50 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 51 | } |
Albert ARIBAUD | cd6cc34 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 52 | |
| 53 | #define RST_BASE 0x90030000 |
| 54 | #define RSRR 0x00 |
| 55 | #define RCSR 0x04 |
| 56 | |
| 57 | __attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused))) |
| 58 | { |
| 59 | /* repeat endlessly */ |
| 60 | while (1) { |
| 61 | writel(0, RST_BASE + RCSR); |
| 62 | writel(1, RST_BASE + RSRR); |
| 63 | } |
| 64 | } |