blob: fe678dfa63a21866709508670f701bef490a1635 [file] [log] [blame]
wdenk9c53f402003-10-15 23:53:47 +00001/*
wdenka445ddf2004-06-09 00:34:46 +00002 * Copyright 2004 Freescale Semiconductor.
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
28#include <common.h>
29#include <watchdog.h>
30#include <command.h>
31#include <asm/cache.h>
32
33/* ------------------------------------------------------------------------- */
34
35int checkcpu (void)
36{
wdenka445ddf2004-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;
41 uint ver;
42 uint major, minor;
wdenk9c53f402003-10-15 23:53:47 +000043
wdenka445ddf2004-06-09 00:34:46 +000044 svr = get_svr();
45 ver = SVR_VER(svr);
46 major = SVR_MAJ(svr);
47 minor = SVR_MIN(svr);
48
wdenk3f3262b2005-03-15 22:56:53 +000049 puts("CPU: ");
wdenka445ddf2004-06-09 00:34:46 +000050 switch (ver) {
51 case SVR_8540:
52 puts("8540");
53 break;
54 case SVR_8541:
55 puts("8541");
56 break;
57 case SVR_8555:
58 puts("8555");
59 break;
60 case SVR_8560:
61 puts("8560");
62 break;
wdenk9c53f402003-10-15 23:53:47 +000063 default:
wdenka445ddf2004-06-09 00:34:46 +000064 puts("Unknown");
wdenk9c53f402003-10-15 23:53:47 +000065 break;
66 }
wdenka445ddf2004-06-09 00:34:46 +000067 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
wdenk9c53f402003-10-15 23:53:47 +000068
wdenk3f3262b2005-03-15 22:56:53 +000069 pvr = get_pvr();
70 ver = PVR_VER(pvr);
71 major = PVR_MAJ(pvr);
72 minor = PVR_MIN(pvr);
73
74 printf("Core: ");
75 switch (ver) {
76 case PVR_VER(PVR_85xx):
77 puts("E500");
78 break;
79 default:
80 puts("Unknown");
81 break;
82 }
83 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
84
wdenka445ddf2004-06-09 00:34:46 +000085 get_sys_info(&sysinfo);
86
wdenk3f3262b2005-03-15 22:56:53 +000087 puts("Clocks Configuration:\n");
88 printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
89 printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
90 printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
wdenka445ddf2004-06-09 00:34:46 +000091
92#if defined(CFG_LBC_LCRR)
93 lcrr = CFG_LBC_LCRR;
94#else
95 {
96 volatile immap_t *immap = (immap_t *)CFG_IMMR;
97 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
98
99 lcrr = lbc->lcrr;
100 }
101#endif
102 clkdiv = lcrr & 0x0f;
103 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
104 printf("LBC:%4lu MHz\n",
105 sysinfo.freqSystemBus / 1000000 / clkdiv);
106 } else {
wdenk3f3262b2005-03-15 22:56:53 +0000107 printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
wdenka445ddf2004-06-09 00:34:46 +0000108 }
109
110 if (ver == SVR_8560) {
wdenk3f3262b2005-03-15 22:56:53 +0000111 printf("CPM: %lu Mhz\n",
wdenka445ddf2004-06-09 00:34:46 +0000112 sysinfo.freqSystemBus / 1000000);
113 }
114
wdenk3f3262b2005-03-15 22:56:53 +0000115 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
wdenk9c53f402003-10-15 23:53:47 +0000116
117 return 0;
118}
119
120
121/* ------------------------------------------------------------------------- */
122
123int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
124{
125 /*
126 * Initiate hard reset in debug control register DBCR0
127 * Make sure MSR[DE] = 1
128 */
wdenka445ddf2004-06-09 00:34:46 +0000129 unsigned long val;
130
131 val = mfspr(DBCR0);
132 val |= 0x70000000;
133 mtspr(DBCR0,val);
134
wdenk9c53f402003-10-15 23:53:47 +0000135 return 1;
136}
137
138
139/*
140 * Get timebase clock frequency
141 */
142unsigned long get_tbclk (void)
143{
144
145 sys_info_t sys_info;
146
147 get_sys_info(&sys_info);
148 return ((sys_info.freqSystemBus + 3L) / 4L);
149}
150
151
152#if defined(CONFIG_WATCHDOG)
153void
154watchdog_reset(void)
155{
156 int re_enable = disable_interrupts();
157 reset_85xx_watchdog();
158 if (re_enable) enable_interrupts();
159}
160
161void
162reset_85xx_watchdog(void)
163{
164 /*
165 * Clear TSR(WIS) bit by writing 1
166 */
167 unsigned long val;
168 val = mfspr(tsr);
169 val |= 0x40000000;
170 mtspr(tsr, val);
171}
172#endif /* CONFIG_WATCHDOG */
173
174#if defined(CONFIG_DDR_ECC)
wdenk9c53f402003-10-15 23:53:47 +0000175void dma_init(void) {
176 volatile immap_t *immap = (immap_t *)CFG_IMMR;
177 volatile ccsr_dma_t *dma = &immap->im_dma;
178
179 dma->satr0 = 0x02c40000;
180 dma->datr0 = 0x02c40000;
181 asm("sync; isync; msync");
182 return;
183}
184
185uint dma_check(void) {
186 volatile immap_t *immap = (immap_t *)CFG_IMMR;
187 volatile ccsr_dma_t *dma = &immap->im_dma;
188 volatile uint status = dma->sr0;
189
190 /* While the channel is busy, spin */
191 while((status & 4) == 4) {
192 status = dma->sr0;
193 }
194
195 if (status != 0) {
196 printf ("DMA Error: status = %x\n", status);
197 }
198 return status;
199}
200
201int dma_xfer(void *dest, uint count, void *src) {
202 volatile immap_t *immap = (immap_t *)CFG_IMMR;
203 volatile ccsr_dma_t *dma = &immap->im_dma;
204
205 dma->dar0 = (uint) dest;
206 dma->sar0 = (uint) src;
207 dma->bcr0 = count;
208 dma->mr0 = 0xf000004;
209 asm("sync;isync;msync");
210 dma->mr0 = 0xf000005;
211 asm("sync;isync;msync");
212 return dma_check();
213}
214#endif