Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 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> |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * CPU specific code |
| 14 | */ |
| 15 | |
| 16 | #include <common.h> |
| 17 | #include <command.h> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame^] | 18 | #include <cpu_func.h> |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 19 | #include <asm/system.h> |
Albert ARIBAUD | 21505f9 | 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 | e6b5f1b | 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 | e6b5f1b | 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 | e6b5f1b | 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 | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 45 | /* flush I/D-cache */ |
| 46 | static void cache_flush (void) |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 47 | { |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 48 | unsigned long i = 0; |
wdenk | 4a9cbbe | 2002-08-27 09:48:53 +0000 | [diff] [blame] | 49 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 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 | 21505f9 | 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 | } |