]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/mpc8260/cpu.c
8adf950f980e77e8a466a7e05b1c853dbb608fc2
[karo-tx-uboot.git] / cpu / mpc8260 / cpu.c
1 /*
2  * (C) Copyright 2000-2003
3  * 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 /*
25  * CPU specific code for the MPC825x / MPC826x / MPC827x / MPC828x
26  *
27  * written or collected and sometimes rewritten by
28  * Magnus Damm <damm@bitsmart.com>
29  *
30  * modified by
31  * 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>
38  *
39  * added HiP7 (824x/827x/8280) processors support by
40  * Yuli Barcohen <yuli@arabellasw.com>
41  */
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
50 int checkcpu (void)
51 {
52         DECLARE_GLOBAL_DATA_PTR;
53
54         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
62         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;
70         case PVR_8260_HIP7R1:
71         case PVR_8260_HIP7:
72                 k = 7;
73                 break;
74         default:
75                 return -1;      /* whoops! not an MPC8260 */
76         }
77         rev = pvr & 0xff;
78
79         immr = immap->im_memctl.memc_immr;
80         if ((immr & IMMR_ISB_MSK) != CFG_IMMR)
81                 return -1;      /* whoops! someone moved the IMMR */
82
83         printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
84
85         /*
86          * the bottom 16 bits of the immr are the Part Number and Mask Number
87          * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
88          * RISC Microcode Revision Number (13-10).
89          * For the 8260, Motorola doesn't include the Microcode Revision
90          * in the mask.
91          */
92         m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
93         k = *((ushort *) & immap->im_dprambase[PROFF_REVNUM]);
94
95         switch (m) {
96         case 0x0000:
97                 puts ("0.2 2J24M");
98                 break;
99         case 0x0010:
100                 puts ("A.0 K22A");
101                 break;
102         case 0x0011:
103                 puts ("A.1 1K22A-XC");
104                 break;
105         case 0x0001:
106                 puts ("B.1 1K23A");
107                 break;
108         case 0x0021:
109                 puts ("B.2 2K23A-XC");
110                 break;
111         case 0x0023:
112                 puts ("B.3 3K23A");
113                 break;
114         case 0x0024:
115                 puts ("C.2 6K23A");
116                 break;
117         case 0x0060:
118                 puts ("A.0(A) 2K25A");
119                 break;
120         case 0x0062:
121                 puts ("B.1 4K25A");
122                 break;
123         case 0x0064:
124                 puts ("C.0 5K25A");
125                 break;
126         case 0x0A00:
127                 puts ("0.0 0K49M");
128                 break;
129         case 0x0A01:
130                 puts ("0.1 1K49M");
131                 break;
132         case 0x0C00:
133         case 0x0D00:
134                 printf ("0.0 0K50M");
135                 break;
136         default:
137                 printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
138                 break;
139         }
140
141         printf (") at %s MHz\n", strmhz (buf, clock));
142
143         return 0;
144 }
145
146 /* ------------------------------------------------------------------------- */
147 /* configures a UPM by writing into the UPM RAM array                        */
148 /* uses bank 11 and a dummy physical address (=BRx_BA_MSK)                   */
149 /* NOTE: the physical address chosen must not overlap into any other area    */
150 /* mapped by the memory controller because bank 11 has the lowest priority   */
151
152 void upmconfig (uint upm, uint * table, uint size)
153 {
154         volatile immap_t *immap = (immap_t *) CFG_IMMR;
155         volatile memctl8260_t *memctl = &immap->im_memctl;
156         volatile uchar *dummy = (uchar *) BRx_BA_MSK;   /* set all BA bits */
157         uint i;
158
159         /* first set up bank 11 to reference the correct UPM at a dummy address */
160
161         memctl->memc_or11 = ORxU_AM_MSK;        /* set all AM bits */
162
163         switch (upm) {
164
165         case UPMA:
166                 memctl->memc_br11 =
167                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
168                         BRx_V;
169                 memctl->memc_mamr = MxMR_OP_WARR;
170                 break;
171
172         case UPMB:
173                 memctl->memc_br11 =
174                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
175                         BRx_V;
176                 memctl->memc_mbmr = MxMR_OP_WARR;
177                 break;
178
179         case UPMC:
180                 memctl->memc_br11 =
181                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
182                         BRx_V;
183                 memctl->memc_mcmr = MxMR_OP_WARR;
184                 break;
185
186         default:
187                 panic ("upmconfig passed invalid UPM number (%u)\n", upm);
188                 break;
189
190         }
191
192         /*
193          * at this point, the dummy address is set up to access the selected UPM,
194          * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
195          *
196          * now we simply load the mdr with each word and poke the dummy address.
197          * the MAD is incremented on each access.
198          */
199
200         for (i = 0; i < size; i++) {
201                 memctl->memc_mdr = table[i];
202                 *dummy = 0;
203         }
204
205         /* now kill bank 11 */
206         memctl->memc_br11 = 0;
207 }
208
209 /* ------------------------------------------------------------------------- */
210
211 int
212 do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
213 {
214         ulong msr, addr;
215
216         volatile immap_t *immap = (immap_t *) CFG_IMMR;
217
218         immap->im_clkrst.car_rmr = RMR_CSRE;    /* Checkstop Reset enable */
219
220         /* Interrupts and MMU off */
221         __asm__ __volatile__ ("mfmsr    %0":"=r" (msr):);
222
223         msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
224         __asm__ __volatile__ ("mtmsr    %0"::"r" (msr));
225
226         /*
227          * Trying to execute the next instruction at a non-existing address
228          * should cause a machine check, resulting in reset
229          */
230 #ifdef CFG_RESET_ADDRESS
231         addr = CFG_RESET_ADDRESS;
232 #else
233         /*
234          * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
235          * - sizeof (ulong) is usually a valid address. Better pick an address
236          * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
237          */
238         addr = CFG_MONITOR_BASE - sizeof (ulong);
239 #endif
240         ((void (*)(void)) addr) ();
241         return 1;
242
243 }
244
245 /* ------------------------------------------------------------------------- */
246
247 /*
248  * Get timebase clock frequency (like cpu_clk in Hz)
249  *
250  */
251 unsigned long get_tbclk (void)
252 {
253         DECLARE_GLOBAL_DATA_PTR;
254
255         ulong tbclk;
256
257         tbclk = (gd->bus_clk + 3L) / 4L;
258
259         return (tbclk);
260 }
261
262 /* ------------------------------------------------------------------------- */
263
264 #if defined(CONFIG_WATCHDOG)
265 void watchdog_reset (void)
266 {
267         int re_enable = disable_interrupts ();
268
269         reset_8260_watchdog ((immap_t *) CFG_IMMR);
270         if (re_enable)
271                 enable_interrupts ();
272 }
273 #endif /* CONFIG_WATCHDOG */
274
275 /* ------------------------------------------------------------------------- */