wdenk | 11a72d9 | 2002-10-27 22:25:25 +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 | * |
| 10 | * See file CREDITS for list of people who contributed to this |
| 11 | * project. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License as |
| 15 | * published by the Free Software Foundation; either version 2 of |
| 16 | * the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 26 | * MA 02111-1307 USA |
| 27 | */ |
| 28 | |
| 29 | /* |
| 30 | * CPU specific code |
| 31 | */ |
| 32 | |
| 33 | #include <common.h> |
| 34 | #include <command.h> |
| 35 | |
| 36 | int cpu_init (void) |
| 37 | { |
| 38 | /* |
| 39 | * setup up stack if necessary |
| 40 | */ |
| 41 | /* |
| 42 | |
| 43 | FIXME: the stack is _below_ the uboot code!! |
| 44 | |
| 45 | #ifdef CONFIG_USE_IRQ |
| 46 | IRQ_STACK_START = _armboot_end + |
| 47 | CONFIG_STACKSIZE + CONFIG_STACKSIZE_IRQ - 4; |
| 48 | FIQ_STACK_START = IRQ_STACK_START + CONFIG_STACKSIZE_FIQ; |
| 49 | _armboot_real_end = FIQ_STACK_START + 4; |
| 50 | #else |
| 51 | _armboot_real_end = _armboot_end + CONFIG_STACKSIZE; |
| 52 | #endif |
| 53 | */ |
| 54 | return (0); |
| 55 | } |
| 56 | |
| 57 | int cleanup_before_linux (void) |
| 58 | { |
| 59 | /* |
| 60 | * this function is called just before we call linux |
| 61 | * it prepares the processor for linux |
| 62 | * |
| 63 | * just disable everything that can disturb booting linux |
| 64 | */ |
| 65 | |
| 66 | unsigned long i; |
| 67 | |
| 68 | disable_interrupts (); |
| 69 | |
| 70 | /* turn off I-cache */ |
| 71 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 72 | i &= ~0x1000; |
| 73 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 74 | |
| 75 | /* flush I-cache */ |
| 76 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 77 | |
| 78 | return (0); |
| 79 | } |
| 80 | |
| 81 | int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 82 | { |
| 83 | extern void reset_cpu (ulong addr); |
| 84 | |
| 85 | printf ("reseting ...\n"); |
| 86 | |
| 87 | udelay (50000); /* wait 50 ms */ |
| 88 | disable_interrupts (); |
| 89 | reset_cpu (0); |
| 90 | |
| 91 | /*NOTREACHED*/ |
| 92 | return (0); |
| 93 | } |
| 94 | |
| 95 | /* taken from blob */ |
| 96 | void icache_enable (void) |
| 97 | { |
| 98 | register u32 i; |
| 99 | |
| 100 | /* read control register */ |
| 101 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 102 | |
| 103 | /* set i-cache */ |
| 104 | i |= 0x1000; |
| 105 | |
| 106 | /* write back to control register */ |
| 107 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 108 | } |
| 109 | |
| 110 | void icache_disable (void) |
| 111 | { |
| 112 | register u32 i; |
| 113 | |
| 114 | /* read control register */ |
| 115 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 116 | |
| 117 | /* clear i-cache */ |
| 118 | i &= ~0x1000; |
| 119 | |
| 120 | /* write back to control register */ |
| 121 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 122 | |
| 123 | /* flush i-cache */ |
| 124 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 125 | } |
| 126 | |
| 127 | int icache_status (void) |
| 128 | { |
| 129 | register u32 i; |
| 130 | |
| 131 | /* read control register */ |
| 132 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 133 | |
| 134 | /* return bit */ |
| 135 | return (i & 0x1000); |
| 136 | } |
| 137 | |
| 138 | /* we will never enable dcache, because we have to setup MMU first */ |
| 139 | void dcache_enable (void) |
| 140 | { |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | void dcache_disable (void) |
| 145 | { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | int dcache_status (void) |
| 150 | { |
| 151 | return 0; /* always off */ |
| 152 | } |