3 * Martin Winistoerfer, martinwinistoerfer@gmx.ch.
5 * SPDX-License-Identifier: GPL-2.0+
11 * Discription: Some cpu specific function for watchdog,
12 * cpu version test, clock setting ...
22 DECLARE_GLOBAL_DATA_PTR;
24 #if (defined(CONFIG_MPC555))
25 # define ID_STR "MPC555/556"
28 * Check version of cpu with Processor Version Register (PVR)
30 static int check_cpu_version (long clock, uint pvr, uint immr)
33 /* The highest 16 bits should be 0x0002 for a MPC555/556 */
34 if ((pvr >> 16) == 0x0002) {
35 printf (" " ID_STR " Version %x", (pvr >> 16));
36 printf (" at %s MHz:", strmhz (buf, clock));
38 printf ("Not supported cpu version");
43 #endif /* CONFIG_MPC555 */
47 * Check version of mpc5xx
51 ulong clock = gd->cpu_clk;
52 uint immr = get_immr (0); /* Return full IMMR contents */
53 uint pvr = get_pvr (); /* Retrieve PVR register */
57 return check_cpu_version (clock, pvr, immr);
61 * Called by macro WATCHDOG_RESET
63 #if defined(CONFIG_WATCHDOG)
64 void watchdog_reset (void)
66 int re_enable = disable_interrupts ();
68 reset_5xx_watchdog ((immap_t *) CONFIG_SYS_IMMR);
74 * Will clear software reset
76 void reset_5xx_watchdog (volatile immap_t * immr)
78 /* Use the MPC5xx Internal Watchdog */
79 immr->im_siu_conf.sc_swsr = 0x556c; /* Prevent SW time-out */
80 immr->im_siu_conf.sc_swsr = 0xaa39;
83 #endif /* CONFIG_WATCHDOG */
87 * Get timebase clock frequency
89 unsigned long get_tbclk (void)
91 volatile immap_t *immr = (volatile immap_t *) CONFIG_SYS_IMMR;
94 if (immr->im_clkrst.car_sccr & SCCR_TBS) {
95 return (gd->cpu_clk / 16);
98 factor = (((CONFIG_SYS_PLPRCR) & PLPRCR_MF_MSK) >> PLPRCR_MF_SHIFT) + 1;
100 oscclk = gd->cpu_clk / factor;
102 if ((immr->im_clkrst.car_sccr & SCCR_RTSEL) == 0 || factor > 2) {
105 return (oscclk / 16);
108 void dcache_enable (void)
113 void dcache_disable (void)
118 int dcache_status (void)
120 return 0; /* always off */
126 int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
128 #if defined(CONFIG_PATI)
129 volatile ulong *addr = (ulong *) CONFIG_SYS_RESET_ADDRESS;
134 /* Interrupts off, enable reset */
135 __asm__ volatile (" mtspr 81, %r0 \n\t"
137 " rlwinm %r31,%r3,0,25,23\n\t"
140 * Trying to execute the next instruction at a non-existing address
141 * should cause a machine check, resulting in reset
143 #ifdef CONFIG_SYS_RESET_ADDRESS
144 addr = CONFIG_SYS_RESET_ADDRESS;
147 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE * - sizeof (ulong) is usually a valid address. Better pick an address
148 * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
149 * "(ulong)-1" used to be a good choice for many systems...
151 addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
153 ((void (*) (void)) addr) ();
154 #endif /* #if defined(CONFIG_PATI) */