2 * Copyright 2004 Freescale Semiconductor
3 * Jeff Brown (jeffrey@freescale.com)
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/cache.h>
31 #if defined(CONFIG_OF_FLAT_TREE)
35 #include "../board/mpc8641hpcn/pixis.h"
44 uint lcrr; /* local bus clock ratio register */
45 uint clkdiv; /* clock divider portion of lcrr */
47 puts("Freescale PowerPC\n");
59 case PVR_VER(PVR_86xx):
66 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
85 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
87 get_sys_info(&sysinfo);
90 printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
91 printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000);
92 printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
94 #if defined(CFG_LBC_LCRR)
98 volatile immap_t *immap = (immap_t *)CFG_IMMR;
99 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
104 clkdiv = lcrr & 0x0f;
105 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
106 printf("LBC:%4lu MHz\n",
107 sysinfo.freqSystemBus / 1000000 / clkdiv);
109 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr);
113 if (get_l2cr() & 0x80000000)
116 printf("Disabled\n");
123 soft_restart(unsigned long addr)
126 #ifndef CONFIG_MPC8641HPCN
128 /* SRR0 has system reset vector, SRR1 has default MSR value */
129 /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
131 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
132 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
133 __asm__ __volatile__ ("mtspr 27, 4");
134 __asm__ __volatile__ ("rfi");
136 #else /* CONFIG_MPC8641HPCN */
137 out8(PIXIS_BASE+PIXIS_RST,0);
138 #endif /* !CONFIG_MPC8641HPCN */
139 while(1); /* not reached */
144 * No generic way to do board reset. Simply call soft_reset.
147 do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
153 #ifdef CFG_RESET_ADDRESS
154 addr = CFG_RESET_ADDRESS;
157 * note: when CFG_MONITOR_BASE points to a RAM address,
158 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
159 * address. Better pick an address known to be invalid on your
160 * system and assign it to CFG_RESET_ADDRESS.
162 addr = CFG_MONITOR_BASE - sizeof (ulong);
165 #ifndef CONFIG_MPC8641HPCN
167 /* flush and disable I/D cache */
168 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
169 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
170 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
171 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
172 __asm__ __volatile__ ("sync");
173 __asm__ __volatile__ ("mtspr 1008, 4");
174 __asm__ __volatile__ ("isync");
175 __asm__ __volatile__ ("sync");
176 __asm__ __volatile__ ("mtspr 1008, 5");
177 __asm__ __volatile__ ("isync");
178 __asm__ __volatile__ ("sync");
182 #else /* CONFIG_MPC8641HPCN */
187 case 'f': /* reset with frequency changed */
190 read_from_px_regs(0);
192 val = set_px_sysclk(simple_strtoul(argv[2],NULL,10));
194 corepll = strfractoint(argv[3]);
195 val = val + set_px_corepll(corepll);
196 val = val + set_px_mpxpll(simple_strtoul(argv[4],
199 printf("Setting registers VCFGEN0 and VCTL\n");
200 read_from_px_regs(1);
201 printf("Resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL ....\n");
206 while (1); /* Not reached */
209 if (argv[2][1] == 'f') {
210 read_from_px_regs(0);
211 read_from_px_regs_altbank(0);
212 /* reset with frequency changed */
213 val = set_px_sysclk(simple_strtoul(argv[3],NULL,10));
215 corepll = strfractoint(argv[4]);
216 val = val + set_px_corepll(corepll);
217 val = val + set_px_mpxpll(simple_strtoul(argv[5],NULL,10));
219 printf("Setting registers VCFGEN0, VCFGEN1, VBOOT, and VCTL\n");
221 read_from_px_regs(1);
222 read_from_px_regs_altbank(1);
223 printf("Enabling watchdog timer on the FPGA and resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL to boot from the other bank ....\n");
224 set_px_go_with_watchdog();
228 while(1); /* Not reached */
229 } else if(argv[2][1] == 'd'){
230 /* Reset from next bank without changing frequencies but with watchdog timer enabled */
231 read_from_px_regs(0);
232 read_from_px_regs_altbank(0);
233 printf("Setting registers VCFGEN1, VBOOT, and VCTL\n");
235 read_from_px_regs_altbank(1);
236 printf("Enabling watchdog timer on the FPGA and resetting board to boot from the other bank....\n");
237 set_px_go_with_watchdog();
238 while(1); /* Not reached */
240 /* Reset from next bank without changing frequency and without watchdog timer enabled */
241 read_from_px_regs(0);
242 read_from_px_regs_altbank(0);
245 printf("Setting registers VCFGNE1, VBOOT, and VCTL\n");
247 read_from_px_regs_altbank(1);
248 printf("Resetting board to boot from the other bank....\n");
257 printf("\nUsage: reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n");
258 printf(" reset altbank [cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>]\n");
259 printf("For example: reset cf 40 2.5 10\n");
260 printf("See MPC8641HPCN Design Workbook for valid values of command line parameters.\n");
263 out8(PIXIS_BASE+PIXIS_RST,0);
265 #endif /* !CONFIG_MPC8641HPCN */
267 while(1); /* not reached */
272 * Get timebase clock frequency
274 unsigned long get_tbclk(void)
278 get_sys_info(&sys_info);
279 return (sys_info.freqSystemBus + 3L) / 4L;
283 #if defined(CONFIG_WATCHDOG)
288 #endif /* CONFIG_WATCHDOG */
291 #if defined(CONFIG_DDR_ECC)
294 volatile immap_t *immap = (immap_t *)CFG_IMMR;
295 volatile ccsr_dma_t *dma = &immap->im_dma;
297 dma->satr0 = 0x00040000;
298 dma->datr0 = 0x00040000;
304 volatile immap_t *immap = (immap_t *)CFG_IMMR;
305 volatile ccsr_dma_t *dma = &immap->im_dma;
306 volatile uint status = dma->sr0;
308 /* While the channel is busy, spin */
309 while((status & 4) == 4) {
314 printf ("DMA Error: status = %x\n", status);
319 int dma_xfer(void *dest, uint count, void *src)
321 volatile immap_t *immap = (immap_t *)CFG_IMMR;
322 volatile ccsr_dma_t *dma = &immap->im_dma;
324 dma->dar0 = (uint) dest;
325 dma->sar0 = (uint) src;
327 dma->mr0 = 0xf000004;
329 dma->mr0 = 0xf000005;
334 #endif /* CONFIG_DDR_ECC */
337 #ifdef CONFIG_OF_FLAT_TREE
338 void ft_cpu_setup(void *blob, bd_t *bd)
344 clock = bd->bi_busfreq;
345 p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
347 *p = cpu_to_be32(clock);
349 p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
351 *p = cpu_to_be32(clock);
353 p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
355 *p = cpu_to_be32(clock);
357 #if defined(CONFIG_MPC86XX_TSEC1)
358 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/address", &len);
359 memcpy(p, bd->bi_enetaddr, 6);
362 #if defined(CONFIG_MPC86XX_TSEC2)
363 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/address", &len);
364 memcpy(p, bd->bi_enet1addr, 6);
367 #if defined(CONFIG_MPC86XX_TSEC3)
368 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/address", &len);
369 memcpy(p, bd->bi_enet2addr, 6);
372 #if defined(CONFIG_MPC86XX_TSEC4)
373 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/address", &len);
374 memcpy(p, bd->bi_enet3addr, 6);