2 * (C) Copyright 2000-2006
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
17 * modified for 8260 by
23 * added HiP7 (824x/827x/8280) processors support by
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 ();
58 ret = prt_8260_clks();
77 return -1; /* whoops! not an MPC8260 */
81 immr = immap->im_memctl.memc_immr;
82 if ((immr & IMMR_ISB_MSK) != CONFIG_SYS_IMMR)
83 return -1; /* whoops! someone moved the IMMR */
85 #if defined(CONFIG_GET_CPU_STR_F)
87 printf ("%s (HiP%d Rev %02x, Mask ", buf, k, rev);
89 printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
93 * the bottom 16 bits of the immr are the Part Number and Mask Number
94 * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
95 * RISC Microcode Revision Number (13-10).
96 * For the 8260, Motorola doesn't include the Microcode Revision
99 m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
100 k = immap->im_dprambase16[PROFF_REVNUM / sizeof(u16)];
110 puts ("A.1 1K22A-XC");
116 puts ("B.2 2K23A-XC");
125 puts ("A.0(A) 2K25A");
155 printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
159 printf (") at %s MHz\n", strmhz (buf, clock));
164 /* ------------------------------------------------------------------------- */
165 /* configures a UPM by writing into the UPM RAM array */
166 /* uses bank 11 and a dummy physical address (=BRx_BA_MSK) */
167 /* NOTE: the physical address chosen must not overlap into any other area */
168 /* mapped by the memory controller because bank 11 has the lowest priority */
170 void upmconfig (uint upm, uint * table, uint size)
172 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
173 volatile memctl8260_t *memctl = &immap->im_memctl;
174 volatile uchar *dummy = (uchar *) BRx_BA_MSK; /* set all BA bits */
177 /* first set up bank 11 to reference the correct UPM at a dummy address */
179 memctl->memc_or11 = ORxU_AM_MSK; /* set all AM bits */
185 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
187 memctl->memc_mamr = MxMR_OP_WARR;
192 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
194 memctl->memc_mbmr = MxMR_OP_WARR;
199 ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
201 memctl->memc_mcmr = MxMR_OP_WARR;
205 panic ("upmconfig passed invalid UPM number (%u)\n", upm);
211 * at this point, the dummy address is set up to access the selected UPM,
212 * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
214 * now we simply load the mdr with each word and poke the dummy address.
215 * the MAD is incremented on each access.
218 for (i = 0; i < size; i++) {
219 memctl->memc_mdr = table[i];
223 /* now kill bank 11 */
224 memctl->memc_br11 = 0;
227 /* ------------------------------------------------------------------------- */
229 #if !defined(CONFIG_HAVE_OWN_RESET)
231 do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
235 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
237 immap->im_clkrst.car_rmr = RMR_CSRE; /* Checkstop Reset enable */
239 /* Interrupts and MMU off */
240 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
242 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
243 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
246 * Trying to execute the next instruction at a non-existing address
247 * should cause a machine check, resulting in reset
249 #ifdef CONFIG_SYS_RESET_ADDRESS
250 addr = CONFIG_SYS_RESET_ADDRESS;
253 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE
254 * - sizeof (ulong) is usually a valid address. Better pick an address
255 * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
257 addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
259 ((void (*)(void)) addr) ();
263 #endif /* CONFIG_HAVE_OWN_RESET */
265 /* ------------------------------------------------------------------------- */
268 * Get timebase clock frequency (like cpu_clk in Hz)
271 unsigned long get_tbclk (void)
275 tbclk = (gd->bus_clk + 3L) / 4L;
280 /* ------------------------------------------------------------------------- */
282 #if defined(CONFIG_WATCHDOG)
283 void watchdog_reset (void)
285 int re_enable = disable_interrupts ();
287 reset_8260_watchdog ((immap_t *) CONFIG_SYS_IMMR);
289 enable_interrupts ();
291 #endif /* CONFIG_WATCHDOG */
293 /* ------------------------------------------------------------------------- */
294 #ifdef CONFIG_OF_BOARD_SETUP
295 void ft_cpu_setup (void *blob, bd_t *bd)
297 do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
298 "clock-frequency", bd->bi_brgfreq, 1);
300 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
301 "bus-frequency", bd->bi_busfreq, 1);
302 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
303 "timebase-frequency", OF_TBCLK, 1);
304 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
305 "clock-frequency", bd->bi_intfreq, 1);
306 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
308 #endif /* CONFIG_OF_BOARD_SETUP */
311 * Initializes on-chip ethernet controllers.
312 * to override, implement board_eth_init()
314 int cpu_eth_init(bd_t *bis)
316 #if defined(CONFIG_ETHER_ON_FCC)
319 #if defined(CONFIG_ETHER_ON_SCC)
320 mpc82xx_scc_enet_initialize(bis);