blob: c41616d2fb024e830242265928e3d52d66ed9930 [file] [log] [blame]
Jon Loeliger5c8aa972006-04-26 17:58:56 -05001/*
Jon Loeligere65e32e2006-05-31 12:44:44 -05002 * Copyright 2006 Freescale Semiconductor
3 * Jeff Brown
Jon Loeliger5c8aa972006-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 Bruce7e07c772008-05-08 19:02:51 -050029#include <asm/mmu.h>
Jon Loeliger5c8aa972006-04-26 17:58:56 -050030#include <mpc86xx.h>
Andy Flemingfecff2b2008-08-31 16:33:26 -050031#include <tsec.h>
Becky Bruceb0b30942008-01-23 16:31:06 -060032#include <asm/fsl_law.h>
Jon Loeliger5c8aa972006-04-26 17:58:56 -050033
Jon Loeliger5c8aa972006-04-26 17:58:56 -050034
Peter Tyser69454402009-02-05 11:25:25 -060035/*
36 * Default board reset function
37 */
38static void
39__board_reset(void)
40{
41 /* Do nothing */
42}
43void board_reset(void) __attribute((weak, alias("__board_reset")));
44
45
Jon Loeligera1295442006-08-22 12:06:18 -050046int
47checkcpu(void)
Jon Loeliger5c8aa972006-04-26 17:58:56 -050048{
49 sys_info_t sysinfo;
50 uint pvr, svr;
51 uint ver;
52 uint major, minor;
Peter Tyser698f3a12009-02-06 14:30:40 -060053 char buf1[32], buf2[32];
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020054 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Jon Loeliger3b971c92007-10-16 15:26:51 -050055 volatile ccsr_gur_t *gur = &immap->im_gur;
Peter Tyser698f3a12009-02-06 14:30:40 -060056 uint msscr0 = mfspr(MSSCR0);
Jon Loeliger5c8aa972006-04-26 17:58:56 -050057
58 svr = get_svr();
Andy Flemingf5740972008-02-06 01:19:40 -060059 ver = SVR_SOC_VER(svr);
Jon Loeliger5c8aa972006-04-26 17:58:56 -050060 major = SVR_MAJ(svr);
61 minor = SVR_MIN(svr);
62
Peter Tyser698f3a12009-02-06 14:30:40 -060063 puts("CPU: ");
64
Jon Loeliger465b9d82006-04-27 10:15:16 -050065 switch (ver) {
Jon Loeliger5c8aa972006-04-26 17:58:56 -050066 case SVR_8641:
Jon Loeligerf57e8292006-09-14 08:40:36 -050067 puts("8641");
Peter Tyser698f3a12009-02-06 14:30:40 -060068 break;
69 case SVR_8641D:
70 puts("8641D");
71 break;
Jon Loeliger3b971c92007-10-16 15:26:51 -050072 case SVR_8610:
73 puts("8610");
74 break;
Jon Loeliger5c8aa972006-04-26 17:58:56 -050075 default:
76 puts("Unknown");
77 break;
78 }
79 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
Peter Tyser698f3a12009-02-06 14:30:40 -060080 puts("Core: ");
81
82 pvr = get_pvr();
83 ver = PVR_E600_VER(pvr);
84 major = PVR_E600_MAJ(pvr);
85 minor = PVR_E600_MIN(pvr);
86
87 printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
88 if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
89 puts("\n Core1Translation Enabled");
90 debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
91
92 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
Jon Loeliger5c8aa972006-04-26 17:58:56 -050093
94 get_sys_info(&sysinfo);
95
Peter Tyser698f3a12009-02-06 14:30:40 -060096 puts("Clock Configuration:\n");
97 printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor));
98 printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
99 printf(" DDR:%-4s MHz (%s MT/s data rate), ",
100 strmhz(buf1, sysinfo.freqSystemBus / 2),
101 strmhz(buf2, sysinfo.freqSystemBus));
Jon Loeliger465b9d82006-04-27 10:15:16 -0500102
Trent Piepho0b691fc2008-12-03 15:16:37 -0800103 if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
Peter Tyser698f3a12009-02-06 14:30:40 -0600104 printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500105 } else {
Wolfgang Denk3fe630c2009-01-12 14:50:35 +0100106 printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
Trent Piepho0b691fc2008-12-03 15:16:37 -0800107 sysinfo.freqLocalBus);
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500108 }
109
Peter Tyser698f3a12009-02-06 14:30:40 -0600110 puts("L1: D-cache 32 KB enabled\n");
111 puts(" I-cache 32 KB enabled\n");
112
113 puts("L2: ");
114 if (get_l2cr() & 0x80000000) {
115#if defined(CONFIG_MPC8610)
116 puts("256");
117#elif defined(CONFIG_MPC8641)
118 puts("512");
119#endif
120 puts(" KB enabled\n");
121 } else {
Jon Loeligere65e32e2006-05-31 12:44:44 -0500122 puts("Disabled\n");
Peter Tyser698f3a12009-02-06 14:30:40 -0600123 }
Jon Loeliger465b9d82006-04-27 10:15:16 -0500124
125 return 0;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500126}
127
128
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500129void
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500130do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500131{
Peter Tyser69454402009-02-05 11:25:25 -0600132 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
133 volatile ccsr_gur_t *gur = &immap->im_gur;
Jon Loeliger465b9d82006-04-27 10:15:16 -0500134
Peter Tyser69454402009-02-05 11:25:25 -0600135 /* Attempt board-specific reset */
136 board_reset();
Jon Loeliger465b9d82006-04-27 10:15:16 -0500137
Peter Tyser69454402009-02-05 11:25:25 -0600138 /* Next try asserting HRESET_REQ */
139 out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ);
Jon Loeliger465b9d82006-04-27 10:15:16 -0500140
Peter Tyser69454402009-02-05 11:25:25 -0600141 while (1)
142 ;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500143}
144
145
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500146/*
147 * Get timebase clock frequency
148 */
Jon Loeligera1295442006-08-22 12:06:18 -0500149unsigned long
150get_tbclk(void)
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500151{
Jon Loeligera1295442006-08-22 12:06:18 -0500152 sys_info_t sys_info;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500153
154 get_sys_info(&sys_info);
Jon Loeliger465b9d82006-04-27 10:15:16 -0500155 return (sys_info.freqSystemBus + 3L) / 4L;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500156}
157
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500158
159#if defined(CONFIG_WATCHDOG)
160void
161watchdog_reset(void)
162{
Jason Jin6c71b942008-05-13 11:50:36 +0800163#if defined(CONFIG_MPC8610)
164 /*
165 * This actually feed the hard enabled watchdog.
166 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200167 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
Jason Jin6c71b942008-05-13 11:50:36 +0800168 volatile ccsr_wdt_t *wdt = &immap->im_wdt;
169 volatile ccsr_gur_t *gur = &immap->im_gur;
170 u32 tmp = gur->pordevsr;
171
172 if (tmp & 0x4000) {
173 wdt->swsrr = 0x556c;
174 wdt->swsrr = 0xaa39;
175 }
176#endif
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500177}
178#endif /* CONFIG_WATCHDOG */
179
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500180
181#if defined(CONFIG_DDR_ECC)
Jon Loeligera1295442006-08-22 12:06:18 -0500182void
183dma_init(void)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500184{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200185 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500186 volatile ccsr_dma_t *dma = &immap->im_dma;
187
188 dma->satr0 = 0x00040000;
189 dma->datr0 = 0x00040000;
190 asm("sync; isync");
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500191}
192
Jon Loeligera1295442006-08-22 12:06:18 -0500193uint
194dma_check(void)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500195{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200196 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500197 volatile ccsr_dma_t *dma = &immap->im_dma;
198 volatile uint status = dma->sr0;
199
200 /* While the channel is busy, spin */
Jon Loeligera1295442006-08-22 12:06:18 -0500201 while ((status & 4) == 4) {
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500202 status = dma->sr0;
203 }
204
205 if (status != 0) {
Jon Loeligera1295442006-08-22 12:06:18 -0500206 printf("DMA Error: status = %x\n", status);
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500207 }
208 return status;
209}
210
Jon Loeligera1295442006-08-22 12:06:18 -0500211int
212dma_xfer(void *dest, uint count, void *src)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500213{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200214 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500215 volatile ccsr_dma_t *dma = &immap->im_dma;
216
217 dma->dar0 = (uint) dest;
218 dma->sar0 = (uint) src;
219 dma->bcr0 = count;
220 dma->mr0 = 0xf000004;
221 asm("sync;isync");
222 dma->mr0 = 0xf000005;
223 asm("sync;isync");
224 return dma_check();
225}
Jon Loeliger465b9d82006-04-27 10:15:16 -0500226
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500227#endif /* CONFIG_DDR_ECC */
228
Becky Bruceb0b30942008-01-23 16:31:06 -0600229
230/*
231 * Print out the state of various machine registers.
Becky Bruce7e07c772008-05-08 19:02:51 -0500232 * Currently prints out LAWs, BR0/OR0, and BATs
Becky Bruceb0b30942008-01-23 16:31:06 -0600233 */
234void mpc86xx_reginfo(void)
235{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200236 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
Becky Bruceb0b30942008-01-23 16:31:06 -0600237 ccsr_lbc_t *lbc = &immap->im_lbc;
238
Becky Bruce7e07c772008-05-08 19:02:51 -0500239 print_bats();
Becky Bruceb0b30942008-01-23 16:31:06 -0600240 print_laws();
241
242 printf ("Local Bus Controller Registers\n"
243 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
244 printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
245 printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
246 printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
247 printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
248 printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
249 printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
250 printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500251
252}
Ben Warrend448a492008-06-23 22:57:27 -0700253
Andy Flemingfecff2b2008-08-31 16:33:26 -0500254/*
255 * Initializes on-chip ethernet controllers.
256 * to override, implement board_eth_init()
Ben Warrend448a492008-06-23 22:57:27 -0700257 */
Ben Warrend448a492008-06-23 22:57:27 -0700258int cpu_eth_init(bd_t *bis)
259{
Andy Flemingfecff2b2008-08-31 16:33:26 -0500260#if defined(CONFIG_TSEC_ENET)
261 tsec_standard_init(bis);
Ben Warrend448a492008-06-23 22:57:27 -0700262#endif
Andy Flemingfecff2b2008-08-31 16:33:26 -0500263
Ben Warrend448a492008-06-23 22:57:27 -0700264 return 0;
265}