Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [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 |
Detlev Zundel | f1b3f2b | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 7 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 8 | * |
Wolfgang Denk | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * CPU specific code |
| 14 | */ |
| 15 | |
| 16 | #include <common.h> |
| 17 | #include <command.h> |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 18 | #include <asm/system.h> |
Albert ARIBAUD | 21505f9 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 19 | #include <asm/io.h> |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 20 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 21 | static void cache_flush(void); |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 22 | |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 23 | int cleanup_before_linux (void) |
| 24 | { |
| 25 | /* |
| 26 | * this function is called just before we call linux |
| 27 | * it prepares the processor for linux |
| 28 | * |
| 29 | * we turn off caches etc ... |
| 30 | */ |
| 31 | |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 32 | disable_interrupts (); |
| 33 | |
Wolfgang Denk | c856ccc | 2005-09-25 02:00:47 +0200 | [diff] [blame] | 34 | /* ARM926E-S needs the protection unit enabled for the icache to have |
| 35 | * been enabled - left for possible later use |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 36 | * should turn off the protection unit as well.... |
Wolfgang Denk | c856ccc | 2005-09-25 02:00:47 +0200 | [diff] [blame] | 37 | */ |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 38 | /* turn off I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 39 | icache_disable(); |
| 40 | dcache_disable(); |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 41 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 42 | cache_flush(); |
| 43 | |
| 44 | return 0; |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 47 | /* flush I/D-cache */ |
| 48 | static void cache_flush (void) |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 49 | { |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 50 | unsigned long i = 0; |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 51 | |
Jean-Christophe PLAGNIOL-VILLARD | e6b5f1b | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 52 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 53 | asm ("mcr p15, 0, %0, c7, c6, 0": :"r" (i)); |
Wolfgang Denk | adf20a1 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 54 | } |
Albert ARIBAUD | 21505f9 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 55 | |
Masahiro Yamada | 665ab67 | 2015-04-21 21:59:38 +0900 | [diff] [blame] | 56 | #ifndef CONFIG_ARCH_INTEGRATOR |
Albert ARIBAUD | 21505f9 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 57 | |
| 58 | __attribute__((noreturn)) void reset_cpu(ulong addr __attribute__((unused))) |
| 59 | { |
| 60 | writew(0x0, 0xfffece10); |
| 61 | writew(0x8, 0xfffece10); |
| 62 | for (;;) |
| 63 | ; |
| 64 | } |
| 65 | |
Masahiro Yamada | 665ab67 | 2015-04-21 21:59:38 +0900 | [diff] [blame] | 66 | #endif /* #ifdef CONFIG_ARCH_INTEGRATOR */ |