Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [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 |
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 8 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * CPU specific code |
| 13 | */ |
| 14 | |
| 15 | #include <common.h> |
| 16 | #include <command.h> |
Simon Glass | 9edefc2 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 17 | #include <cpu_func.h> |
Simon Glass | 36bf446 | 2019-11-14 12:57:42 -0700 | [diff] [blame] | 18 | #include <irq_func.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> |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 21 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 22 | static void cache_flush(void); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 23 | |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [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 | * we turn off caches etc ... |
| 31 | */ |
| 32 | |
Simon Glass | 9d3915b | 2019-11-14 12:57:40 -0700 | [diff] [blame] | 33 | disable_interrupts(); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 34 | |
Wolfgang Denk | fe7eb5d | 2005-09-25 02:00:47 +0200 | [diff] [blame] | 35 | /* ARM926E-S needs the protection unit enabled for the icache to have |
| 36 | * been enabled - left for possible later use |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 37 | * should turn off the protection unit as well.... |
Wolfgang Denk | fe7eb5d | 2005-09-25 02:00:47 +0200 | [diff] [blame] | 38 | */ |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 39 | /* turn off I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 40 | icache_disable(); |
| 41 | dcache_disable(); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 42 | /* flush I/D-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 43 | cache_flush(); |
| 44 | |
| 45 | return 0; |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 48 | /* flush I/D-cache */ |
| 49 | static void cache_flush (void) |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 50 | { |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 51 | unsigned long i = 0; |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 52 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame] | 53 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 54 | asm ("mcr p15, 0, %0, c7, c6, 0": :"r" (i)); |
Wolfgang Denk | 74f4304 | 2005-09-25 01:48:28 +0200 | [diff] [blame] | 55 | } |
Albert ARIBAUD | cd6cc34 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 56 | |
Masahiro Yamada | e702146 | 2015-04-21 21:59:38 +0900 | [diff] [blame] | 57 | #ifndef CONFIG_ARCH_INTEGRATOR |
Albert ARIBAUD | cd6cc34 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 58 | |
Harald Seiler | 35b65dd | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 59 | __attribute__((noreturn)) void reset_cpu(void) |
Albert ARIBAUD | cd6cc34 | 2014-04-15 16:13:48 +0200 | [diff] [blame] | 60 | { |
| 61 | writew(0x0, 0xfffece10); |
| 62 | writew(0x8, 0xfffece10); |
| 63 | for (;;) |
| 64 | ; |
| 65 | } |
| 66 | |
Masahiro Yamada | e702146 | 2015-04-21 21:59:38 +0900 | [diff] [blame] | 67 | #endif /* #ifdef CONFIG_ARCH_INTEGRATOR */ |