2 * Copyright 2004,2007 Freescale Semiconductor, Inc.
3 * (C) Copyright 2002, 2003 Motorola Inc.
4 * Xianghua Xiao (X.Xiao@motorola.com)
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * See file CREDITS for list of people who contributed to this
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.
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.
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,
31 #include <asm/cache.h>
33 #if defined(CONFIG_OF_FLAT_TREE)
41 uint lcrr; /* local bus clock ratio register */
42 uint clkdiv; /* clock divider portion of lcrr */
86 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
96 case PVR_FAM(PVR_85xx):
103 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
105 get_sys_info(&sysinfo);
107 puts("Clock Configuration:\n");
108 printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
109 printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
110 printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
112 #if defined(CFG_LBC_LCRR)
116 volatile immap_t *immap = (immap_t *)CFG_IMMR;
117 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
122 clkdiv = lcrr & 0x0f;
123 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
124 #if defined(CONFIG_MPC8548) || defined(CONFIG_MPC8544)
126 * Yes, the entire PQ38 family use the same
127 * bit-representation for twice the clock divider values.
131 printf("LBC:%4lu MHz\n",
132 sysinfo.freqSystemBus / 1000000 / clkdiv);
134 printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
137 if (ver == SVR_8560) {
138 printf("CPM: %lu Mhz\n",
139 sysinfo.freqSystemBus / 1000000);
142 puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
148 /* ------------------------------------------------------------------------- */
150 int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
157 /* e500 v2 core has reset control register */
158 volatile unsigned int * rstcr;
159 rstcr = (volatile unsigned int *)(CFG_IMMR + 0xE00B0);
160 *rstcr = 0x2; /* HRESET_REQ */
163 * Initiate hard reset in debug control register DBCR0
164 * Make sure MSR[DE] = 1
176 * Get timebase clock frequency
178 unsigned long get_tbclk (void)
183 get_sys_info(&sys_info);
184 return ((sys_info.freqSystemBus + 7L) / 8L);
188 #if defined(CONFIG_WATCHDOG)
192 int re_enable = disable_interrupts();
193 reset_85xx_watchdog();
194 if (re_enable) enable_interrupts();
198 reset_85xx_watchdog(void)
201 * Clear TSR(WIS) bit by writing 1
204 val = mfspr(SPRN_TSR);
206 mtspr(SPRN_TSR, val);
208 #endif /* CONFIG_WATCHDOG */
210 #if defined(CONFIG_DDR_ECC)
211 void dma_init(void) {
212 volatile immap_t *immap = (immap_t *)CFG_IMMR;
213 volatile ccsr_dma_t *dma = &immap->im_dma;
215 dma->satr0 = 0x02c40000;
216 dma->datr0 = 0x02c40000;
217 dma->sr0 = 0xfffffff; /* clear any errors */
218 asm("sync; isync; msync");
222 uint dma_check(void) {
223 volatile immap_t *immap = (immap_t *)CFG_IMMR;
224 volatile ccsr_dma_t *dma = &immap->im_dma;
225 volatile uint status = dma->sr0;
227 /* While the channel is busy, spin */
228 while((status & 4) == 4) {
232 /* clear MR0[CS] channel start bit */
233 dma->mr0 &= 0x00000001;
234 asm("sync;isync;msync");
237 printf ("DMA Error: status = %x\n", status);
242 int dma_xfer(void *dest, uint count, void *src) {
243 volatile immap_t *immap = (immap_t *)CFG_IMMR;
244 volatile ccsr_dma_t *dma = &immap->im_dma;
246 dma->dar0 = (uint) dest;
247 dma->sar0 = (uint) src;
249 dma->mr0 = 0xf000004;
250 asm("sync;isync;msync");
251 dma->mr0 = 0xf000005;
252 asm("sync;isync;msync");
258 #ifdef CONFIG_OF_FLAT_TREE
260 ft_cpu_setup(void *blob, bd_t *bd)
266 clock = bd->bi_busfreq;
267 p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
269 *p = cpu_to_be32(clock);
271 p = ft_get_prop(blob, "/qe@e0080000/" OF_CPU "/bus-frequency", &len);
273 *p = cpu_to_be32(clock);
275 p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
277 *p = cpu_to_be32(clock);
279 p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
281 *p = cpu_to_be32(clock);
283 #if defined(CONFIG_HAS_ETH0)
284 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/mac-address", &len);
286 memcpy(p, bd->bi_enetaddr, 6);
288 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/local-mac-address", &len);
290 memcpy(p, bd->bi_enetaddr, 6);
293 #if defined(CONFIG_HAS_ETH1)
294 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/mac-address", &len);
296 memcpy(p, bd->bi_enet1addr, 6);
298 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/local-mac-address", &len);
300 memcpy(p, bd->bi_enet1addr, 6);
303 #if defined(CONFIG_HAS_ETH2)
304 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/mac-address", &len);
306 memcpy(p, bd->bi_enet2addr, 6);
308 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/local-mac-address", &len);
310 memcpy(p, bd->bi_enet2addr, 6);
312 #ifdef CONFIG_UEC_ETH
313 p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/mac-address", &len);
315 memcpy(p, bd->bi_enet2addr, 6);
317 p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/local-mac-address", &len);
319 memcpy(p, bd->bi_enet2addr, 6);
324 #if defined(CONFIG_HAS_ETH3)
325 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/mac-address", &len);
327 memcpy(p, bd->bi_enet3addr, 6);
329 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/local-mac-address", &len);
331 memcpy(p, bd->bi_enet3addr, 6);
333 #ifdef CONFIG_UEC_ETH
334 p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/mac-address", &len);
336 memcpy(p, bd->bi_enet3addr, 6);
338 p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/local-mac-address", &len);
340 memcpy(p, bd->bi_enet3addr, 6);