2 * Copyright 2006 Freescale Semiconductor
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>
30 #include <asm/fsl_law.h>
32 #if defined(CONFIG_OF_FLAT_TREE)
43 uint lcrr; /* local bus clock ratio register */
44 uint clkdiv; /* clock divider portion of lcrr */
45 volatile immap_t *immap = (immap_t *) CFG_IMMR;
46 volatile ccsr_gur_t *gur = &immap->im_gur;
48 puts("Freescale PowerPC\n");
59 case PVR_VER(PVR_86xx):
61 uint msscr0 = mfspr(MSSCR0);
62 printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
63 if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
64 puts("\n Core1Translation Enabled");
65 debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
72 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
82 if (SVR_SUBVER(svr) == 1) {
95 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
97 get_sys_info(&sysinfo);
100 printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
101 printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000);
102 printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
104 #if defined(CFG_LBC_LCRR)
108 volatile immap_t *immap = (immap_t *) CFG_IMMR;
109 volatile ccsr_lbc_t *lbc = &immap->im_lbc;
114 clkdiv = lcrr & 0x0f;
115 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
116 printf("LBC:%4lu MHz\n",
117 sysinfo.freqSystemBus / 1000000 / clkdiv);
119 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr);
123 if (get_l2cr() & 0x80000000)
133 soft_restart(unsigned long addr)
135 #if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
138 * SRR0 has system reset vector, SRR1 has default MSR value
139 * rfi restores MSR from SRR1 and sets the PC to the SRR0 value
142 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
143 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
144 __asm__ __volatile__ ("mtspr 27, 4");
145 __asm__ __volatile__ ("rfi");
147 #else /* CONFIG_MPC8641HPCN */
149 out8(PIXIS_BASE + PIXIS_RST, 0);
151 #endif /* !CONFIG_MPC8641HPCN */
153 while (1) ; /* not reached */
158 * No generic way to do board reset. Simply call soft_reset.
161 do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
163 #if !defined(CONFIG_MPC8641HPCN) && !defined(CONFIG_MPC8610HPCD)
165 #ifdef CFG_RESET_ADDRESS
166 ulong addr = CFG_RESET_ADDRESS;
169 * note: when CFG_MONITOR_BASE points to a RAM address,
170 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
171 * address. Better pick an address known to be invalid on your
172 * system and assign it to CFG_RESET_ADDRESS.
174 ulong addr = CFG_MONITOR_BASE - sizeof(ulong);
177 /* flush and disable I/D cache */
178 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
179 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
180 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
181 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
182 __asm__ __volatile__ ("sync");
183 __asm__ __volatile__ ("mtspr 1008, 4");
184 __asm__ __volatile__ ("isync");
185 __asm__ __volatile__ ("sync");
186 __asm__ __volatile__ ("mtspr 1008, 5");
187 __asm__ __volatile__ ("isync");
188 __asm__ __volatile__ ("sync");
192 #else /* CONFIG_MPC8641HPCN */
194 out8(PIXIS_BASE + PIXIS_RST, 0);
196 #endif /* !CONFIG_MPC8641HPCN */
198 while (1) ; /* not reached */
203 * Get timebase clock frequency
210 get_sys_info(&sys_info);
211 return (sys_info.freqSystemBus + 3L) / 4L;
215 #if defined(CONFIG_WATCHDOG)
220 #endif /* CONFIG_WATCHDOG */
223 #if defined(CONFIG_DDR_ECC)
227 volatile immap_t *immap = (immap_t *) CFG_IMMR;
228 volatile ccsr_dma_t *dma = &immap->im_dma;
230 dma->satr0 = 0x00040000;
231 dma->datr0 = 0x00040000;
238 volatile immap_t *immap = (immap_t *) CFG_IMMR;
239 volatile ccsr_dma_t *dma = &immap->im_dma;
240 volatile uint status = dma->sr0;
242 /* While the channel is busy, spin */
243 while ((status & 4) == 4) {
248 printf("DMA Error: status = %x\n", status);
254 dma_xfer(void *dest, uint count, void *src)
256 volatile immap_t *immap = (immap_t *) CFG_IMMR;
257 volatile ccsr_dma_t *dma = &immap->im_dma;
259 dma->dar0 = (uint) dest;
260 dma->sar0 = (uint) src;
262 dma->mr0 = 0xf000004;
264 dma->mr0 = 0xf000005;
269 #endif /* CONFIG_DDR_ECC */
272 #ifdef CONFIG_OF_FLAT_TREE
274 ft_cpu_setup(void *blob, bd_t *bd)
280 clock = bd->bi_busfreq;
281 p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
283 *p = cpu_to_be32(clock);
285 p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
287 *p = cpu_to_be32(clock);
289 p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
291 *p = cpu_to_be32(clock);
293 #if defined(CONFIG_TSEC1)
294 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/mac-address", &len);
296 memcpy(p, bd->bi_enetaddr, 6);
297 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/local-mac-address", &len);
299 memcpy(p, bd->bi_enetaddr, 6);
302 #if defined(CONFIG_TSEC2)
303 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/mac-address", &len);
305 memcpy(p, bd->bi_enet1addr, 6);
306 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/local-mac-address", &len);
308 memcpy(p, bd->bi_enet1addr, 6);
311 #if defined(CONFIG_TSEC3)
312 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/mac-address", &len);
314 memcpy(p, bd->bi_enet2addr, 6);
315 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/local-mac-address", &len);
317 memcpy(p, bd->bi_enet2addr, 6);
320 #if defined(CONFIG_TSEC4)
321 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/mac-address", &len);
323 memcpy(p, bd->bi_enet3addr, 6);
324 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/local-mac-address", &len);
326 memcpy(p, bd->bi_enet3addr, 6);
328 #endif /* CONFIG_OF_FLAT_TREE */
331 * Print out the state of various machine registers.
332 * Currently prints out LAWs and BR0/OR0
334 void mpc86xx_reginfo(void)
336 immap_t *immap = (immap_t *)CFG_IMMR;
337 ccsr_lbc_t *lbc = &immap->im_lbc;
341 printf ("Local Bus Controller Registers\n"
342 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
343 printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
344 printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
345 printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
346 printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
347 printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
348 printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
349 printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));