blob: ecea5b0643896211960c4821ab9e11acae94f5c5 [file] [log] [blame]
Jon Loeligerdebb7352006-04-26 17:58:56 -05001/*
Jon Loeligercb5965f2006-05-31 12:44:44 -05002 * Copyright 2006 Freescale Semiconductor
3 * Jeff Brown
Jon Loeligerdebb7352006-04-26 17:58:56 -05004 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <common.h>
26#include <watchdog.h>
27#include <command.h>
28#include <asm/cache.h>
Becky Brucee34a0e92008-05-08 19:02:51 -050029#include <asm/mmu.h>
Jon Loeligerdebb7352006-04-26 17:58:56 -050030#include <mpc86xx.h>
Becky Bruce4f93f8b2008-01-23 16:31:06 -060031#include <asm/fsl_law.h>
Jon Loeligerdebb7352006-04-26 17:58:56 -050032
Jon Loeligerdebb7352006-04-26 17:58:56 -050033
Jon Loeligerffff3ae2006-08-22 12:06:18 -050034int
35checkcpu(void)
Jon Loeligerdebb7352006-04-26 17:58:56 -050036{
37 sys_info_t sysinfo;
38 uint pvr, svr;
39 uint ver;
40 uint major, minor;
41 uint lcrr; /* local bus clock ratio register */
42 uint clkdiv; /* clock divider portion of lcrr */
Jon Loeliger9553df82007-10-16 15:26:51 -050043 volatile immap_t *immap = (immap_t *) CFG_IMMR;
44 volatile ccsr_gur_t *gur = &immap->im_gur;
Jon Loeliger5c9efb32006-04-27 10:15:16 -050045
Jon Loeligerdebb7352006-04-26 17:58:56 -050046 puts("Freescale PowerPC\n");
47
48 pvr = get_pvr();
49 ver = PVR_VER(pvr);
50 major = PVR_MAJ(pvr);
51 minor = PVR_MIN(pvr);
52
Jon Loeliger5c9efb32006-04-27 10:15:16 -050053 puts("CPU:\n");
Jon Loeligercb5965f2006-05-31 12:44:44 -050054 puts(" Core: ");
Jon Loeliger5c9efb32006-04-27 10:15:16 -050055
Jon Loeligerdebb7352006-04-26 17:58:56 -050056 switch (ver) {
57 case PVR_VER(PVR_86xx):
Jon Loeliger9553df82007-10-16 15:26:51 -050058 {
59 uint msscr0 = mfspr(MSSCR0);
60 printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
61 if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
62 puts("\n Core1Translation Enabled");
63 debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
64 }
65 break;
Jon Loeligerdebb7352006-04-26 17:58:56 -050066 default:
Jon Loeligerffff3ae2006-08-22 12:06:18 -050067 puts("Unknown");
68 break;
Jon Loeligerdebb7352006-04-26 17:58:56 -050069 }
70 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
71
72 svr = get_svr();
Andy Fleming1ced1212008-02-06 01:19:40 -060073 ver = SVR_SOC_VER(svr);
Jon Loeligerdebb7352006-04-26 17:58:56 -050074 major = SVR_MAJ(svr);
75 minor = SVR_MIN(svr);
76
77 puts(" System: ");
Jon Loeliger5c9efb32006-04-27 10:15:16 -050078 switch (ver) {
Jon Loeligerdebb7352006-04-26 17:58:56 -050079 case SVR_8641:
Jon Loeligerd14ba6a2006-09-14 08:40:36 -050080 if (SVR_SUBVER(svr) == 1) {
Jon Loeligerdebb7352006-04-26 17:58:56 -050081 puts("8641D");
Jon Loeligerd14ba6a2006-09-14 08:40:36 -050082 } else {
83 puts("8641");
84 }
85 break;
Jon Loeliger9553df82007-10-16 15:26:51 -050086 case SVR_8610:
87 puts("8610");
88 break;
Jon Loeligerdebb7352006-04-26 17:58:56 -050089 default:
90 puts("Unknown");
91 break;
92 }
93 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
94
95 get_sys_info(&sysinfo);
96
97 puts(" Clocks: ");
98 printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
99 printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000);
100 printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500101
Jon Loeligerdebb7352006-04-26 17:58:56 -0500102#if defined(CFG_LBC_LCRR)
103 lcrr = CFG_LBC_LCRR;
104#else
105 {
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500106 volatile immap_t *immap = (immap_t *) CFG_IMMR;
107 volatile ccsr_lbc_t *lbc = &immap->im_lbc;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500108
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500109 lcrr = lbc->lcrr;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500110 }
111#endif
112 clkdiv = lcrr & 0x0f;
113 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
114 printf("LBC:%4lu MHz\n",
115 sysinfo.freqSystemBus / 1000000 / clkdiv);
116 } else {
117 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr);
118 }
119
Jon Loeligercb5965f2006-05-31 12:44:44 -0500120 puts(" L2: ");
Jon Loeliger126aa702006-05-30 17:47:00 -0500121 if (get_l2cr() & 0x80000000)
Jon Loeligercb5965f2006-05-31 12:44:44 -0500122 puts("Enabled\n");
Jon Loeliger126aa702006-05-30 17:47:00 -0500123 else
Jon Loeligercb5965f2006-05-31 12:44:44 -0500124 puts("Disabled\n");
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500125
126 return 0;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500127}
128
129
Jon Loeligerdebb7352006-04-26 17:58:56 -0500130static inline void
131soft_restart(unsigned long addr)
132{
Jason Jina8318ec2007-10-26 18:32:00 +0800133#if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500134
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500135 /*
136 * SRR0 has system reset vector, SRR1 has default MSR value
137 * rfi restores MSR from SRR1 and sets the PC to the SRR0 value
138 */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500139
140 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
141 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
142 __asm__ __volatile__ ("mtspr 27, 4");
143 __asm__ __volatile__ ("rfi");
144
145#else /* CONFIG_MPC8641HPCN */
Jon Loeligercb5965f2006-05-31 12:44:44 -0500146
147 out8(PIXIS_BASE + PIXIS_RST, 0);
148
Jon Loeligerdebb7352006-04-26 17:58:56 -0500149#endif /* !CONFIG_MPC8641HPCN */
Jon Loeligercb5965f2006-05-31 12:44:44 -0500150
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500151 while (1) ; /* not reached */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500152}
153
154
Jon Loeliger126aa702006-05-30 17:47:00 -0500155/*
156 * No generic way to do board reset. Simply call soft_reset.
157 */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500158void
Jon Loeliger126aa702006-05-30 17:47:00 -0500159do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
Jon Loeligerdebb7352006-04-26 17:58:56 -0500160{
Jason Jina8318ec2007-10-26 18:32:00 +0800161#if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
Jon Loeligerdebb7352006-04-26 17:58:56 -0500162
163#ifdef CFG_RESET_ADDRESS
Jon Loeligercb5965f2006-05-31 12:44:44 -0500164 ulong addr = CFG_RESET_ADDRESS;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500165#else
166 /*
167 * note: when CFG_MONITOR_BASE points to a RAM address,
168 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
169 * address. Better pick an address known to be invalid on your
170 * system and assign it to CFG_RESET_ADDRESS.
171 */
Jon Loeligercb5965f2006-05-31 12:44:44 -0500172 ulong addr = CFG_MONITOR_BASE - sizeof(ulong);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500173#endif
174
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500175 /* flush and disable I/D cache */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500176 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
177 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
178 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
179 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
180 __asm__ __volatile__ ("sync");
181 __asm__ __volatile__ ("mtspr 1008, 4");
182 __asm__ __volatile__ ("isync");
183 __asm__ __volatile__ ("sync");
184 __asm__ __volatile__ ("mtspr 1008, 5");
185 __asm__ __volatile__ ("isync");
186 __asm__ __volatile__ ("sync");
187
Jon Loeliger126aa702006-05-30 17:47:00 -0500188 soft_restart(addr);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500189
190#else /* CONFIG_MPC8641HPCN */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500191
Haiying Wang3d98b852007-01-22 12:37:30 -0600192 out8(PIXIS_BASE + PIXIS_RST, 0);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500193
Jon Loeligerdebb7352006-04-26 17:58:56 -0500194#endif /* !CONFIG_MPC8641HPCN */
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500195
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500196 while (1) ; /* not reached */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500197}
198
199
Jon Loeligerdebb7352006-04-26 17:58:56 -0500200/*
201 * Get timebase clock frequency
202 */
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500203unsigned long
204get_tbclk(void)
Jon Loeligerdebb7352006-04-26 17:58:56 -0500205{
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500206 sys_info_t sys_info;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500207
208 get_sys_info(&sys_info);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500209 return (sys_info.freqSystemBus + 3L) / 4L;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500210}
211
Jon Loeligerdebb7352006-04-26 17:58:56 -0500212
213#if defined(CONFIG_WATCHDOG)
214void
215watchdog_reset(void)
216{
Jason Jin3473ab72008-05-13 11:50:36 +0800217#if defined(CONFIG_MPC8610)
218 /*
219 * This actually feed the hard enabled watchdog.
220 */
221 volatile immap_t *immap = (immap_t *)CFG_IMMR;
222 volatile ccsr_wdt_t *wdt = &immap->im_wdt;
223 volatile ccsr_gur_t *gur = &immap->im_gur;
224 u32 tmp = gur->pordevsr;
225
226 if (tmp & 0x4000) {
227 wdt->swsrr = 0x556c;
228 wdt->swsrr = 0xaa39;
229 }
230#endif
Jon Loeligerdebb7352006-04-26 17:58:56 -0500231}
232#endif /* CONFIG_WATCHDOG */
233
Jon Loeligerdebb7352006-04-26 17:58:56 -0500234
235#if defined(CONFIG_DDR_ECC)
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500236void
237dma_init(void)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500238{
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500239 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500240 volatile ccsr_dma_t *dma = &immap->im_dma;
241
242 dma->satr0 = 0x00040000;
243 dma->datr0 = 0x00040000;
244 asm("sync; isync");
Jon Loeligerdebb7352006-04-26 17:58:56 -0500245}
246
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500247uint
248dma_check(void)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500249{
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500250 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500251 volatile ccsr_dma_t *dma = &immap->im_dma;
252 volatile uint status = dma->sr0;
253
254 /* While the channel is busy, spin */
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500255 while ((status & 4) == 4) {
Jon Loeligerdebb7352006-04-26 17:58:56 -0500256 status = dma->sr0;
257 }
258
259 if (status != 0) {
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500260 printf("DMA Error: status = %x\n", status);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500261 }
262 return status;
263}
264
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500265int
266dma_xfer(void *dest, uint count, void *src)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500267{
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500268 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500269 volatile ccsr_dma_t *dma = &immap->im_dma;
270
271 dma->dar0 = (uint) dest;
272 dma->sar0 = (uint) src;
273 dma->bcr0 = count;
274 dma->mr0 = 0xf000004;
275 asm("sync;isync");
276 dma->mr0 = 0xf000005;
277 asm("sync;isync");
278 return dma_check();
279}
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500280
Jon Loeligerdebb7352006-04-26 17:58:56 -0500281#endif /* CONFIG_DDR_ECC */
282
283
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600284/*
285 * Print out the state of various machine registers.
Becky Brucee34a0e92008-05-08 19:02:51 -0500286 * Currently prints out LAWs, BR0/OR0, and BATs
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600287 */
288void mpc86xx_reginfo(void)
289{
290 immap_t *immap = (immap_t *)CFG_IMMR;
291 ccsr_lbc_t *lbc = &immap->im_lbc;
292
Becky Brucee34a0e92008-05-08 19:02:51 -0500293 print_bats();
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600294 print_laws();
295
296 printf ("Local Bus Controller Registers\n"
297 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
298 printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
299 printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
300 printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
301 printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
302 printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
303 printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
304 printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
Jon Loeligerdebb7352006-04-26 17:58:56 -0500305
306}
Ben Warrendd354792008-06-23 22:57:27 -0700307
308#ifdef CONFIG_TSEC_ENET
309/* Default initializations for TSEC controllers. To override,
310 * create a board-specific function called:
311 * int board_eth_init(bd_t *bis)
312 */
313
314extern int tsec_initialize(bd_t * bis, int index, char *devname);
315
316int cpu_eth_init(bd_t *bis)
317{
318#if defined(CONFIG_TSEC1)
319 tsec_initialize(bis, 0, CONFIG_TSEC1_NAME);
320#endif
321#if defined(CONFIG_TSEC2)
322 tsec_initialize(bis, 1, CONFIG_TSEC2_NAME);
323#endif
324#if defined(CONFIG_TSEC3)
325 tsec_initialize(bis, 2, CONFIG_TSEC3_NAME);
326#endif
327#if defined(CONFIG_TSEC4)
328 tsec_initialize(bis, 3, CONFIG_TSEC4_NAME);
329#endif
330 return 0;
331}
Wolfgang Denk4188f042008-07-10 01:13:30 +0200332#endif /* CONFIG_TSEC_ENET */