blob: 4f23012b729420ba74ce64dc4cb65d24cb73385e [file] [log] [blame]
wdenk4a9cbbe2002-08-27 09:48:53 +00001/*
Wolfgang Denk6405a152006-03-31 18:32:53 +02002 * (C) Copyright 2000-2006
wdenk4a9cbbe2002-08-27 09:48:53 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
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/*
wdenkdccbda02003-07-14 22:13:32 +000025 * CPU specific code for the MPC825x / MPC826x / MPC827x / MPC828x
wdenk4a9cbbe2002-08-27 09:48:53 +000026 *
27 * written or collected and sometimes rewritten by
28 * Magnus Damm <damm@bitsmart.com>
29 *
wdenkc08f1582003-04-27 22:52:51 +000030 * modified by
wdenk4a9cbbe2002-08-27 09:48:53 +000031 * Wolfgang Denk <wd@denx.de>
32 *
33 * modified for 8260 by
34 * Murray Jensen <Murray.Jensen@cmst.csiro.au>
35 *
36 * added 8260 masks by
37 * Marius Groeger <mag@sysgo.de>
wdenkdccbda02003-07-14 22:13:32 +000038 *
wdenk3902d702004-04-15 18:22:41 +000039 * added HiP7 (824x/827x/8280) processors support by
wdenkdccbda02003-07-14 22:13:32 +000040 * Yuli Barcohen <yuli@arabellasw.com>
wdenk4a9cbbe2002-08-27 09:48:53 +000041 */
42
43#include <common.h>
44#include <watchdog.h>
45#include <command.h>
46#include <mpc8260.h>
47#include <asm/processor.h>
48#include <asm/cpm_8260.h>
49
Wolfgang Denk6405a152006-03-31 18:32:53 +020050DECLARE_GLOBAL_DATA_PTR;
51
wdenk4a9cbbe2002-08-27 09:48:53 +000052int checkcpu (void)
53{
wdenk4a9cbbe2002-08-27 09:48:53 +000054 volatile immap_t *immap = (immap_t *) CFG_IMMR;
55 ulong clock = gd->cpu_clk;
56 uint pvr = get_pvr ();
57 uint immr, rev, m, k;
58 char buf[32];
59
60 puts ("CPU: ");
61
wdenkdccbda02003-07-14 22:13:32 +000062 switch (pvr) {
63 case PVR_8260:
64 case PVR_8260_HIP3:
65 k = 3;
66 break;
67 case PVR_8260_HIP4:
68 k = 4;
69 break;
wdenk86765902003-12-06 23:55:10 +000070 case PVR_8260_HIP7R1:
wdenk391b5742004-10-10 23:27:33 +000071 case PVR_8260_HIP7RA:
wdenkdccbda02003-07-14 22:13:32 +000072 case PVR_8260_HIP7:
73 k = 7;
74 break;
75 default:
wdenk4a9cbbe2002-08-27 09:48:53 +000076 return -1; /* whoops! not an MPC8260 */
wdenkdccbda02003-07-14 22:13:32 +000077 }
wdenk4a9cbbe2002-08-27 09:48:53 +000078 rev = pvr & 0xff;
79
80 immr = immap->im_memctl.memc_immr;
81 if ((immr & IMMR_ISB_MSK) != CFG_IMMR)
82 return -1; /* whoops! someone moved the IMMR */
83
wdenkdccbda02003-07-14 22:13:32 +000084 printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
wdenk4a9cbbe2002-08-27 09:48:53 +000085
86 /*
87 * the bottom 16 bits of the immr are the Part Number and Mask Number
88 * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
89 * RISC Microcode Revision Number (13-10).
90 * For the 8260, Motorola doesn't include the Microcode Revision
91 * in the mask.
92 */
93 m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
94 k = *((ushort *) & immap->im_dprambase[PROFF_REVNUM]);
95
96 switch (m) {
97 case 0x0000:
wdenk42c05472004-03-23 22:14:11 +000098 puts ("0.2 2J24M");
wdenk4a9cbbe2002-08-27 09:48:53 +000099 break;
100 case 0x0010:
wdenk42c05472004-03-23 22:14:11 +0000101 puts ("A.0 K22A");
wdenk4a9cbbe2002-08-27 09:48:53 +0000102 break;
103 case 0x0011:
wdenk42c05472004-03-23 22:14:11 +0000104 puts ("A.1 1K22A-XC");
wdenk4a9cbbe2002-08-27 09:48:53 +0000105 break;
106 case 0x0001:
wdenk42c05472004-03-23 22:14:11 +0000107 puts ("B.1 1K23A");
wdenk4a9cbbe2002-08-27 09:48:53 +0000108 break;
109 case 0x0021:
wdenk42c05472004-03-23 22:14:11 +0000110 puts ("B.2 2K23A-XC");
wdenk4a9cbbe2002-08-27 09:48:53 +0000111 break;
112 case 0x0023:
wdenk42c05472004-03-23 22:14:11 +0000113 puts ("B.3 3K23A");
wdenk4a9cbbe2002-08-27 09:48:53 +0000114 break;
115 case 0x0024:
wdenk42c05472004-03-23 22:14:11 +0000116 puts ("C.2 6K23A");
wdenk4a9cbbe2002-08-27 09:48:53 +0000117 break;
118 case 0x0060:
wdenk42c05472004-03-23 22:14:11 +0000119 puts ("A.0(A) 2K25A");
wdenk4a9cbbe2002-08-27 09:48:53 +0000120 break;
wdenkc08f1582003-04-27 22:52:51 +0000121 case 0x0062:
wdenk42c05472004-03-23 22:14:11 +0000122 puts ("B.1 4K25A");
wdenkc08f1582003-04-27 22:52:51 +0000123 break;
wdenk2f0812d2003-10-08 22:45:44 +0000124 case 0x0064:
wdenk42c05472004-03-23 22:14:11 +0000125 puts ("C.0 5K25A");
wdenk2f0812d2003-10-08 22:45:44 +0000126 break;
wdenkdccbda02003-07-14 22:13:32 +0000127 case 0x0A00:
wdenk42c05472004-03-23 22:14:11 +0000128 puts ("0.0 0K49M");
wdenkdccbda02003-07-14 22:13:32 +0000129 break;
130 case 0x0A01:
wdenk42c05472004-03-23 22:14:11 +0000131 puts ("0.1 1K49M");
wdenkdccbda02003-07-14 22:13:32 +0000132 break;
wdenk391b5742004-10-10 23:27:33 +0000133 case 0x0A10:
134 puts ("1.0 1K49M");
135 break;
wdenk3902d702004-04-15 18:22:41 +0000136 case 0x0C00:
wdenk391b5742004-10-10 23:27:33 +0000137 puts ("0.0 0K50M");
138 break;
139 case 0x0C10:
Wolfgang Denke37c98a2005-08-06 02:03:03 +0200140 puts ("1.0 1K50M");
wdenk391b5742004-10-10 23:27:33 +0000141 break;
wdenk3902d702004-04-15 18:22:41 +0000142 case 0x0D00:
wdenk391b5742004-10-10 23:27:33 +0000143 puts ("0.0 0K50M");
144 break;
145 case 0x0D10:
Wolfgang Denke37c98a2005-08-06 02:03:03 +0200146 puts ("1.0 1K50M");
wdenk3902d702004-04-15 18:22:41 +0000147 break;
wdenk4a9cbbe2002-08-27 09:48:53 +0000148 default:
149 printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
150 break;
151 }
152
153 printf (") at %s MHz\n", strmhz (buf, clock));
154
155 return 0;
156}
157
158/* ------------------------------------------------------------------------- */
159/* configures a UPM by writing into the UPM RAM array */
160/* uses bank 11 and a dummy physical address (=BRx_BA_MSK) */
161/* NOTE: the physical address chosen must not overlap into any other area */
162/* mapped by the memory controller because bank 11 has the lowest priority */
163
164void upmconfig (uint upm, uint * table, uint size)
165{
166 volatile immap_t *immap = (immap_t *) CFG_IMMR;
167 volatile memctl8260_t *memctl = &immap->im_memctl;
168 volatile uchar *dummy = (uchar *) BRx_BA_MSK; /* set all BA bits */
169 uint i;
170
171 /* first set up bank 11 to reference the correct UPM at a dummy address */
172
173 memctl->memc_or11 = ORxU_AM_MSK; /* set all AM bits */
174
175 switch (upm) {
176
177 case UPMA:
178 memctl->memc_br11 =
179 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
180 BRx_V;
181 memctl->memc_mamr = MxMR_OP_WARR;
182 break;
183
184 case UPMB:
185 memctl->memc_br11 =
186 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
187 BRx_V;
188 memctl->memc_mbmr = MxMR_OP_WARR;
189 break;
190
191 case UPMC:
192 memctl->memc_br11 =
193 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
194 BRx_V;
195 memctl->memc_mcmr = MxMR_OP_WARR;
196 break;
197
198 default:
199 panic ("upmconfig passed invalid UPM number (%u)\n", upm);
200 break;
201
202 }
203
204 /*
205 * at this point, the dummy address is set up to access the selected UPM,
206 * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
207 *
208 * now we simply load the mdr with each word and poke the dummy address.
209 * the MAD is incremented on each access.
210 */
211
212 for (i = 0; i < size; i++) {
213 memctl->memc_mdr = table[i];
214 *dummy = 0;
215 }
216
217 /* now kill bank 11 */
218 memctl->memc_br11 = 0;
219}
220
221/* ------------------------------------------------------------------------- */
222
wdenkc28149c2005-05-30 23:55:42 +0000223#if !defined(CONFIG_HAVE_OWN_RESET)
wdenk4a9cbbe2002-08-27 09:48:53 +0000224int
wdenk57b2d802003-06-27 21:31:46 +0000225do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
wdenk4a9cbbe2002-08-27 09:48:53 +0000226{
227 ulong msr, addr;
228
229 volatile immap_t *immap = (immap_t *) CFG_IMMR;
230
231 immap->im_clkrst.car_rmr = RMR_CSRE; /* Checkstop Reset enable */
232
233 /* Interrupts and MMU off */
234 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
235
236 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
237 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
238
239 /*
240 * Trying to execute the next instruction at a non-existing address
241 * should cause a machine check, resulting in reset
242 */
243#ifdef CFG_RESET_ADDRESS
244 addr = CFG_RESET_ADDRESS;
245#else
246 /*
247 * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
248 * - sizeof (ulong) is usually a valid address. Better pick an address
249 * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
250 */
251 addr = CFG_MONITOR_BASE - sizeof (ulong);
252#endif
253 ((void (*)(void)) addr) ();
254 return 1;
255
256}
wdenkc28149c2005-05-30 23:55:42 +0000257#endif /* CONFIG_HAVE_OWN_RESET */
wdenk4a9cbbe2002-08-27 09:48:53 +0000258
259/* ------------------------------------------------------------------------- */
260
261/*
262 * Get timebase clock frequency (like cpu_clk in Hz)
263 *
264 */
265unsigned long get_tbclk (void)
266{
wdenk4a9cbbe2002-08-27 09:48:53 +0000267 ulong tbclk;
268
269 tbclk = (gd->bus_clk + 3L) / 4L;
270
271 return (tbclk);
272}
273
274/* ------------------------------------------------------------------------- */
275
276#if defined(CONFIG_WATCHDOG)
277void watchdog_reset (void)
278{
279 int re_enable = disable_interrupts ();
280
281 reset_8260_watchdog ((immap_t *) CFG_IMMR);
282 if (re_enable)
283 enable_interrupts ();
284}
285#endif /* CONFIG_WATCHDOG */
286
287/* ------------------------------------------------------------------------- */