blob: c265ce265af72ae3e72d2a1d60e59c965fc2bcfd [file] [log] [blame]
wdenk1df49e22002-09-17 21:37:55 +00001/*
2 * (C) Copyright 2001
3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * cpu.c
26 *
27 * CPU specific code
28 *
29 * written or collected and sometimes rewritten by
30 * Magnus Damm <damm@bitsmart.com>
31 *
32 * minor modifications by
33 * Wolfgang Denk <wd@denx.de>
34 *
35 * more modifications by
36 * Josh Huber <huber@mclx.com>
37 * added support for the 74xx series of cpus
38 * added support for the 7xx series of cpus
39 * made the code a little less hard-coded, and more auto-detectish
40 */
41
42#include <common.h>
43#include <command.h>
44#include <74xx_7xx.h>
45#include <asm/cache.h>
46
wdenkc7de8292002-11-19 11:04:11 +000047#ifdef CONFIG_AMIGAONEG3SE
48#include "../board/MAI/AmigaOneG3SE/via686.h"
49#include "../board/MAI/AmigaOneG3SE/memio.h"
50#endif
51
wdenk1df49e22002-09-17 21:37:55 +000052cpu_t
53get_cpu_type(void)
54{
55 uint pvr = get_pvr();
56 cpu_t type;
57
58 type = CPU_UNKNOWN;
59
60 switch (PVR_VER(pvr)) {
61 case 0x000c:
62 type = CPU_7400;
63 break;
64 case 0x0008:
65 type = CPU_750;
66
67 if (((pvr >> 8) & 0xff) == 0x01) {
68 type = CPU_750CX; /* old CX (80100 and 8010x?)*/
69 } else if (((pvr >> 8) & 0xff) == 0x22) {
70 type = CPU_750CX; /* CX (82201,82202) and CXe (82214) */
71 } else if (((pvr >> 8) & 0xff) == 0x33) {
72 type = CPU_750CX; /* CXe (83311) */
73 } else if (((pvr >> 12) & 0xF) == 0x3) {
74 type = CPU_755;
75 }
76 break;
77
78 case 0x800C:
79 type = CPU_7410;
80 break;
81
82 case 0x8000:
83 type = CPU_7450;
84 break;
85
86 default:
87 break;
88 }
89
90 return type;
91}
92
93/* ------------------------------------------------------------------------- */
94
95#if !defined(CONFIG_BAB7xx)
96int checkcpu (void)
97{
98 DECLARE_GLOBAL_DATA_PTR;
99
100 uint type = get_cpu_type();
101 uint pvr = get_pvr();
102 ulong clock = gd->cpu_clk;
103 char buf[32];
104 char *str;
105
106 puts ("CPU: ");
107
108 switch (type) {
109 case CPU_750CX:
110 printf ("750CX%s v%d.%d", (pvr&0xf0)?"e":"",
111 (pvr>>8) & 0xf,
112 pvr & 0xf);
113 goto PR_CLK;
114
115 case CPU_750:
116 str = "750";
117 break;
118
119 case CPU_755:
120 str = "755";
121 break;
122
123 case CPU_7400:
124 str = "MPC7400";
125 break;
126
127 case CPU_7410:
128 str = "MPC7410";
129 break;
130
131 case CPU_7450:
132 str = "MPC7450";
133 break;
134
135 default:
136 printf("Unknown CPU -- PVR: 0x%08x\n", pvr);
137 return -1;
138 }
139
140 printf ("%s v%d.%d", str, (pvr >> 8) & 0xFF, pvr & 0xFF);
141PR_CLK:
142 printf (" @ %s MHz\n", strmhz(buf, clock));
143
144 return (0);
145}
146#endif
147/* these two functions are unimplemented currently [josh] */
148
149/* ------------------------------------------------------------------------- */
150/* L1 i-cache */
151
152int
153checkicache(void)
154{
155 return 0; /* XXX */
156}
157
158/* ------------------------------------------------------------------------- */
159/* L1 d-cache */
160
161int
162checkdcache(void)
163{
164 return 0; /* XXX */
165}
166
167/* ------------------------------------------------------------------------- */
168
169static inline void
170soft_restart(unsigned long addr)
171{
172 /* SRR0 has system reset vector, SRR1 has default MSR value */
173 /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
174
175 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
176 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
177 __asm__ __volatile__ ("mtspr 27, 4");
178 __asm__ __volatile__ ("rfi");
179
180 while(1); /* not reached */
181}
182
183
184#if !defined(CONFIG_PCIPPC2) && \
185 !defined(CONFIG_BAB7xx) && \
186 !defined(CONFIG_ELPPC)
187/* no generic way to do board reset. simply call soft_reset. */
188void
189do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
190{
191 ulong addr;
192 /* flush and disable I/D cache */
193 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
194 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
195 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
196 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
197 __asm__ __volatile__ ("sync");
198 __asm__ __volatile__ ("mtspr 1008, 4");
199 __asm__ __volatile__ ("isync");
200 __asm__ __volatile__ ("sync");
201 __asm__ __volatile__ ("mtspr 1008, 5");
202 __asm__ __volatile__ ("isync");
203 __asm__ __volatile__ ("sync");
204
205#ifdef CFG_RESET_ADDRESS
206 addr = CFG_RESET_ADDRESS;
207#else
208 /*
209 * note: when CFG_MONITOR_BASE points to a RAM address,
210 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
211 * address. Better pick an address known to be invalid on your
212 * system and assign it to CFG_RESET_ADDRESS.
213 */
214 addr = CFG_MONITOR_BASE - sizeof (ulong);
215#endif
216 soft_restart(addr);
217 while(1); /* not reached */
218}
219#endif
220
221/* ------------------------------------------------------------------------- */
222
223/*
224 * For the 7400 the TB clock runs at 1/4 the cpu bus speed.
225 */
wdenkc7de8292002-11-19 11:04:11 +0000226#ifdef CONFIG_AMIGAONEG3SE
227unsigned long get_tbclk(void)
228{
229 DECLARE_GLOBAL_DATA_PTR;
230
231 return (gd->bus_clk / 4);
232}
233#else /* ! CONFIG_AMIGAONEG3SE */
234
235unsigned long get_tbclk (void)
wdenk1df49e22002-09-17 21:37:55 +0000236{
237 return CFG_BUS_HZ / 4;
238}
wdenkc7de8292002-11-19 11:04:11 +0000239#endif /* CONFIG_AMIGAONEG3SE */
wdenk1df49e22002-09-17 21:37:55 +0000240/* ------------------------------------------------------------------------- */
241
242#if defined(CONFIG_WATCHDOG)
243#if !defined(CONFIG_PCIPPC2) && !defined(CONFIG_BAB7xx)
244void
245watchdog_reset(void)
246{
247
248}
249#endif /* !CONFIG_PCIPPC2 && !CONFIG_BAB7xx */
250#endif /* CONFIG_WATCHDOG */
251
252/* ------------------------------------------------------------------------- */