blob: 0507c47e6e74dc66d04adffe35631138be9dc302 [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
Matthew McClintock40d5fa32006-06-28 10:43:36 -050033#if defined(CONFIG_OF_FLAT_TREE)
34#include <ft_build.h>
35#endif
36
wdenk42d1f032003-10-15 23:53:47 +000037
38int checkcpu (void)
39{
wdenk97d80fc2004-06-09 00:34:46 +000040 sys_info_t sysinfo;
41 uint lcrr; /* local bus clock ratio register */
42 uint clkdiv; /* clock divider portion of lcrr */
43 uint pvr, svr;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050044 uint fam;
wdenk97d80fc2004-06-09 00:34:46 +000045 uint ver;
46 uint major, minor;
wdenk42d1f032003-10-15 23:53:47 +000047
wdenk97d80fc2004-06-09 00:34:46 +000048 svr = get_svr();
49 ver = SVR_VER(svr);
50 major = SVR_MAJ(svr);
51 minor = SVR_MIN(svr);
52
wdenk6c9e7892005-03-15 22:56:53 +000053 puts("CPU: ");
wdenk97d80fc2004-06-09 00:34:46 +000054 switch (ver) {
55 case SVR_8540:
56 puts("8540");
57 break;
58 case SVR_8541:
59 puts("8541");
60 break;
61 case SVR_8555:
62 puts("8555");
63 break;
64 case SVR_8560:
65 puts("8560");
66 break;
Jon Loeligerd9b94f22005-07-25 14:05:07 -050067 case SVR_8548:
68 puts("8548");
69 break;
70 case SVR_8548_E:
71 puts("8548_E");
72 break;
wdenk97d80fc2004-06-09 00:34:46 +000073 default:
74 puts("Unknown");
wdenk42d1f032003-10-15 23:53:47 +000075 break;
76 }
wdenk97d80fc2004-06-09 00:34:46 +000077 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
wdenk42d1f032003-10-15 23:53:47 +000078
wdenk6c9e7892005-03-15 22:56:53 +000079 pvr = get_pvr();
Jon Loeligerd9b94f22005-07-25 14:05:07 -050080 fam = PVR_FAM(pvr);
wdenk6c9e7892005-03-15 22:56:53 +000081 ver = PVR_VER(pvr);
82 major = PVR_MAJ(pvr);
83 minor = PVR_MIN(pvr);
84
85 printf("Core: ");
Jon Loeligerd9b94f22005-07-25 14:05:07 -050086 switch (fam) {
87 case PVR_FAM(PVR_85xx):
wdenk6c9e7892005-03-15 22:56:53 +000088 puts("E500");
89 break;
90 default:
91 puts("Unknown");
92 break;
93 }
94 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
95
wdenk97d80fc2004-06-09 00:34:46 +000096 get_sys_info(&sysinfo);
97
Jon Loeligerd9b94f22005-07-25 14:05:07 -050098 puts("Clock Configuration:\n");
wdenk6c9e7892005-03-15 22:56:53 +000099 printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
100 printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
101 printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
wdenk97d80fc2004-06-09 00:34:46 +0000102
103#if defined(CFG_LBC_LCRR)
104 lcrr = CFG_LBC_LCRR;
105#else
106 {
107 volatile immap_t *immap = (immap_t *)CFG_IMMR;
108 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
109
110 lcrr = lbc->lcrr;
111 }
112#endif
113 clkdiv = lcrr & 0x0f;
114 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500115#ifdef CONFIG_MPC8548
116 /*
117 * Yes, the entire PQ38 family use the same
118 * bit-representation for twice the clock divider values.
119 */
120 clkdiv *= 2;
121#endif
wdenk97d80fc2004-06-09 00:34:46 +0000122 printf("LBC:%4lu MHz\n",
123 sysinfo.freqSystemBus / 1000000 / clkdiv);
124 } else {
wdenk6c9e7892005-03-15 22:56:53 +0000125 printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
wdenk97d80fc2004-06-09 00:34:46 +0000126 }
127
128 if (ver == SVR_8560) {
wdenk6c9e7892005-03-15 22:56:53 +0000129 printf("CPM: %lu Mhz\n",
wdenk97d80fc2004-06-09 00:34:46 +0000130 sysinfo.freqSystemBus / 1000000);
131 }
132
wdenk6c9e7892005-03-15 22:56:53 +0000133 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
wdenk42d1f032003-10-15 23:53:47 +0000134
135 return 0;
136}
137
138
139/* ------------------------------------------------------------------------- */
140
141int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
142{
143 /*
144 * Initiate hard reset in debug control register DBCR0
145 * Make sure MSR[DE] = 1
146 */
wdenk97d80fc2004-06-09 00:34:46 +0000147 unsigned long val;
148
149 val = mfspr(DBCR0);
150 val |= 0x70000000;
151 mtspr(DBCR0,val);
152
wdenk42d1f032003-10-15 23:53:47 +0000153 return 1;
154}
155
156
157/*
158 * Get timebase clock frequency
159 */
160unsigned long get_tbclk (void)
161{
162
163 sys_info_t sys_info;
164
165 get_sys_info(&sys_info);
wdenk2a8af182005-04-13 10:02:42 +0000166 return ((sys_info.freqSystemBus + 7L) / 8L);
wdenk42d1f032003-10-15 23:53:47 +0000167}
168
169
170#if defined(CONFIG_WATCHDOG)
171void
172watchdog_reset(void)
173{
174 int re_enable = disable_interrupts();
175 reset_85xx_watchdog();
176 if (re_enable) enable_interrupts();
177}
178
179void
180reset_85xx_watchdog(void)
181{
182 /*
183 * Clear TSR(WIS) bit by writing 1
184 */
185 unsigned long val;
186 val = mfspr(tsr);
187 val |= 0x40000000;
188 mtspr(tsr, val);
189}
190#endif /* CONFIG_WATCHDOG */
191
192#if defined(CONFIG_DDR_ECC)
wdenk42d1f032003-10-15 23:53:47 +0000193void dma_init(void) {
194 volatile immap_t *immap = (immap_t *)CFG_IMMR;
195 volatile ccsr_dma_t *dma = &immap->im_dma;
196
197 dma->satr0 = 0x02c40000;
198 dma->datr0 = 0x02c40000;
199 asm("sync; isync; msync");
200 return;
201}
202
203uint dma_check(void) {
204 volatile immap_t *immap = (immap_t *)CFG_IMMR;
205 volatile ccsr_dma_t *dma = &immap->im_dma;
206 volatile uint status = dma->sr0;
207
208 /* While the channel is busy, spin */
209 while((status & 4) == 4) {
210 status = dma->sr0;
211 }
212
213 if (status != 0) {
214 printf ("DMA Error: status = %x\n", status);
215 }
216 return status;
217}
218
219int dma_xfer(void *dest, uint count, void *src) {
220 volatile immap_t *immap = (immap_t *)CFG_IMMR;
221 volatile ccsr_dma_t *dma = &immap->im_dma;
222
223 dma->dar0 = (uint) dest;
224 dma->sar0 = (uint) src;
225 dma->bcr0 = count;
226 dma->mr0 = 0xf000004;
227 asm("sync;isync;msync");
228 dma->mr0 = 0xf000005;
229 asm("sync;isync;msync");
230 return dma_check();
231}
232#endif
Matthew McClintock40d5fa32006-06-28 10:43:36 -0500233
234
235#ifdef CONFIG_OF_FLAT_TREE
236void
237ft_cpu_setup(void *blob, bd_t *bd)
238{
239 u32 *p;
240 ulong clock;
241 int len;
242
243 clock = bd->bi_busfreq;
244 p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
245 if (p != NULL)
246 *p = cpu_to_be32(clock);
247
248 p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
249 if (p != NULL)
250 *p = cpu_to_be32(clock);
251
252 p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
253 if (p != NULL)
254 *p = cpu_to_be32(clock);
255
256#if defined(CONFIG_MPC85XX_TSEC1)
257 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/mac-address", &len);
258 memcpy(p, bd->bi_enetaddr, 6);
259#endif
260
261#if defined(CONFIG_HAS_ETH1)
262 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/mac-address", &len);
263 memcpy(p, bd->bi_enet1addr, 6);
264#endif
265
266#if defined(CONFIG_HAS_ETH2)
267 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/mac-address", &len);
268 memcpy(p, bd->bi_enet2addr, 6);
269#endif
270
271#if defined(CONFIG_HAS_ETH3)
272 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/mac-address", &len);
273 memcpy(p, bd->bi_enet3addr, 6);
274#endif
275
276}
277#endif