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> |
Jean-Christophe PLAGNIOL-VILLARD | 677e62f | 2009-04-05 13:02:43 +0200 | [diff] [blame] | 37 | #include <asm/system.h> |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 38 | |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 39 | ulong loops_per_jiffy; |
| 40 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 41 | #ifdef CONFIG_USE_IRQ |
| 42 | DECLARE_GLOBAL_DATA_PTR; |
| 43 | #endif |
| 44 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 45 | static void cache_flush(void); |
| 46 | |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 47 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 48 | int print_cpuinfo (void) |
| 49 | { |
| 50 | unsigned long id; |
| 51 | int speed = 0; |
| 52 | |
| 53 | asm ("mrc p15, 0, %0, c0, c0, 0":"=r" (id)); |
| 54 | |
| 55 | puts("CPU: Intel IXP425 at "); |
| 56 | switch ((id & 0x000003f0) >> 4) { |
| 57 | case 0x1c: |
| 58 | loops_per_jiffy = 887467; |
| 59 | speed = 533; |
| 60 | break; |
| 61 | |
| 62 | case 0x1d: |
| 63 | loops_per_jiffy = 666016; |
| 64 | speed = 400; |
| 65 | break; |
| 66 | |
| 67 | case 0x1f: |
| 68 | loops_per_jiffy = 442901; |
| 69 | speed = 266; |
| 70 | break; |
| 71 | } |
| 72 | |
| 73 | if (speed) |
| 74 | printf("%d MHz\n", speed); |
| 75 | else |
| 76 | puts("unknown revision\n"); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
| 81 | |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 82 | int cpu_init (void) |
| 83 | { |
| 84 | /* |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 85 | * setup up stacks if necessary |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 86 | */ |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 87 | #ifdef CONFIG_USE_IRQ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | 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] | 89 | FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ; |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 90 | #endif |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 91 | |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | int cleanup_before_linux (void) |
| 96 | { |
| 97 | /* |
| 98 | * this function is called just before we call linux |
| 99 | * it prepares the processor for linux |
| 100 | * |
| 101 | * just disable everything that can disturb booting linux |
| 102 | */ |
| 103 | |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 104 | disable_interrupts (); |
| 105 | |
| 106 | /* turn off I-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 107 | icache_disable(); |
| 108 | dcache_disable(); |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 109 | |
| 110 | /* flush I-cache */ |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 111 | cache_flush(); |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 112 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 113 | return 0; |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 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 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 128 | /* flush I/D-cache */ |
| 129 | static void cache_flush (void) |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 130 | { |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 131 | unsigned long i = 0; |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 132 | |
Jean-Christophe PLAGNIOL-VILLARD | b3acb6c | 2009-04-05 13:06:31 +0200 | [diff] [blame^] | 133 | asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i)); |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* FIXME */ |
wdenk | a119190 | 2005-01-09 17:12:27 +0000 | [diff] [blame] | 137 | /* |
wdenk | 2d5b561 | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 138 | void pci_init(void) |
| 139 | { |
| 140 | return; |
| 141 | } |
wdenk | a119190 | 2005-01-09 17:12:27 +0000 | [diff] [blame] | 142 | */ |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 143 | |
| 144 | #ifdef CONFIG_BOOTCOUNT_LIMIT |
| 145 | |
| 146 | void bootcount_store (ulong a) |
| 147 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 148 | volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 149 | |
| 150 | save_addr[0] = a; |
| 151 | save_addr[1] = BOOTCOUNT_MAGIC; |
| 152 | } |
| 153 | |
| 154 | ulong bootcount_load (void) |
| 155 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 156 | volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR); |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 157 | |
| 158 | if (save_addr[1] != BOOTCOUNT_MAGIC) |
| 159 | return 0; |
| 160 | else |
| 161 | return save_addr[0]; |
| 162 | } |
| 163 | |
| 164 | #endif /* CONFIG_BOOTCOUNT_LIMIT */ |
Ben Warren | cc94074 | 2008-09-05 01:55:22 -0400 | [diff] [blame] | 165 | |
| 166 | int cpu_eth_init(bd_t *bis) |
| 167 | { |
| 168 | #ifdef CONFIG_IXP4XX_NPE |
| 169 | npe_initialize(bis); |
| 170 | #endif |
| 171 | return 0; |
| 172 | } |