wdenk | 2d5b561 | 2003-10-14 19:43:55 +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> |
Ben Warren | cc94074 | 2008-09-05 01:55:22 -0400 | [diff] [blame] | 35 | #include <netdev.h> |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 36 | #include <asm/arch/ixp425.h> |
| 37 | |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 38 | ulong loops_per_jiffy; |
| 39 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 40 | #ifdef CONFIG_USE_IRQ |
| 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | #endif |
| 43 | |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 44 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 45 | int print_cpuinfo (void) |
| 46 | { |
| 47 | unsigned long id; |
| 48 | int speed = 0; |
| 49 | |
| 50 | asm ("mrc p15, 0, %0, c0, c0, 0":"=r" (id)); |
| 51 | |
| 52 | puts("CPU: Intel IXP425 at "); |
| 53 | switch ((id & 0x000003f0) >> 4) { |
| 54 | case 0x1c: |
| 55 | loops_per_jiffy = 887467; |
| 56 | speed = 533; |
| 57 | break; |
| 58 | |
| 59 | case 0x1d: |
| 60 | loops_per_jiffy = 666016; |
| 61 | speed = 400; |
| 62 | break; |
| 63 | |
| 64 | case 0x1f: |
| 65 | loops_per_jiffy = 442901; |
| 66 | speed = 266; |
| 67 | break; |
| 68 | } |
| 69 | |
| 70 | if (speed) |
| 71 | printf("%d MHz\n", speed); |
| 72 | else |
| 73 | puts("unknown revision\n"); |
| 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
| 78 | |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 79 | int cpu_init (void) |
| 80 | { |
| 81 | /* |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 82 | * setup up stacks if necessary |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 83 | */ |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 84 | #ifdef CONFIG_USE_IRQ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4; |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 86 | FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ; |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 87 | #endif |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 88 | |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | int cleanup_before_linux (void) |
| 93 | { |
| 94 | /* |
| 95 | * this function is called just before we call linux |
| 96 | * it prepares the processor for linux |
| 97 | * |
| 98 | * just disable everything that can disturb booting linux |
| 99 | */ |
| 100 | |
| 101 | unsigned long i; |
| 102 | |
| 103 | disable_interrupts (); |
| 104 | |
| 105 | /* turn off I-cache */ |
| 106 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 107 | i &= ~0x1000; |
| 108 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 109 | |
| 110 | /* flush I-cache */ |
| 111 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 112 | |
| 113 | return (0); |
| 114 | } |
| 115 | |
| 116 | int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 117 | { |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 118 | printf ("resetting ...\n"); |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 119 | |
| 120 | udelay (50000); /* wait 50 ms */ |
| 121 | disable_interrupts (); |
| 122 | reset_cpu (0); |
| 123 | |
| 124 | /*NOTREACHED*/ |
| 125 | return (0); |
| 126 | } |
| 127 | |
| 128 | /* taken from blob */ |
| 129 | void icache_enable (void) |
| 130 | { |
| 131 | register u32 i; |
| 132 | |
| 133 | /* read control register */ |
| 134 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 135 | |
| 136 | /* set i-cache */ |
| 137 | i |= 0x1000; |
| 138 | |
| 139 | /* write back to control register */ |
| 140 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 141 | } |
| 142 | |
| 143 | void icache_disable (void) |
| 144 | { |
| 145 | register u32 i; |
| 146 | |
| 147 | /* read control register */ |
| 148 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 149 | |
| 150 | /* clear i-cache */ |
| 151 | i &= ~0x1000; |
| 152 | |
| 153 | /* write back to control register */ |
| 154 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 155 | |
| 156 | /* flush i-cache */ |
| 157 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
| 158 | } |
| 159 | |
| 160 | int icache_status (void) |
| 161 | { |
| 162 | register u32 i; |
| 163 | |
| 164 | /* read control register */ |
| 165 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
| 166 | |
| 167 | /* return bit */ |
| 168 | return (i & 0x1000); |
| 169 | } |
| 170 | |
| 171 | /* we will never enable dcache, because we have to setup MMU first */ |
| 172 | void dcache_enable (void) |
| 173 | { |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | void dcache_disable (void) |
| 178 | { |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | int dcache_status (void) |
| 183 | { |
| 184 | return 0; /* always off */ |
| 185 | } |
| 186 | |
| 187 | /* FIXME */ |
wdenk | a119190 | 2005-01-09 17:12:27 +0000 | [diff] [blame] | 188 | /* |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 189 | void pci_init(void) |
| 190 | { |
| 191 | return; |
| 192 | } |
wdenk | a119190 | 2005-01-09 17:12:27 +0000 | [diff] [blame] | 193 | */ |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 194 | |
| 195 | #ifdef CONFIG_BOOTCOUNT_LIMIT |
| 196 | |
| 197 | void bootcount_store (ulong a) |
| 198 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 199 | volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 200 | |
| 201 | save_addr[0] = a; |
| 202 | save_addr[1] = BOOTCOUNT_MAGIC; |
| 203 | } |
| 204 | |
| 205 | ulong bootcount_load (void) |
| 206 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 207 | volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 208 | |
| 209 | if (save_addr[1] != BOOTCOUNT_MAGIC) |
| 210 | return 0; |
| 211 | else |
| 212 | return save_addr[0]; |
| 213 | } |
| 214 | |
| 215 | #endif /* CONFIG_BOOTCOUNT_LIMIT */ |
Ben Warren | cc94074 | 2008-09-05 01:55:22 -0400 | [diff] [blame] | 216 | |
| 217 | int cpu_eth_init(bd_t *bis) |
| 218 | { |
| 219 | #ifdef CONFIG_IXP4XX_NPE |
| 220 | npe_initialize(bis); |
| 221 | #endif |
| 222 | return 0; |
| 223 | } |