blob: f7fe22e3e1e1da1e28a651780e56ed2ead5f7a22 [file] [log] [blame]
wdenk42d1f032003-10-15 23:53:47 +00001/*
wdenk97d80fc2004-06-09 00:34:46 +00002 * Copyright 2004 Freescale Semiconductor.
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
33/* ------------------------------------------------------------------------- */
34
35int checkcpu (void)
36{
wdenk97d80fc2004-06-09 00:34:46 +000037 sys_info_t sysinfo;
38 uint lcrr; /* local bus clock ratio register */
39 uint clkdiv; /* clock divider portion of lcrr */
40 uint pvr, svr;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050041 uint fam;
wdenk97d80fc2004-06-09 00:34:46 +000042 uint ver;
43 uint major, minor;
wdenk42d1f032003-10-15 23:53:47 +000044
wdenk97d80fc2004-06-09 00:34:46 +000045 svr = get_svr();
46 ver = SVR_VER(svr);
47 major = SVR_MAJ(svr);
48 minor = SVR_MIN(svr);
49
wdenk6c9e7892005-03-15 22:56:53 +000050 puts("CPU: ");
wdenk97d80fc2004-06-09 00:34:46 +000051 switch (ver) {
52 case SVR_8540:
53 puts("8540");
54 break;
55 case SVR_8541:
56 puts("8541");
57 break;
58 case SVR_8555:
59 puts("8555");
60 break;
61 case SVR_8560:
62 puts("8560");
63 break;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050064 case SVR_8548:
65 puts("8548");
66 break;
67 case SVR_8548_E:
68 puts("8548_E");
69 break;
wdenk97d80fc2004-06-09 00:34:46 +000070 default:
71 puts("Unknown");
wdenk42d1f032003-10-15 23:53:47 +000072 break;
73 }
wdenk97d80fc2004-06-09 00:34:46 +000074 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
wdenk42d1f032003-10-15 23:53:47 +000075
wdenk6c9e7892005-03-15 22:56:53 +000076 pvr = get_pvr();
Jon Loeligerd9b94f22005-07-25 14:05:07 -050077 fam = PVR_FAM(pvr);
wdenk6c9e7892005-03-15 22:56:53 +000078 ver = PVR_VER(pvr);
79 major = PVR_MAJ(pvr);
80 minor = PVR_MIN(pvr);
81
82 printf("Core: ");
Jon Loeligerd9b94f22005-07-25 14:05:07 -050083 switch (fam) {
84 case PVR_FAM(PVR_85xx):
wdenk6c9e7892005-03-15 22:56:53 +000085 puts("E500");
86 break;
87 default:
88 puts("Unknown");
89 break;
90 }
91 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
92
wdenk97d80fc2004-06-09 00:34:46 +000093 get_sys_info(&sysinfo);
94
Jon Loeligerd9b94f22005-07-25 14:05:07 -050095 puts("Clock Configuration:\n");
wdenk6c9e7892005-03-15 22:56:53 +000096 printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
97 printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
98 printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
wdenk97d80fc2004-06-09 00:34:46 +000099
100#if defined(CFG_LBC_LCRR)
101 lcrr = CFG_LBC_LCRR;
102#else
103 {
104 volatile immap_t *immap = (immap_t *)CFG_IMMR;
105 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
106
107 lcrr = lbc->lcrr;
108 }
109#endif
110 clkdiv = lcrr & 0x0f;
111 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500112#ifdef CONFIG_MPC8548
113 /*
114 * Yes, the entire PQ38 family use the same
115 * bit-representation for twice the clock divider values.
116 */
117 clkdiv *= 2;
118#endif
wdenk97d80fc2004-06-09 00:34:46 +0000119 printf("LBC:%4lu MHz\n",
120 sysinfo.freqSystemBus / 1000000 / clkdiv);
121 } else {
wdenk6c9e7892005-03-15 22:56:53 +0000122 printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
wdenk97d80fc2004-06-09 00:34:46 +0000123 }
124
125 if (ver == SVR_8560) {
wdenk6c9e7892005-03-15 22:56:53 +0000126 printf("CPM: %lu Mhz\n",
wdenk97d80fc2004-06-09 00:34:46 +0000127 sysinfo.freqSystemBus / 1000000);
128 }
129
wdenk6c9e7892005-03-15 22:56:53 +0000130 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
wdenk42d1f032003-10-15 23:53:47 +0000131
132 return 0;
133}
134
135
136/* ------------------------------------------------------------------------- */
137
138int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
139{
140 /*
141 * Initiate hard reset in debug control register DBCR0
142 * Make sure MSR[DE] = 1
143 */
wdenk97d80fc2004-06-09 00:34:46 +0000144 unsigned long val;
145
146 val = mfspr(DBCR0);
147 val |= 0x70000000;
148 mtspr(DBCR0,val);
149
wdenk42d1f032003-10-15 23:53:47 +0000150 return 1;
151}
152
153
154/*
155 * Get timebase clock frequency
156 */
157unsigned long get_tbclk (void)
158{
159
160 sys_info_t sys_info;
161
162 get_sys_info(&sys_info);
wdenk2a8af182005-04-13 10:02:42 +0000163 return ((sys_info.freqSystemBus + 7L) / 8L);
wdenk42d1f032003-10-15 23:53:47 +0000164}
165
166
167#if defined(CONFIG_WATCHDOG)
168void
169watchdog_reset(void)
170{
171 int re_enable = disable_interrupts();
172 reset_85xx_watchdog();
173 if (re_enable) enable_interrupts();
174}
175
176void
177reset_85xx_watchdog(void)
178{
179 /*
180 * Clear TSR(WIS) bit by writing 1
181 */
182 unsigned long val;
183 val = mfspr(tsr);
184 val |= 0x40000000;
185 mtspr(tsr, val);
186}
187#endif /* CONFIG_WATCHDOG */
188
189#if defined(CONFIG_DDR_ECC)
wdenk42d1f032003-10-15 23:53:47 +0000190void dma_init(void) {
191 volatile immap_t *immap = (immap_t *)CFG_IMMR;
192 volatile ccsr_dma_t *dma = &immap->im_dma;
193
194 dma->satr0 = 0x02c40000;
195 dma->datr0 = 0x02c40000;
196 asm("sync; isync; msync");
197 return;
198}
199
200uint dma_check(void) {
201 volatile immap_t *immap = (immap_t *)CFG_IMMR;
202 volatile ccsr_dma_t *dma = &immap->im_dma;
203 volatile uint status = dma->sr0;
204
205 /* While the channel is busy, spin */
206 while((status & 4) == 4) {
207 status = dma->sr0;
208 }
209
210 if (status != 0) {
211 printf ("DMA Error: status = %x\n", status);
212 }
213 return status;
214}
215
216int dma_xfer(void *dest, uint count, void *src) {
217 volatile immap_t *immap = (immap_t *)CFG_IMMR;
218 volatile ccsr_dma_t *dma = &immap->im_dma;
219
220 dma->dar0 = (uint) dest;
221 dma->sar0 = (uint) src;
222 dma->bcr0 = count;
223 dma->mr0 = 0xf000004;
224 asm("sync;isync;msync");
225 dma->mr0 = 0xf000005;
226 asm("sync;isync;msync");
227 return dma_check();
228}
229#endif