Changed PPC44x startup message (cpu info, speed...) to common style:
[platform/kernel/u-boot.git] / cpu / ppc4xx / 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
26  *
27  * written or collected and sometimes rewritten by
28  * Magnus Damm <damm@bitsmart.com>
29  *
30  * minor modifications by
31  * Wolfgang Denk <wd@denx.de>
32  */
33
34 #include <common.h>
35 #include <watchdog.h>
36 #include <command.h>
37 #include <asm/cache.h>
38 #include <ppc4xx.h>
39
40
41 #if defined(CONFIG_405GP)
42 #define PCI_ARBITER_ENABLED     (mfdcr(strap) & PSR_PCI_ARBIT_EN)
43 #define PCI_ASYNC_ENABLED       (mfdcr(strap) & PSR_PCI_ASYNC_EN)
44 #endif
45
46 #if defined(CONFIG_405EP)
47 #define PCI_ARBITER_ENABLED     (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
48 #define I2C_BOOTROM_ENABLED     (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
49 #endif
50
51 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
52 #define SDR0_SDSTP1_PAE         (0x80000000 >> 21)
53 #define SDR0_SDSTP1_PAME        (0x80000000 >> 27)
54
55 #define PCI_ARBITER_ENABLED     (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
56 #define PCI_ASYNC_ENABLED       (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAME)
57 #endif
58
59 #if defined(CONFIG_440GP)
60 #define CPC0_STRP1_PAE          (0x80000000 >> 11)
61
62 #define PCI_ARBITER_ENABLED     (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE)
63 #endif
64
65 #if defined(CONFIG_440GX)
66 #define SDR0_SDSTP1_PAE         (0x80000000 >> 13)
67
68 #define PCI_ARBITER_ENABLED     (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
69 #endif
70
71 #if defined(CONFIG_440)
72 #define FREQ_EBC                (sys_info.freqEPB)
73 #else
74 #define FREQ_EBC                (sys_info.freqPLB / sys_info.pllExtBusDiv)
75 #endif
76
77
78 #if defined(CONFIG_440)
79 static int do_chip_reset(unsigned long sys0, unsigned long sys1);
80 #endif
81
82
83 int checkcpu (void)
84 {
85 #if !defined(CONFIG_405)        /* not used on Xilinx 405 FPGA implementations */
86         DECLARE_GLOBAL_DATA_PTR;
87         uint pvr = get_pvr();
88         ulong clock = gd->cpu_clk;
89         char buf[32];
90
91 #if !defined(CONFIG_IOP480)
92         sys_info_t sys_info;
93
94         puts ("CPU:   ");
95
96         get_sys_info(&sys_info);
97
98         puts("AMCC PowerPC 4");
99
100 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
101         puts("05");
102 #endif
103 #if defined(CONFIG_440)
104         puts("40");
105 #endif
106
107         switch (pvr) {
108         case PVR_405GP_RB:
109                 puts("GP Rev. B");
110                 break;
111
112         case PVR_405GP_RC:
113                 puts("GP Rev. C");
114                 break;
115
116         case PVR_405GP_RD:
117                 puts("GP Rev. D");
118                 break;
119
120 #ifdef CONFIG_405GP
121         case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
122                 puts("GP Rev. E");
123                 break;
124 #endif
125
126         case PVR_405CR_RA:
127                 puts("CR Rev. A");
128                 break;
129
130         case PVR_405CR_RB:
131                 puts("CR Rev. B");
132                 break;
133
134 #ifdef CONFIG_405CR
135         case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
136                 puts("CR Rev. C");
137                 break;
138 #endif
139
140         case PVR_405GPR_RB:
141                 puts("GPr Rev. B");
142                 break;
143
144         case PVR_405EP_RB:
145                 puts("EP Rev. B");
146                 break;
147
148 #if defined(CONFIG_440)
149         case PVR_440GP_RB:
150                 puts("GP Rev. B");
151                 /* See errata 1.12: CHIP_4 */
152                 if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
153                     (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
154                         puts (  "\n\t CPC0_SYSx DCRs corrupted. "
155                                 "Resetting chip ...\n");
156                         udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
157                         do_chip_reset ( mfdcr(cpc0_strp0),
158                                         mfdcr(cpc0_strp1) );
159                 }
160                 break;
161
162         case PVR_440GP_RC:
163                 puts("GP Rev. C");
164                 break;
165
166         case PVR_440GX_RA:
167                 puts("GX Rev. A");
168                 break;
169
170         case PVR_440GX_RB:
171                 puts("GX Rev. B");
172                 break;
173
174         case PVR_440GX_RC:
175                 puts("GX Rev. C");
176                 break;
177
178         case PVR_440GX_RF:
179                 puts("GX Rev. F");
180                 break;
181
182         case PVR_440EP_RA:
183                 puts("EP Rev. A");
184                 break;
185
186 #ifdef CONFIG_440EP
187         case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
188                 puts("EP Rev. B");
189                 break;
190 #endif /*  CONFIG_440EP */
191
192 #ifdef CONFIG_440GR
193         case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
194                 puts("GR Rev. A");
195                 break;
196 #endif /* CONFIG_440GR */
197 #endif /* CONFIG_440 */
198
199         default:
200                 printf (" UNKNOWN (PVR=%08x)", pvr);
201                 break;
202         }
203
204         printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
205                sys_info.freqPLB / 1000000,
206                sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
207                FREQ_EBC / 1000000);
208
209 #if defined(I2C_BOOTROM_ENABLED)
210         printf ("       IIC Boot EEPROM %sabled\n", I2C_BOOTROM_ENABLED ? "en" : "dis");
211 #endif
212
213 #if defined(PCI_ARBITER_ENABLED)
214         printf ("       %sternal PCI arbiter enabled",
215                 (PCI_ARBITER_ENABLED) ? "In" : "Ex");
216 #endif
217
218 #if defined(PCI_ASYNC_ENABLED)
219         if (PCI_ASYNC_ENABLED) {
220                 printf (", PCI async ext clock used");
221         } else {
222                 printf (", PCI sync clock at %lu MHz",
223                        sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
224         }
225 #endif
226
227 #if defined(PCI_ARBITER_ENABLED) || defined(PCI_ASYNC_ENABLED)
228         putc('\n');
229 #endif
230
231 #if defined(CONFIG_405EP)
232         printf ("       16 kB I-Cache 16 kB D-Cache");
233 #elif defined(CONFIG_440)
234         printf ("       32 kB I-Cache 32 kB D-Cache");
235 #else
236         printf ("       16 kB I-Cache %d kB D-Cache",
237                 ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
238 #endif
239 #endif /* !defined(CONFIG_IOP480) */
240
241 #if defined(CONFIG_IOP480)
242         printf ("PLX IOP480 (PVR=%08x)", pvr);
243         printf (" at %s MHz:", strmhz(buf, clock));
244         printf (" %u kB I-Cache", 4);
245         printf (" %u kB D-Cache", 2);
246 #endif
247
248 #endif /* !defined(CONFIG_405) */
249
250         putc ('\n');
251
252         return 0;
253 }
254
255
256 /* ------------------------------------------------------------------------- */
257
258 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
259 {
260 #if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
261         /*give reset to BCSR*/
262         *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
263
264 #else
265
266         /*
267          * Initiate system reset in debug control register DBCR
268          */
269         __asm__ __volatile__("lis   3, 0x3000" ::: "r3");
270 #if defined(CONFIG_440)
271         __asm__ __volatile__("mtspr 0x134, 3");
272 #else
273         __asm__ __volatile__("mtspr 0x3f2, 3");
274 #endif
275
276 #endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
277         return 1;
278 }
279
280 #if defined(CONFIG_440)
281 static int do_chip_reset (unsigned long sys0, unsigned long sys1)
282 {
283         /* Changes to cpc0_sys0 and cpc0_sys1 require chip
284          * reset.
285          */
286         mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000);    /* Set SWE */
287         mtdcr (cpc0_sys0, sys0);
288         mtdcr (cpc0_sys1, sys1);
289         mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000);   /* Clr SWE */
290         mtspr (dbcr0, 0x20000000);      /* Reset the chip */
291
292         return 1;
293 }
294 #endif
295
296
297 /*
298  * Get timebase clock frequency
299  */
300 unsigned long get_tbclk (void)
301 {
302 #if !defined(CONFIG_IOP480)
303         sys_info_t  sys_info;
304
305         get_sys_info(&sys_info);
306         return (sys_info.freqProcessor);
307 #else
308         return (66000000);
309 #endif
310
311 }
312
313
314 #if defined(CONFIG_WATCHDOG)
315 void
316 watchdog_reset(void)
317 {
318         int re_enable = disable_interrupts();
319         reset_4xx_watchdog();
320         if (re_enable) enable_interrupts();
321 }
322
323 void
324 reset_4xx_watchdog(void)
325 {
326         /*
327          * Clear TSR(WIS) bit
328          */
329         mtspr(tsr, 0x40000000);
330 }
331 #endif  /* CONFIG_WATCHDOG */