blob: fb8fa5ec5135697d85b534f8e5effd1e91dd53d2 [file] [log] [blame]
wdenk9c53f402003-10-15 23:53:47 +00001/*
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +08002 * Copyright 2004,2007-2010 Freescale Semiconductor, Inc.
wdenk9c53f402003-10-15 23:53:47 +00003 * (C) Copyright 2002, 2003 Motorola Inc.
4 * Xianghua Xiao (X.Xiao@motorola.com)
5 *
6 * (C) Copyright 2000
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
Andy Flemingfecff2b2008-08-31 16:33:26 -050028#include <config.h>
wdenk9c53f402003-10-15 23:53:47 +000029#include <common.h>
30#include <watchdog.h>
31#include <command.h>
Andy Fleming6843a6e2008-10-30 16:51:33 -050032#include <fsl_esdhc.h>
wdenk9c53f402003-10-15 23:53:47 +000033#include <asm/cache.h>
Sergei Poselenovddc1a472008-06-06 15:42:40 +020034#include <asm/io.h>
Becky Bruceee888da2010-06-17 11:37:25 -050035#include <asm/mmu.h>
36#include <asm/fsl_law.h>
wdenk9c53f402003-10-15 23:53:47 +000037
James Yang957b1912008-02-08 16:44:53 -060038DECLARE_GLOBAL_DATA_PTR;
39
wdenk9c53f402003-10-15 23:53:47 +000040int checkcpu (void)
41{
wdenka445ddf2004-06-09 00:34:46 +000042 sys_info_t sysinfo;
wdenka445ddf2004-06-09 00:34:46 +000043 uint pvr, svr;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050044 uint fam;
wdenka445ddf2004-06-09 00:34:46 +000045 uint ver;
46 uint major, minor;
Kumar Gala8ddf00c2008-06-10 16:53:46 -050047 struct cpu_type *cpu;
Wolfgang Denk20591042008-10-19 02:35:49 +020048 char buf1[32], buf2[32];
Kumar Gala1d39c9a2010-04-13 11:07:57 -050049#if defined(CONFIG_DDR_CLK_FREQ) || defined(CONFIG_FSL_CORENET)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020050 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kumar Gala1d39c9a2010-04-13 11:07:57 -050051#endif /* CONFIG_FSL_CORENET */
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +080052#ifdef CONFIG_DDR_CLK_FREQ
Jason Jinbfcd6c32008-09-27 14:40:57 +080053 u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
54 >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
Kumar Galadccd9e32009-03-19 02:46:19 -050055#else
56#ifdef CONFIG_FSL_CORENET
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +080057 u32 ddr_sync = ((gur->rcwsr[5]) & FSL_CORENET_RCWSR5_DDR_SYNC)
58 >> FSL_CORENET_RCWSR5_DDR_SYNC_SHIFT;
Kumar Gala54b68102008-05-29 01:21:24 -050059#else
60 u32 ddr_ratio = 0;
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +080061#endif /* CONFIG_FSL_CORENET */
Kumar Galadccd9e32009-03-19 02:46:19 -050062#endif /* CONFIG_DDR_CLK_FREQ */
Haiying Wangbb8aea72009-01-15 11:58:35 -050063 int i;
wdenk9c53f402003-10-15 23:53:47 +000064
wdenka445ddf2004-06-09 00:34:46 +000065 svr = get_svr();
wdenka445ddf2004-06-09 00:34:46 +000066 major = SVR_MAJ(svr);
Kumar Galacd777282008-08-12 11:14:19 -050067#ifdef CONFIG_MPC8536
68 major &= 0x7; /* the msb of this nibble is a mfg code */
69#endif
wdenka445ddf2004-06-09 00:34:46 +000070 minor = SVR_MIN(svr);
71
Poonam Aggrwal4baef822009-07-31 12:08:14 +053072 if (cpu_numcores() > 1) {
Poonam Aggrwal36a68432009-09-03 19:42:40 +053073#ifndef CONFIG_MP
74 puts("Unicore software on multiprocessor system!!\n"
75 "To enable mutlticore build define CONFIG_MP\n");
76#endif
Poonam Aggrwal4baef822009-07-31 12:08:14 +053077 volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC85xx_PIC_ADDR);
78 printf("CPU%d: ", pic->whoami);
79 } else {
80 puts("CPU: ");
81 }
Andy Flemingf5740972008-02-06 01:19:40 -060082
Poonam Aggrwal4baef822009-07-31 12:08:14 +053083 cpu = gd->cpu;
Andy Flemingf5740972008-02-06 01:19:40 -060084
Poonam Aggrwalda6e1ca2009-09-02 13:35:21 +053085 puts(cpu->name);
86 if (IS_E_PROCESSOR(svr))
87 puts("E");
Andy Flemingf5740972008-02-06 01:19:40 -060088
wdenka445ddf2004-06-09 00:34:46 +000089 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
wdenk9c53f402003-10-15 23:53:47 +000090
wdenk3f3262b2005-03-15 22:56:53 +000091 pvr = get_pvr();
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050092 fam = PVR_FAM(pvr);
wdenk3f3262b2005-03-15 22:56:53 +000093 ver = PVR_VER(pvr);
94 major = PVR_MAJ(pvr);
95 minor = PVR_MIN(pvr);
96
97 printf("Core: ");
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050098 switch (fam) {
99 case PVR_FAM(PVR_85xx):
wdenk3f3262b2005-03-15 22:56:53 +0000100 puts("E500");
101 break;
102 default:
103 puts("Unknown");
104 break;
105 }
Kumar Gala9f4a6892008-10-23 01:47:38 -0500106
107 if (PVR_MEM(pvr) == 0x03)
108 puts("MC");
109
wdenk3f3262b2005-03-15 22:56:53 +0000110 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
111
wdenka445ddf2004-06-09 00:34:46 +0000112 get_sys_info(&sysinfo);
113
Kumar Galaf92794c2009-02-04 09:35:57 -0600114 puts("Clock Configuration:");
Poonam Aggrwal4baef822009-07-31 12:08:14 +0530115 for (i = 0; i < cpu_numcores(); i++) {
Wolfgang Denk1f79d142009-02-19 00:41:08 +0100116 if (!(i & 3))
117 printf ("\n ");
Haiying Wangbb8aea72009-01-15 11:58:35 -0500118 printf("CPU%d:%-4s MHz, ",
119 i,strmhz(buf1, sysinfo.freqProcessor[i]));
Kumar Galaf92794c2009-02-04 09:35:57 -0600120 }
121 printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus));
Kumar Gala54b68102008-05-29 01:21:24 -0500122
Kumar Galadccd9e32009-03-19 02:46:19 -0500123#ifdef CONFIG_FSL_CORENET
124 if (ddr_sync == 1) {
125 printf(" DDR:%-4s MHz (%s MT/s data rate) "
126 "(Synchronous), ",
127 strmhz(buf1, sysinfo.freqDDRBus/2),
128 strmhz(buf2, sysinfo.freqDDRBus));
129 } else {
130 printf(" DDR:%-4s MHz (%s MT/s data rate) "
131 "(Asynchronous), ",
132 strmhz(buf1, sysinfo.freqDDRBus/2),
133 strmhz(buf2, sysinfo.freqDDRBus));
134 }
135#else
Kumar Gala07db1702007-12-07 04:59:26 -0600136 switch (ddr_ratio) {
137 case 0x0:
Wolfgang Denk20591042008-10-19 02:35:49 +0200138 printf(" DDR:%-4s MHz (%s MT/s data rate), ",
139 strmhz(buf1, sysinfo.freqDDRBus/2),
140 strmhz(buf2, sysinfo.freqDDRBus));
Kumar Gala07db1702007-12-07 04:59:26 -0600141 break;
142 case 0x7:
Kumar Galadccd9e32009-03-19 02:46:19 -0500143 printf(" DDR:%-4s MHz (%s MT/s data rate) "
144 "(Synchronous), ",
Wolfgang Denk20591042008-10-19 02:35:49 +0200145 strmhz(buf1, sysinfo.freqDDRBus/2),
146 strmhz(buf2, sysinfo.freqDDRBus));
Kumar Gala07db1702007-12-07 04:59:26 -0600147 break;
148 default:
Kumar Galadccd9e32009-03-19 02:46:19 -0500149 printf(" DDR:%-4s MHz (%s MT/s data rate) "
150 "(Asynchronous), ",
Wolfgang Denk20591042008-10-19 02:35:49 +0200151 strmhz(buf1, sysinfo.freqDDRBus/2),
152 strmhz(buf2, sysinfo.freqDDRBus));
Kumar Gala07db1702007-12-07 04:59:26 -0600153 break;
154 }
Kumar Galadccd9e32009-03-19 02:46:19 -0500155#endif
wdenka445ddf2004-06-09 00:34:46 +0000156
Kumar Galadccd9e32009-03-19 02:46:19 -0500157 if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
Trent Piepho0b691fc2008-12-03 15:16:37 -0800158 printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
Kumar Galadccd9e32009-03-19 02:46:19 -0500159 } else {
Trent Piepho0b691fc2008-12-03 15:16:37 -0800160 printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
161 sysinfo.freqLocalBus);
Kumar Galadccd9e32009-03-19 02:46:19 -0500162 }
wdenka445ddf2004-06-09 00:34:46 +0000163
Andy Flemingf5740972008-02-06 01:19:40 -0600164#ifdef CONFIG_CPM2
Wolfgang Denk20591042008-10-19 02:35:49 +0200165 printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
Andy Flemingf5740972008-02-06 01:19:40 -0600166#endif
wdenka445ddf2004-06-09 00:34:46 +0000167
Haiying Wang61414682009-05-20 12:30:29 -0400168#ifdef CONFIG_QE
169 printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE));
170#endif
171
Kumar Galadccd9e32009-03-19 02:46:19 -0500172#ifdef CONFIG_SYS_DPAA_FMAN
173 for (i = 0; i < CONFIG_SYS_NUM_FMAN; i++) {
174 printf(" FMAN%d: %s MHz\n", i,
175 strmhz(buf1, sysinfo.freqFMan[i]));
176 }
177#endif
178
179#ifdef CONFIG_SYS_DPAA_PME
180 printf(" PME: %s MHz\n", strmhz(buf1, sysinfo.freqPME));
181#endif
182
wdenk3f3262b2005-03-15 22:56:53 +0000183 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
wdenk9c53f402003-10-15 23:53:47 +0000184
185 return 0;
186}
187
188
189/* ------------------------------------------------------------------------- */
190
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200191int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char * const argv[])
wdenk9c53f402003-10-15 23:53:47 +0000192{
Kumar Galaaff01532009-09-08 13:46:46 -0500193/* Everything after the first generation of PQ3 parts has RSTCR */
194#if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
195 defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560)
Sergei Poselenov25147422008-05-08 14:17:08 +0200196 unsigned long val, msr;
197
wdenk9c53f402003-10-15 23:53:47 +0000198 /*
199 * Initiate hard reset in debug control register DBCR0
Kumar Galaaff01532009-09-08 13:46:46 -0500200 * Make sure MSR[DE] = 1. This only resets the core.
wdenk9c53f402003-10-15 23:53:47 +0000201 */
Sergei Poselenov25147422008-05-08 14:17:08 +0200202 msr = mfmsr ();
203 msr |= MSR_DE;
204 mtmsr (msr);
urwithsughosh@gmail.com06c2fb92007-09-24 13:32:13 -0400205
Sergei Poselenov25147422008-05-08 14:17:08 +0200206 val = mfspr(DBCR0);
207 val |= 0x70000000;
208 mtspr(DBCR0,val);
Kumar Galaaff01532009-09-08 13:46:46 -0500209#else
210 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
211 out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */
212 udelay(100);
213#endif
Sergei Poselenov25147422008-05-08 14:17:08 +0200214
wdenk9c53f402003-10-15 23:53:47 +0000215 return 1;
216}
217
218
219/*
220 * Get timebase clock frequency
221 */
222unsigned long get_tbclk (void)
223{
Kumar Gala24f86a82009-09-17 01:52:37 -0500224#ifdef CONFIG_FSL_CORENET
225 return (gd->bus_clk + 8) / 16;
226#else
James Yang957b1912008-02-08 16:44:53 -0600227 return (gd->bus_clk + 4UL)/8UL;
Kumar Gala24f86a82009-09-17 01:52:37 -0500228#endif
wdenk9c53f402003-10-15 23:53:47 +0000229}
230
231
232#if defined(CONFIG_WATCHDOG)
233void
234watchdog_reset(void)
235{
236 int re_enable = disable_interrupts();
237 reset_85xx_watchdog();
238 if (re_enable) enable_interrupts();
239}
240
241void
242reset_85xx_watchdog(void)
243{
244 /*
245 * Clear TSR(WIS) bit by writing 1
246 */
247 unsigned long val;
Andy Flemingeac342d2007-04-23 01:44:44 -0500248 val = mfspr(SPRN_TSR);
249 val |= TSR_WIS;
250 mtspr(SPRN_TSR, val);
wdenk9c53f402003-10-15 23:53:47 +0000251}
252#endif /* CONFIG_WATCHDOG */
253
Sergei Poselenovddc1a472008-06-06 15:42:40 +0200254/*
Andy Fleming6843a6e2008-10-30 16:51:33 -0500255 * Initializes on-chip MMC controllers.
256 * to override, implement board_mmc_init()
257 */
258int cpu_mmc_init(bd_t *bis)
259{
260#ifdef CONFIG_FSL_ESDHC
261 return fsl_esdhc_mmc_init(bis);
262#else
263 return 0;
264#endif
265}
Becky Bruceee888da2010-06-17 11:37:25 -0500266
267/*
268 * Print out the state of various machine registers.
269 * Currently prints out LAWs, BR0/OR0, and TLBs
270 */
271void mpc85xx_reginfo(void)
272{
273 print_tlbcam();
274 print_laws();
275 print_lbc_regs();
276}