]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/powerpc/cpu/mpc8260/cpu.c
2 * (C) Copyright 2000-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * CPU specific code for the MPC825x / MPC826x / MPC827x / MPC828x
11 * written or collected and sometimes rewritten by
12 * Magnus Damm <damm@bitsmart.com>
15 * Wolfgang Denk <wd@denx.de>
17 * modified for 8260 by
18 * Murray Jensen <Murray.Jensen@cmst.csiro.au>
21 * Marius Groeger <mag@sysgo.de>
23 * added HiP7 (824x/827x/8280) processors support by
24 * Yuli Barcohen <yuli@arabellasw.com>
32 #include <asm/processor.h>
33 #include <asm/cpm_8260.h>
35 #if defined(CONFIG_OF_LIBFDT)
37 #include <fdt_support.h>
40 DECLARE_GLOBAL_DATA_PTR
;
42 #if defined(CONFIG_GET_CPU_STR_F)
43 extern int get_cpu_str_f (char *buf
);
48 volatile immap_t
*immap
= (immap_t
*) CONFIG_SYS_IMMR
;
49 ulong clock
= gd
->cpu_clk
;
50 uint pvr
= get_pvr ();
70 return -1; /* whoops! not an MPC8260 */
74 immr
= immap
->im_memctl
.memc_immr
;
75 if ((immr
& IMMR_ISB_MSK
) != CONFIG_SYS_IMMR
)
76 return -1; /* whoops! someone moved the IMMR */
78 #if defined(CONFIG_GET_CPU_STR_F)
80 printf ("%s (HiP%d Rev %02x, Mask ", buf
, k
, rev
);
82 printf (CPU_ID_STR
" (HiP%d Rev %02x, Mask ", k
, rev
);
86 * the bottom 16 bits of the immr are the Part Number and Mask Number
87 * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
88 * RISC Microcode Revision Number (13-10).
89 * For the 8260, Motorola doesn't include the Microcode Revision
92 m
= immr
& (IMMR_PARTNUM_MSK
| IMMR_MASKNUM_MSK
);
93 k
= immap
->im_dprambase16
[PROFF_REVNUM
/ sizeof(u16
)];
103 puts ("A.1 1K22A-XC");
109 puts ("B.2 2K23A-XC");
118 puts ("A.0(A) 2K25A");
148 printf ("unknown [immr=0x%04x,k=0x%04x]", m
, k
);
152 printf (") at %s MHz\n", strmhz (buf
, clock
));
157 /* ------------------------------------------------------------------------- */
158 /* configures a UPM by writing into the UPM RAM array */
159 /* uses bank 11 and a dummy physical address (=BRx_BA_MSK) */
160 /* NOTE: the physical address chosen must not overlap into any other area */
161 /* mapped by the memory controller because bank 11 has the lowest priority */
163 void upmconfig (uint upm
, uint
* table
, uint size
)
165 volatile immap_t
*immap
= (immap_t
*) CONFIG_SYS_IMMR
;
166 volatile memctl8260_t
*memctl
= &immap
->im_memctl
;
167 volatile uchar
*dummy
= (uchar
*) BRx_BA_MSK
; /* set all BA bits */
170 /* first set up bank 11 to reference the correct UPM at a dummy address */
172 memctl
->memc_or11
= ORxU_AM_MSK
; /* set all AM bits */
178 ((uint
)dummy
& BRx_BA_MSK
) | BRx_PS_32
| BRx_MS_UPMA
|
180 memctl
->memc_mamr
= MxMR_OP_WARR
;
185 ((uint
)dummy
& BRx_BA_MSK
) | BRx_PS_32
| BRx_MS_UPMB
|
187 memctl
->memc_mbmr
= MxMR_OP_WARR
;
192 ((uint
)dummy
& BRx_BA_MSK
) | BRx_PS_32
| BRx_MS_UPMC
|
194 memctl
->memc_mcmr
= MxMR_OP_WARR
;
198 panic ("upmconfig passed invalid UPM number (%u)\n", upm
);
204 * at this point, the dummy address is set up to access the selected UPM,
205 * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
207 * now we simply load the mdr with each word and poke the dummy address.
208 * the MAD is incremented on each access.
211 for (i
= 0; i
< size
; i
++) {
212 memctl
->memc_mdr
= table
[i
];
216 /* now kill bank 11 */
217 memctl
->memc_br11
= 0;
220 /* ------------------------------------------------------------------------- */
222 #if !defined(CONFIG_HAVE_OWN_RESET)
224 do_reset (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char * const argv
[])
228 volatile immap_t
*immap
= (immap_t
*) CONFIG_SYS_IMMR
;
230 immap
->im_clkrst
.car_rmr
= RMR_CSRE
; /* Checkstop Reset enable */
232 /* Interrupts and MMU off */
233 __asm__
__volatile__ ("mfmsr %0":"=r" (msr
):);
235 msr
&= ~(MSR_ME
| MSR_EE
| MSR_IR
| MSR_DR
);
236 __asm__
__volatile__ ("mtmsr %0"::"r" (msr
));
239 * Trying to execute the next instruction at a non-existing address
240 * should cause a machine check, resulting in reset
242 #ifdef CONFIG_SYS_RESET_ADDRESS
243 addr
= CONFIG_SYS_RESET_ADDRESS
;
246 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE
247 * - sizeof (ulong) is usually a valid address. Better pick an address
248 * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
250 addr
= CONFIG_SYS_MONITOR_BASE
- sizeof (ulong
);
252 ((void (*)(void)) addr
) ();
256 #endif /* CONFIG_HAVE_OWN_RESET */
258 /* ------------------------------------------------------------------------- */
261 * Get timebase clock frequency (like cpu_clk in Hz)
264 unsigned long get_tbclk (void)
268 tbclk
= (gd
->bus_clk
+ 3L) / 4L;
273 /* ------------------------------------------------------------------------- */
275 #if defined(CONFIG_WATCHDOG)
276 void watchdog_reset (void)
278 int re_enable
= disable_interrupts ();
280 reset_8260_watchdog ((immap_t
*) CONFIG_SYS_IMMR
);
282 enable_interrupts ();
284 #endif /* CONFIG_WATCHDOG */
286 /* ------------------------------------------------------------------------- */
287 #if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
288 void ft_cpu_setup (void *blob
, bd_t
*bd
)
290 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
291 defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
292 fdt_fixup_ethernet(blob
);
295 do_fixup_by_compat_u32(blob
, "fsl,cpm2-brg",
296 "clock-frequency", bd
->bi_brgfreq
, 1);
298 do_fixup_by_prop_u32(blob
, "device_type", "cpu", 4,
299 "bus-frequency", bd
->bi_busfreq
, 1);
300 do_fixup_by_prop_u32(blob
, "device_type", "cpu", 4,
301 "timebase-frequency", OF_TBCLK
, 1);
302 do_fixup_by_prop_u32(blob
, "device_type", "cpu", 4,
303 "clock-frequency", bd
->bi_intfreq
, 1);
304 fdt_fixup_memory(blob
, (u64
)bd
->bi_memstart
, (u64
)bd
->bi_memsize
);
306 #endif /* CONFIG_OF_LIBFDT */
309 * Initializes on-chip ethernet controllers.
310 * to override, implement board_eth_init()
312 int cpu_eth_init(bd_t
*bis
)
314 #if defined(CONFIG_ETHER_ON_FCC)
317 #if defined(CONFIG_ETHER_ON_SCC)
318 mpc82xx_scc_enet_initialize(bis
);