blob: e55d3372890665bc3059b64fcc3ad97138e4a76a [file] [log] [blame]
wdenk42d1f032003-10-15 23:53:47 +00001/*
Andy Fleming151d5d92007-04-23 01:32:22 -05002 * Copyright 2004,2007 Freescale Semiconductor, Inc.
wdenk42d1f032003-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
28#include <common.h>
29#include <watchdog.h>
30#include <command.h>
31#include <asm/cache.h>
32
wdenk42d1f032003-10-15 23:53:47 +000033int checkcpu (void)
34{
wdenk97d80fc2004-06-09 00:34:46 +000035 sys_info_t sysinfo;
36 uint lcrr; /* local bus clock ratio register */
37 uint clkdiv; /* clock divider portion of lcrr */
38 uint pvr, svr;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050039 uint fam;
wdenk97d80fc2004-06-09 00:34:46 +000040 uint ver;
41 uint major, minor;
wdenk42d1f032003-10-15 23:53:47 +000042
wdenk97d80fc2004-06-09 00:34:46 +000043 svr = get_svr();
44 ver = SVR_VER(svr);
45 major = SVR_MAJ(svr);
46 minor = SVR_MIN(svr);
47
wdenk6c9e7892005-03-15 22:56:53 +000048 puts("CPU: ");
wdenk97d80fc2004-06-09 00:34:46 +000049 switch (ver) {
50 case SVR_8540:
51 puts("8540");
52 break;
53 case SVR_8541:
54 puts("8541");
55 break;
56 case SVR_8555:
57 puts("8555");
58 break;
59 case SVR_8560:
60 puts("8560");
61 break;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050062 case SVR_8548:
63 puts("8548");
64 break;
65 case SVR_8548_E:
66 puts("8548_E");
67 break;
Andy Fleming151d5d92007-04-23 01:32:22 -050068 case SVR_8544:
Wolfgang Denk2f152782007-05-05 18:23:11 +020069 puts("8544");
70 break;
71 case SVR_8544_E:
72 puts("8544_E");
73 break;
74 case SVR_8568_E:
75 puts("8568_E");
76 break;
wdenk97d80fc2004-06-09 00:34:46 +000077 default:
78 puts("Unknown");
wdenk42d1f032003-10-15 23:53:47 +000079 break;
80 }
wdenk97d80fc2004-06-09 00:34:46 +000081 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
wdenk42d1f032003-10-15 23:53:47 +000082
wdenk6c9e7892005-03-15 22:56:53 +000083 pvr = get_pvr();
Jon Loeligerd9b94f22005-07-25 14:05:07 -050084 fam = PVR_FAM(pvr);
wdenk6c9e7892005-03-15 22:56:53 +000085 ver = PVR_VER(pvr);
86 major = PVR_MAJ(pvr);
87 minor = PVR_MIN(pvr);
88
89 printf("Core: ");
Jon Loeligerd9b94f22005-07-25 14:05:07 -050090 switch (fam) {
91 case PVR_FAM(PVR_85xx):
wdenk6c9e7892005-03-15 22:56:53 +000092 puts("E500");
93 break;
94 default:
95 puts("Unknown");
96 break;
97 }
98 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
99
wdenk97d80fc2004-06-09 00:34:46 +0000100 get_sys_info(&sysinfo);
101
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500102 puts("Clock Configuration:\n");
wdenk6c9e7892005-03-15 22:56:53 +0000103 printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
104 printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
105 printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
wdenk97d80fc2004-06-09 00:34:46 +0000106
107#if defined(CFG_LBC_LCRR)
108 lcrr = CFG_LBC_LCRR;
109#else
110 {
Kumar Gala04db4002007-11-29 02:10:09 -0600111 volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
wdenk97d80fc2004-06-09 00:34:46 +0000112
113 lcrr = lbc->lcrr;
114 }
115#endif
116 clkdiv = lcrr & 0x0f;
117 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
Andy Fleming151d5d92007-04-23 01:32:22 -0500118#if defined(CONFIG_MPC8548) || defined(CONFIG_MPC8544)
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500119 /*
120 * Yes, the entire PQ38 family use the same
121 * bit-representation for twice the clock divider values.
122 */
123 clkdiv *= 2;
124#endif
wdenk97d80fc2004-06-09 00:34:46 +0000125 printf("LBC:%4lu MHz\n",
126 sysinfo.freqSystemBus / 1000000 / clkdiv);
127 } else {
wdenk6c9e7892005-03-15 22:56:53 +0000128 printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
wdenk97d80fc2004-06-09 00:34:46 +0000129 }
130
131 if (ver == SVR_8560) {
wdenk6c9e7892005-03-15 22:56:53 +0000132 printf("CPM: %lu Mhz\n",
wdenk97d80fc2004-06-09 00:34:46 +0000133 sysinfo.freqSystemBus / 1000000);
134 }
135
wdenk6c9e7892005-03-15 22:56:53 +0000136 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
wdenk42d1f032003-10-15 23:53:47 +0000137
138 return 0;
139}
140
141
142/* ------------------------------------------------------------------------- */
143
144int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
145{
Zang Roy-r6191196629cb2006-12-05 16:42:30 +0800146 uint pvr;
147 uint ver;
148 pvr = get_pvr();
149 ver = PVR_VER(pvr);
150 if (ver & 1){
151 /* e500 v2 core has reset control register */
152 volatile unsigned int * rstcr;
153 rstcr = (volatile unsigned int *)(CFG_IMMR + 0xE00B0);
Wolfgang Denk2f152782007-05-05 18:23:11 +0200154 *rstcr = 0x2; /* HRESET_REQ */
Zang Roy-r6191196629cb2006-12-05 16:42:30 +0800155 }else{
wdenk42d1f032003-10-15 23:53:47 +0000156 /*
157 * Initiate hard reset in debug control register DBCR0
158 * Make sure MSR[DE] = 1
159 */
urwithsughosh@gmail.comdf909682007-09-24 13:32:13 -0400160 unsigned long val, msr;
161
162 msr = mfmsr ();
163 msr |= MSR_DE;
164 mtmsr (msr);
165
Zang Roy-r6191196629cb2006-12-05 16:42:30 +0800166 val = mfspr(DBCR0);
167 val |= 0x70000000;
168 mtspr(DBCR0,val);
169 }
wdenk42d1f032003-10-15 23:53:47 +0000170 return 1;
171}
172
173
174/*
175 * Get timebase clock frequency
176 */
177unsigned long get_tbclk (void)
178{
179
180 sys_info_t sys_info;
181
182 get_sys_info(&sys_info);
wdenk2a8af182005-04-13 10:02:42 +0000183 return ((sys_info.freqSystemBus + 7L) / 8L);
wdenk42d1f032003-10-15 23:53:47 +0000184}
185
186
187#if defined(CONFIG_WATCHDOG)
188void
189watchdog_reset(void)
190{
191 int re_enable = disable_interrupts();
192 reset_85xx_watchdog();
193 if (re_enable) enable_interrupts();
194}
195
196void
197reset_85xx_watchdog(void)
198{
199 /*
200 * Clear TSR(WIS) bit by writing 1
201 */
202 unsigned long val;
Andy Fleming03b81b42007-04-23 01:44:44 -0500203 val = mfspr(SPRN_TSR);
204 val |= TSR_WIS;
205 mtspr(SPRN_TSR, val);
wdenk42d1f032003-10-15 23:53:47 +0000206}
207#endif /* CONFIG_WATCHDOG */
208
209#if defined(CONFIG_DDR_ECC)
wdenk42d1f032003-10-15 23:53:47 +0000210void dma_init(void) {
Kumar Gala04db4002007-11-29 02:10:09 -0600211 volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
wdenk42d1f032003-10-15 23:53:47 +0000212
213 dma->satr0 = 0x02c40000;
214 dma->datr0 = 0x02c40000;
Andy Fleming03b81b42007-04-23 01:44:44 -0500215 dma->sr0 = 0xfffffff; /* clear any errors */
wdenk42d1f032003-10-15 23:53:47 +0000216 asm("sync; isync; msync");
217 return;
218}
219
220uint dma_check(void) {
Kumar Gala04db4002007-11-29 02:10:09 -0600221 volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
wdenk42d1f032003-10-15 23:53:47 +0000222 volatile uint status = dma->sr0;
223
224 /* While the channel is busy, spin */
225 while((status & 4) == 4) {
226 status = dma->sr0;
227 }
228
Andy Fleming03b81b42007-04-23 01:44:44 -0500229 /* clear MR0[CS] channel start bit */
230 dma->mr0 &= 0x00000001;
231 asm("sync;isync;msync");
232
wdenk42d1f032003-10-15 23:53:47 +0000233 if (status != 0) {
234 printf ("DMA Error: status = %x\n", status);
235 }
236 return status;
237}
238
239int dma_xfer(void *dest, uint count, void *src) {
Kumar Gala04db4002007-11-29 02:10:09 -0600240 volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
wdenk42d1f032003-10-15 23:53:47 +0000241
242 dma->dar0 = (uint) dest;
243 dma->sar0 = (uint) src;
244 dma->bcr0 = count;
245 dma->mr0 = 0xf000004;
246 asm("sync;isync;msync");
247 dma->mr0 = 0xf000005;
248 asm("sync;isync;msync");
249 return dma_check();
250}
251#endif