]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/mpc86xx/cpu.c
2 * Copyright 2006 Freescale Semiconductor
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)
42 uint lcrr
; /* local bus clock ratio register */
43 uint clkdiv
; /* clock divider portion of lcrr */
45 puts("Freescale PowerPC\n");
56 case PVR_VER(PVR_86xx
):
63 printf(", Version: %d.%d, (0x%08x)\n", major
, minor
, pvr
);
73 if (SVR_SUBVER(svr
) == 1) {
83 printf(", Version: %d.%d, (0x%08x)\n", major
, minor
, svr
);
85 get_sys_info(&sysinfo
);
88 printf("CPU:%4lu MHz, ", sysinfo
.freqProcessor
/ 1000000);
89 printf("MPX:%4lu MHz, ", sysinfo
.freqSystemBus
/ 1000000);
90 printf("DDR:%4lu MHz, ", sysinfo
.freqSystemBus
/ 2000000);
92 #if defined(CFG_LBC_LCRR)
96 volatile immap_t
*immap
= (immap_t
*) CFG_IMMR
;
97 volatile ccsr_lbc_t
*lbc
= &immap
->im_lbc
;
102 clkdiv
= lcrr
& 0x0f;
103 if (clkdiv
== 2 || clkdiv
== 4 || clkdiv
== 8) {
104 printf("LBC:%4lu MHz\n",
105 sysinfo
.freqSystemBus
/ 1000000 / clkdiv
);
107 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr
);
111 if (get_l2cr() & 0x80000000)
121 soft_restart(unsigned long addr
)
123 #ifndef CONFIG_MPC8641HPCN
126 * SRR0 has system reset vector, SRR1 has default MSR value
127 * rfi restores MSR from SRR1 and sets the PC to the SRR0 value
130 __asm__
__volatile__ ("mtspr 26, %0" :: "r" (addr
));
131 __asm__
__volatile__ ("li 4, (1 << 6)" ::: "r4");
132 __asm__
__volatile__ ("mtspr 27, 4");
133 __asm__
__volatile__ ("rfi");
135 #else /* CONFIG_MPC8641HPCN */
137 out8(PIXIS_BASE
+ PIXIS_RST
, 0);
139 #endif /* !CONFIG_MPC8641HPCN */
141 while (1) ; /* not reached */
146 * No generic way to do board reset. Simply call soft_reset.
149 do_reset(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
151 #ifndef CONFIG_MPC8641HPCN
153 #ifdef CFG_RESET_ADDRESS
154 ulong 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 ulong addr
= CFG_MONITOR_BASE
- sizeof(ulong
);
165 /* flush and disable I/D cache */
166 __asm__
__volatile__ ("mfspr 3, 1008" ::: "r3");
167 __asm__
__volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
168 __asm__
__volatile__ ("ori 4, 3, 0xc00" ::: "r4");
169 __asm__
__volatile__ ("andc 5, 3, 5" ::: "r5");
170 __asm__
__volatile__ ("sync");
171 __asm__
__volatile__ ("mtspr 1008, 4");
172 __asm__
__volatile__ ("isync");
173 __asm__
__volatile__ ("sync");
174 __asm__
__volatile__ ("mtspr 1008, 5");
175 __asm__
__volatile__ ("isync");
176 __asm__
__volatile__ ("sync");
180 #else /* CONFIG_MPC8641HPCN */
182 out8(PIXIS_BASE
+ PIXIS_RST
, 0);
184 #endif /* !CONFIG_MPC8641HPCN */
186 while (1) ; /* not reached */
191 * Get timebase clock frequency
198 get_sys_info(&sys_info
);
199 return (sys_info
.freqSystemBus
+ 3L) / 4L;
203 #if defined(CONFIG_WATCHDOG)
208 #endif /* CONFIG_WATCHDOG */
211 #if defined(CONFIG_DDR_ECC)
215 volatile immap_t
*immap
= (immap_t
*) CFG_IMMR
;
216 volatile ccsr_dma_t
*dma
= &immap
->im_dma
;
218 dma
->satr0
= 0x00040000;
219 dma
->datr0
= 0x00040000;
226 volatile immap_t
*immap
= (immap_t
*) CFG_IMMR
;
227 volatile ccsr_dma_t
*dma
= &immap
->im_dma
;
228 volatile uint status
= dma
->sr0
;
230 /* While the channel is busy, spin */
231 while ((status
& 4) == 4) {
236 printf("DMA Error: status = %x\n", status
);
242 dma_xfer(void *dest
, uint count
, void *src
)
244 volatile immap_t
*immap
= (immap_t
*) CFG_IMMR
;
245 volatile ccsr_dma_t
*dma
= &immap
->im_dma
;
247 dma
->dar0
= (uint
) dest
;
248 dma
->sar0
= (uint
) src
;
250 dma
->mr0
= 0xf000004;
252 dma
->mr0
= 0xf000005;
257 #endif /* CONFIG_DDR_ECC */
260 #ifdef CONFIG_OF_FLAT_TREE
262 ft_cpu_setup(void *blob
, bd_t
*bd
)
268 clock
= bd
->bi_busfreq
;
269 p
= ft_get_prop(blob
, "/cpus/" OF_CPU
"/bus-frequency", &len
);
271 *p
= cpu_to_be32(clock
);
273 p
= ft_get_prop(blob
, "/" OF_SOC
"/serial@4500/clock-frequency", &len
);
275 *p
= cpu_to_be32(clock
);
277 p
= ft_get_prop(blob
, "/" OF_SOC
"/serial@4600/clock-frequency", &len
);
279 *p
= cpu_to_be32(clock
);
281 #if defined(CONFIG_TSEC1)
282 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@24000/mac-address", &len
);
284 memcpy(p
, bd
->bi_enetaddr
, 6);
285 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@24000/local-mac-address", &len
);
287 memcpy(p
, bd
->bi_enetaddr
, 6);
290 #if defined(CONFIG_TSEC2)
291 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@25000/mac-address", &len
);
293 memcpy(p
, bd
->bi_enet1addr
, 6);
294 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@25000/local-mac-address", &len
);
296 memcpy(p
, bd
->bi_enet1addr
, 6);
299 #if defined(CONFIG_TSEC3)
300 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@26000/mac-address", &len
);
302 memcpy(p
, bd
->bi_enet2addr
, 6);
303 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@26000/local-mac-address", &len
);
305 memcpy(p
, bd
->bi_enet2addr
, 6);
308 #if defined(CONFIG_TSEC4)
309 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@27000/mac-address", &len
);
311 memcpy(p
, bd
->bi_enet3addr
, 6);
312 p
= ft_get_prop(blob
, "/" OF_SOC
"/ethernet@27000/local-mac-address", &len
);
314 memcpy(p
, bd
->bi_enet3addr
, 6);