blob: 3c7476445d01e1093a2484b83628167ac9bd836f [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>
29#include <mpc86xx.h>
Becky Bruceb0b30942008-01-23 16:31:06 -060030#include <asm/fsl_law.h>
Jon Loeliger5c8aa972006-04-26 17:58:56 -050031
Jon Loeliger5c8aa972006-04-26 17:58:56 -050032
Jon Loeligera1295442006-08-22 12:06:18 -050033int
34checkcpu(void)
Jon Loeliger5c8aa972006-04-26 17:58:56 -050035{
36 sys_info_t sysinfo;
37 uint pvr, svr;
38 uint ver;
39 uint major, minor;
40 uint lcrr; /* local bus clock ratio register */
41 uint clkdiv; /* clock divider portion of lcrr */
Jon Loeliger3b971c92007-10-16 15:26:51 -050042 volatile immap_t *immap = (immap_t *) CFG_IMMR;
43 volatile ccsr_gur_t *gur = &immap->im_gur;
Jon Loeliger465b9d82006-04-27 10:15:16 -050044
Jon Loeliger5c8aa972006-04-26 17:58:56 -050045 puts("Freescale PowerPC\n");
46
47 pvr = get_pvr();
48 ver = PVR_VER(pvr);
49 major = PVR_MAJ(pvr);
50 minor = PVR_MIN(pvr);
51
Jon Loeliger465b9d82006-04-27 10:15:16 -050052 puts("CPU:\n");
Jon Loeligere65e32e2006-05-31 12:44:44 -050053 puts(" Core: ");
Jon Loeliger465b9d82006-04-27 10:15:16 -050054
Jon Loeliger5c8aa972006-04-26 17:58:56 -050055 switch (ver) {
56 case PVR_VER(PVR_86xx):
Jon Loeliger3b971c92007-10-16 15:26:51 -050057 {
58 uint msscr0 = mfspr(MSSCR0);
59 printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
60 if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
61 puts("\n Core1Translation Enabled");
62 debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
63 }
64 break;
Jon Loeliger5c8aa972006-04-26 17:58:56 -050065 default:
Jon Loeligera1295442006-08-22 12:06:18 -050066 puts("Unknown");
67 break;
Jon Loeliger5c8aa972006-04-26 17:58:56 -050068 }
69 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
70
71 svr = get_svr();
Andy Flemingf5740972008-02-06 01:19:40 -060072 ver = SVR_SOC_VER(svr);
Jon Loeliger5c8aa972006-04-26 17:58:56 -050073 major = SVR_MAJ(svr);
74 minor = SVR_MIN(svr);
75
76 puts(" System: ");
Jon Loeliger465b9d82006-04-27 10:15:16 -050077 switch (ver) {
Jon Loeliger5c8aa972006-04-26 17:58:56 -050078 case SVR_8641:
Jon Loeligerf57e8292006-09-14 08:40:36 -050079 if (SVR_SUBVER(svr) == 1) {
Jon Loeliger5c8aa972006-04-26 17:58:56 -050080 puts("8641D");
Jon Loeligerf57e8292006-09-14 08:40:36 -050081 } else {
82 puts("8641");
83 }
84 break;
Jon Loeliger3b971c92007-10-16 15:26:51 -050085 case SVR_8610:
86 puts("8610");
87 break;
Jon Loeliger5c8aa972006-04-26 17:58:56 -050088 default:
89 puts("Unknown");
90 break;
91 }
92 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
93
94 get_sys_info(&sysinfo);
95
96 puts(" Clocks: ");
97 printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
98 printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000);
99 printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
Jon Loeliger465b9d82006-04-27 10:15:16 -0500100
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500101#if defined(CFG_LBC_LCRR)
102 lcrr = CFG_LBC_LCRR;
103#else
104 {
Jon Loeligera1295442006-08-22 12:06:18 -0500105 volatile immap_t *immap = (immap_t *) CFG_IMMR;
106 volatile ccsr_lbc_t *lbc = &immap->im_lbc;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500107
Jon Loeligera1295442006-08-22 12:06:18 -0500108 lcrr = lbc->lcrr;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500109 }
110#endif
111 clkdiv = lcrr & 0x0f;
112 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
113 printf("LBC:%4lu MHz\n",
114 sysinfo.freqSystemBus / 1000000 / clkdiv);
115 } else {
116 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr);
117 }
118
Jon Loeligere65e32e2006-05-31 12:44:44 -0500119 puts(" L2: ");
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500120 if (get_l2cr() & 0x80000000)
Jon Loeligere65e32e2006-05-31 12:44:44 -0500121 puts("Enabled\n");
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500122 else
Jon Loeligere65e32e2006-05-31 12:44:44 -0500123 puts("Disabled\n");
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 -0500129static inline void
130soft_restart(unsigned long addr)
131{
Jason Jin333dd1d2007-10-26 18:32:00 +0800132#if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500133
Jon Loeligera1295442006-08-22 12:06:18 -0500134 /*
135 * SRR0 has system reset vector, SRR1 has default MSR value
136 * rfi restores MSR from SRR1 and sets the PC to the SRR0 value
137 */
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500138
139 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
140 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
141 __asm__ __volatile__ ("mtspr 27, 4");
142 __asm__ __volatile__ ("rfi");
143
144#else /* CONFIG_MPC8641HPCN */
Jon Loeligere65e32e2006-05-31 12:44:44 -0500145
146 out8(PIXIS_BASE + PIXIS_RST, 0);
147
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500148#endif /* !CONFIG_MPC8641HPCN */
Jon Loeligere65e32e2006-05-31 12:44:44 -0500149
Jon Loeligera1295442006-08-22 12:06:18 -0500150 while (1) ; /* not reached */
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500151}
152
153
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500154/*
155 * No generic way to do board reset. Simply call soft_reset.
156 */
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500157void
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500158do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500159{
Jason Jin333dd1d2007-10-26 18:32:00 +0800160#if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500161
162#ifdef CFG_RESET_ADDRESS
Jon Loeligere65e32e2006-05-31 12:44:44 -0500163 ulong addr = CFG_RESET_ADDRESS;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500164#else
165 /*
166 * note: when CFG_MONITOR_BASE points to a RAM address,
167 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
168 * address. Better pick an address known to be invalid on your
169 * system and assign it to CFG_RESET_ADDRESS.
170 */
Jon Loeligere65e32e2006-05-31 12:44:44 -0500171 ulong addr = CFG_MONITOR_BASE - sizeof(ulong);
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500172#endif
173
Jon Loeliger465b9d82006-04-27 10:15:16 -0500174 /* flush and disable I/D cache */
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500175 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
176 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
177 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
178 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
179 __asm__ __volatile__ ("sync");
180 __asm__ __volatile__ ("mtspr 1008, 4");
181 __asm__ __volatile__ ("isync");
182 __asm__ __volatile__ ("sync");
183 __asm__ __volatile__ ("mtspr 1008, 5");
184 __asm__ __volatile__ ("isync");
185 __asm__ __volatile__ ("sync");
186
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500187 soft_restart(addr);
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500188
189#else /* CONFIG_MPC8641HPCN */
Jon Loeliger465b9d82006-04-27 10:15:16 -0500190
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600191 out8(PIXIS_BASE + PIXIS_RST, 0);
Jon Loeliger465b9d82006-04-27 10:15:16 -0500192
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500193#endif /* !CONFIG_MPC8641HPCN */
Jon Loeliger465b9d82006-04-27 10:15:16 -0500194
Jon Loeligera1295442006-08-22 12:06:18 -0500195 while (1) ; /* not reached */
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500196}
197
198
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500199/*
200 * Get timebase clock frequency
201 */
Jon Loeligera1295442006-08-22 12:06:18 -0500202unsigned long
203get_tbclk(void)
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500204{
Jon Loeligera1295442006-08-22 12:06:18 -0500205 sys_info_t sys_info;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500206
207 get_sys_info(&sys_info);
Jon Loeliger465b9d82006-04-27 10:15:16 -0500208 return (sys_info.freqSystemBus + 3L) / 4L;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500209}
210
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500211
212#if defined(CONFIG_WATCHDOG)
213void
214watchdog_reset(void)
215{
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500216}
217#endif /* CONFIG_WATCHDOG */
218
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500219
220#if defined(CONFIG_DDR_ECC)
Jon Loeligera1295442006-08-22 12:06:18 -0500221void
222dma_init(void)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500223{
Jon Loeligera1295442006-08-22 12:06:18 -0500224 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500225 volatile ccsr_dma_t *dma = &immap->im_dma;
226
227 dma->satr0 = 0x00040000;
228 dma->datr0 = 0x00040000;
229 asm("sync; isync");
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500230}
231
Jon Loeligera1295442006-08-22 12:06:18 -0500232uint
233dma_check(void)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500234{
Jon Loeligera1295442006-08-22 12:06:18 -0500235 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500236 volatile ccsr_dma_t *dma = &immap->im_dma;
237 volatile uint status = dma->sr0;
238
239 /* While the channel is busy, spin */
Jon Loeligera1295442006-08-22 12:06:18 -0500240 while ((status & 4) == 4) {
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500241 status = dma->sr0;
242 }
243
244 if (status != 0) {
Jon Loeligera1295442006-08-22 12:06:18 -0500245 printf("DMA Error: status = %x\n", status);
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500246 }
247 return status;
248}
249
Jon Loeligera1295442006-08-22 12:06:18 -0500250int
251dma_xfer(void *dest, uint count, void *src)
Jon Loeliger465b9d82006-04-27 10:15:16 -0500252{
Jon Loeligera1295442006-08-22 12:06:18 -0500253 volatile immap_t *immap = (immap_t *) CFG_IMMR;
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500254 volatile ccsr_dma_t *dma = &immap->im_dma;
255
256 dma->dar0 = (uint) dest;
257 dma->sar0 = (uint) src;
258 dma->bcr0 = count;
259 dma->mr0 = 0xf000004;
260 asm("sync;isync");
261 dma->mr0 = 0xf000005;
262 asm("sync;isync");
263 return dma_check();
264}
Jon Loeliger465b9d82006-04-27 10:15:16 -0500265
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500266#endif /* CONFIG_DDR_ECC */
267
Becky Bruceb0b30942008-01-23 16:31:06 -0600268
269/*
270 * Print out the state of various machine registers.
271 * Currently prints out LAWs and BR0/OR0
272 */
273void mpc86xx_reginfo(void)
274{
275 immap_t *immap = (immap_t *)CFG_IMMR;
276 ccsr_lbc_t *lbc = &immap->im_lbc;
277
278 print_laws();
279
280 printf ("Local Bus Controller Registers\n"
281 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
282 printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
283 printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
284 printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
285 printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
286 printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
287 printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
288 printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
Jon Loeliger5c8aa972006-04-26 17:58:56 -0500289
290}