blob: fd545b5a254c16bc03f126e0aa6fbc75534096de [file] [log] [blame]
wdenk2d5b5612003-10-14 19:43:55 +00001/*
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 Warrencc940742008-09-05 01:55:22 -040035#include <netdev.h>
wdenk2d5b5612003-10-14 19:43:55 +000036#include <asm/arch/ixp425.h>
37
Wolfgang Denkba94a1b2006-05-30 15:56:48 +020038ulong loops_per_jiffy;
39
Wolfgang Denkd87080b2006-03-31 18:32:53 +020040#ifdef CONFIG_USE_IRQ
41DECLARE_GLOBAL_DATA_PTR;
42#endif
43
Wolfgang Denkba94a1b2006-05-30 15:56:48 +020044#if defined(CONFIG_DISPLAY_CPUINFO)
45int 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
wdenk2d5b5612003-10-14 19:43:55 +000079int cpu_init (void)
80{
81 /*
wdenkf6e20fc2004-02-08 19:38:38 +000082 * setup up stacks if necessary
wdenk2d5b5612003-10-14 19:43:55 +000083 */
wdenk2d5b5612003-10-14 19:43:55 +000084#ifdef CONFIG_USE_IRQ
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
wdenkf6e20fc2004-02-08 19:38:38 +000086 FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
wdenk2d5b5612003-10-14 19:43:55 +000087#endif
wdenkf6e20fc2004-02-08 19:38:38 +000088
wdenk2d5b5612003-10-14 19:43:55 +000089 return 0;
90}
91
92int 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
116int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
117{
wdenkf6e20fc2004-02-08 19:38:38 +0000118 printf ("resetting ...\n");
wdenk2d5b5612003-10-14 19:43:55 +0000119
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 */
129void 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
143void 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
160int 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 */
172void dcache_enable (void)
173{
174 return;
175}
176
177void dcache_disable (void)
178{
179 return;
180}
181
182int dcache_status (void)
183{
184 return 0; /* always off */
185}
186
187/* FIXME */
wdenka1191902005-01-09 17:12:27 +0000188/*
wdenk2d5b5612003-10-14 19:43:55 +0000189void pci_init(void)
190{
191 return;
192}
wdenka1191902005-01-09 17:12:27 +0000193*/
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200194
195#ifdef CONFIG_BOOTCOUNT_LIMIT
196
197void bootcount_store (ulong a)
198{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200199 volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200200
201 save_addr[0] = a;
202 save_addr[1] = BOOTCOUNT_MAGIC;
203}
204
205ulong bootcount_load (void)
206{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200207 volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200208
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 Warrencc940742008-09-05 01:55:22 -0400216
217int cpu_eth_init(bd_t *bis)
218{
219#ifdef CONFIG_IXP4XX_NPE
220 npe_initialize(bis);
221#endif
222 return 0;
223}