blob: 04409cec68f446c528c58bf24e9ff132fbd8c054 [file] [log] [blame]
Jon Loeligerdebb7352006-04-26 17:58:56 -05001/*
Poonam Aggrwal18bacc22009-07-31 12:07:45 +05302 * Copyright 2006,2009 Freescale Semiconductor, Inc.
Jon Loeligercb5965f2006-05-31 12:44:44 -05003 * 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
Poonam Aggrwal0e870982009-07-31 12:08:14 +053033DECLARE_GLOBAL_DATA_PTR;
34
Peter Tyser4ef630d2009-02-05 11:25:25 -060035/*
36 * Default board reset function
37 */
38static void
39__board_reset(void)
40{
41 /* Do nothing */
42}
Peter Tyserf9a109b2009-04-20 11:08:46 -050043void board_reset(void) __attribute__((weak, alias("__board_reset")));
Peter Tyser4ef630d2009-02-05 11:25:25 -060044
45
Jon Loeligerffff3ae2006-08-22 12:06:18 -050046int
47checkcpu(void)
Jon Loeligerdebb7352006-04-26 17:58:56 -050048{
49 sys_info_t sysinfo;
50 uint pvr, svr;
51 uint ver;
52 uint major, minor;
Peter Tysera1c8a712009-02-06 14:30:40 -060053 char buf1[32], buf2[32];
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020054 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Jon Loeliger9553df82007-10-16 15:26:51 -050055 volatile ccsr_gur_t *gur = &immap->im_gur;
Kumar Gala480f6172009-06-18 08:23:01 -050056 struct cpu_type *cpu;
Peter Tysera1c8a712009-02-06 14:30:40 -060057 uint msscr0 = mfspr(MSSCR0);
Jon Loeligerdebb7352006-04-26 17:58:56 -050058
59 svr = get_svr();
Andy Fleming1ced1212008-02-06 01:19:40 -060060 ver = SVR_SOC_VER(svr);
Jon Loeligerdebb7352006-04-26 17:58:56 -050061 major = SVR_MAJ(svr);
62 minor = SVR_MIN(svr);
63
Peter Tysera1c8a712009-02-06 14:30:40 -060064 puts("CPU: ");
65
Poonam Aggrwal0e870982009-07-31 12:08:14 +053066 cpu = gd->cpu;
67
68 if (cpu->name)
Kumar Gala480f6172009-06-18 08:23:01 -050069 puts(cpu->name);
Poonam Aggrwal0e870982009-07-31 12:08:14 +053070 else
Jon Loeligerdebb7352006-04-26 17:58:56 -050071 puts("Unknown");
Kumar Gala480f6172009-06-18 08:23:01 -050072
Jon Loeligerdebb7352006-04-26 17:58:56 -050073 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
Peter Tysera1c8a712009-02-06 14:30:40 -060074 puts("Core: ");
75
76 pvr = get_pvr();
77 ver = PVR_E600_VER(pvr);
78 major = PVR_E600_MAJ(pvr);
79 minor = PVR_E600_MIN(pvr);
80
81 printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
82 if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
83 puts("\n Core1Translation Enabled");
84 debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
85
86 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
Jon Loeligerdebb7352006-04-26 17:58:56 -050087
88 get_sys_info(&sysinfo);
89
Peter Tysera1c8a712009-02-06 14:30:40 -060090 puts("Clock Configuration:\n");
91 printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor));
92 printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
93 printf(" DDR:%-4s MHz (%s MT/s data rate), ",
94 strmhz(buf1, sysinfo.freqSystemBus / 2),
95 strmhz(buf2, sysinfo.freqSystemBus));
Jon Loeliger5c9efb32006-04-27 10:15:16 -050096
Trent Piephoada591d2008-12-03 15:16:37 -080097 if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
Peter Tysera1c8a712009-02-06 14:30:40 -060098 printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
Jon Loeligerdebb7352006-04-26 17:58:56 -050099 } else {
Wolfgang Denka9f3acb2009-01-12 14:50:35 +0100100 printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
Trent Piephoada591d2008-12-03 15:16:37 -0800101 sysinfo.freqLocalBus);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500102 }
103
Peter Tysera1c8a712009-02-06 14:30:40 -0600104 puts("L1: D-cache 32 KB enabled\n");
105 puts(" I-cache 32 KB enabled\n");
106
107 puts("L2: ");
108 if (get_l2cr() & 0x80000000) {
109#if defined(CONFIG_MPC8610)
110 puts("256");
111#elif defined(CONFIG_MPC8641)
112 puts("512");
113#endif
114 puts(" KB enabled\n");
115 } else {
Jon Loeligercb5965f2006-05-31 12:44:44 -0500116 puts("Disabled\n");
Peter Tysera1c8a712009-02-06 14:30:40 -0600117 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500118
119 return 0;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500120}
121
122
Jon Loeligerdebb7352006-04-26 17:58:56 -0500123void
Jon Loeliger126aa702006-05-30 17:47:00 -0500124do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
Jon Loeligerdebb7352006-04-26 17:58:56 -0500125{
Peter Tyser4ef630d2009-02-05 11:25:25 -0600126 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
127 volatile ccsr_gur_t *gur = &immap->im_gur;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500128
Peter Tyser4ef630d2009-02-05 11:25:25 -0600129 /* Attempt board-specific reset */
130 board_reset();
Jon Loeligerdebb7352006-04-26 17:58:56 -0500131
Peter Tyser4ef630d2009-02-05 11:25:25 -0600132 /* Next try asserting HRESET_REQ */
133 out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500134
Peter Tyser4ef630d2009-02-05 11:25:25 -0600135 while (1)
136 ;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500137}
138
139
Jon Loeligerdebb7352006-04-26 17:58:56 -0500140/*
141 * Get timebase clock frequency
142 */
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500143unsigned long
144get_tbclk(void)
Jon Loeligerdebb7352006-04-26 17:58:56 -0500145{
Jon Loeligerffff3ae2006-08-22 12:06:18 -0500146 sys_info_t sys_info;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500147
148 get_sys_info(&sys_info);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500149 return (sys_info.freqSystemBus + 3L) / 4L;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500150}
151
Jon Loeligerdebb7352006-04-26 17:58:56 -0500152
153#if defined(CONFIG_WATCHDOG)
154void
155watchdog_reset(void)
156{
Jason Jin3473ab72008-05-13 11:50:36 +0800157#if defined(CONFIG_MPC8610)
158 /*
159 * This actually feed the hard enabled watchdog.
160 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200161 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
Jason Jin3473ab72008-05-13 11:50:36 +0800162 volatile ccsr_wdt_t *wdt = &immap->im_wdt;
163 volatile ccsr_gur_t *gur = &immap->im_gur;
164 u32 tmp = gur->pordevsr;
165
166 if (tmp & 0x4000) {
167 wdt->swsrr = 0x556c;
168 wdt->swsrr = 0xaa39;
169 }
170#endif
Jon Loeligerdebb7352006-04-26 17:58:56 -0500171}
172#endif /* CONFIG_WATCHDOG */
173
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600174/*
175 * Print out the state of various machine registers.
Becky Brucee34a0e92008-05-08 19:02:51 -0500176 * Currently prints out LAWs, BR0/OR0, and BATs
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600177 */
178void mpc86xx_reginfo(void)
179{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200180 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600181 ccsr_lbc_t *lbc = &immap->im_lbc;
182
Becky Brucee34a0e92008-05-08 19:02:51 -0500183 print_bats();
Becky Bruce4f93f8b2008-01-23 16:31:06 -0600184 print_laws();
185
186 printf ("Local Bus Controller Registers\n"
187 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
188 printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
189 printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
190 printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
191 printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
192 printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
193 printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
194 printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
Jon Loeligerdebb7352006-04-26 17:58:56 -0500195
196}