1 // SPDX-License-Identifier: GPL-2.0+
13 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
22 #include <asm/immap.h>
27 DECLARE_GLOBAL_DATA_PTR;
30 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
32 rcm_t *rcm = (rcm_t *)(MMAP_RCM);
36 out_8(&rcm->rcr, RCM_RCR_SOFTRST);
38 /* we don't return! */
42 #if defined(CONFIG_DISPLAY_CPUINFO)
43 int print_cpuinfo(void)
45 char buf1[32], buf2[32];
47 printf("CPU: Freescale Coldfire MCF5208\n"
48 " CPU CLK %s MHz BUS CLK %s MHz\n",
49 strmhz(buf1, gd->cpu_clk),
50 strmhz(buf2, gd->bus_clk));
53 #endif /* CONFIG_DISPLAY_CPUINFO */
55 #if defined(CONFIG_WATCHDOG)
56 /* Called by macro WATCHDOG_RESET */
57 void watchdog_reset(void)
59 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
61 out_be16(&wdt->sr, 0x5555);
62 out_be16(&wdt->sr, 0xaaaa);
65 int watchdog_disable(void)
67 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
69 /* reset watchdog counter */
70 out_be16(&wdt->sr, 0x5555);
71 out_be16(&wdt->sr, 0xaaaa);
72 /* disable watchdog timer */
73 out_be16(&wdt->cr, 0);
75 puts("WATCHDOG:disabled\n");
79 int watchdog_init(void)
81 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
83 /* disable watchdog */
84 out_be16(&wdt->cr, 0);
86 /* set timeout and enable watchdog */
88 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
90 /* reset watchdog counter */
91 out_be16(&wdt->sr, 0x5555);
92 out_be16(&wdt->sr, 0xaaaa);
94 puts("WATCHDOG:enabled\n");
97 #endif /* #ifdef CONFIG_WATCHDOG */
98 #endif /* #ifdef CONFIG_M5208 */
101 #if defined(CONFIG_DISPLAY_CPUINFO)
103 * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to
104 * determine which one we are running on, based on the Chip Identification
107 int print_cpuinfo(void)
110 unsigned short cir; /* Chip Identification Register */
111 unsigned short pin; /* Part identification number */
112 unsigned char prn; /* Part revision number */
115 cir = mbar_readShort(MCF_CCM_CIR);
116 pin = cir >> MCF_CCM_CIR_PIN_LEN;
117 prn = cir & MCF_CCM_CIR_PRN_MASK;
120 case MCF_CCM_CIR_PIN_MCF5270:
123 case MCF_CCM_CIR_PIN_MCF5271:
132 printf("CPU: Freescale ColdFire MCF%s rev. %hu, at %s MHz\n",
133 cpu_model, prn, strmhz(buf, CONFIG_SYS_CLK));
135 printf("CPU: Unknown - Freescale ColdFire MCF5271 family"
136 " (PIN: 0x%x) rev. %hu, at %s MHz\n",
137 pin, prn, strmhz(buf, CONFIG_SYS_CLK));
141 #endif /* CONFIG_DISPLAY_CPUINFO */
143 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
145 /* Call the board specific reset actions first. */
150 mbar_writeByte(MCF_RCM_RCR,
151 MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT);
155 #if defined(CONFIG_WATCHDOG)
156 void watchdog_reset(void)
158 mbar_writeShort(MCF_WTM_WSR, 0x5555);
159 mbar_writeShort(MCF_WTM_WSR, 0xAAAA);
162 int watchdog_disable(void)
164 mbar_writeShort(MCF_WTM_WCR, 0);
168 int watchdog_init(void)
170 mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN);
173 #endif /* #ifdef CONFIG_WATCHDOG */
178 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
180 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
182 out_be16(&wdp->wdog_wrrr, 0);
185 /* enable watchdog, set timeout to 0 and wait */
186 out_be16(&wdp->wdog_wrrr, 1);
189 /* we don't return! */
193 #if defined(CONFIG_DISPLAY_CPUINFO)
194 int print_cpuinfo(void)
196 sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG);
201 msk = (in_be32(&sysctrl->sc_dir) > 28) & 0xf;
211 printf("Freescale MCF5272 (Mask:%01x)\n", msk);
216 printf("Freescale MCF5272 %s\n", suf);
219 #endif /* CONFIG_DISPLAY_CPUINFO */
221 #if defined(CONFIG_WATCHDOG)
222 /* Called by macro WATCHDOG_RESET */
223 void watchdog_reset(void)
225 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
227 out_be16(&wdt->wdog_wcr, 0);
230 int watchdog_disable(void)
232 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
234 /* reset watchdog counter */
235 out_be16(&wdt->wdog_wcr, 0);
236 /* disable watchdog interrupt */
237 out_be16(&wdt->wdog_wirr, 0);
238 /* disable watchdog timer */
239 out_be16(&wdt->wdog_wrrr, 0);
241 puts("WATCHDOG:disabled\n");
245 int watchdog_init(void)
247 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
249 /* disable watchdog interrupt */
250 out_be16(&wdt->wdog_wirr, 0);
252 /* set timeout and enable watchdog */
253 out_be16(&wdt->wdog_wrrr,
254 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
256 /* reset watchdog counter */
257 out_be16(&wdt->wdog_wcr, 0);
259 puts("WATCHDOG:enabled\n");
262 #endif /* #ifdef CONFIG_WATCHDOG */
264 #endif /* #ifdef CONFIG_M5272 */
267 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
269 rcm_t *rcm = (rcm_t *)(MMAP_RCM);
273 out_8(&rcm->rcr, RCM_RCR_SOFTRST);
275 /* we don't return! */
279 #if defined(CONFIG_DISPLAY_CPUINFO)
280 int print_cpuinfo(void)
284 printf("CPU: Freescale Coldfire MCF5275 at %s MHz\n",
285 strmhz(buf, CONFIG_SYS_CLK));
288 #endif /* CONFIG_DISPLAY_CPUINFO */
290 #if defined(CONFIG_WATCHDOG)
291 /* Called by macro WATCHDOG_RESET */
292 void watchdog_reset(void)
294 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
296 out_be16(&wdt->wsr, 0x5555);
297 out_be16(&wdt->wsr, 0xaaaa);
300 int watchdog_disable(void)
302 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
304 /* reset watchdog counter */
305 out_be16(&wdt->wsr, 0x5555);
306 out_be16(&wdt->wsr, 0xaaaa);
308 /* disable watchdog timer */
309 out_be16(&wdt->wcr, 0);
311 puts("WATCHDOG:disabled\n");
315 int watchdog_init(void)
317 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
319 /* disable watchdog */
320 out_be16(&wdt->wcr, 0);
322 /* set timeout and enable watchdog */
324 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
326 /* reset watchdog counter */
327 out_be16(&wdt->wsr, 0x5555);
328 out_be16(&wdt->wsr, 0xaaaa);
330 puts("WATCHDOG:enabled\n");
333 #endif /* #ifdef CONFIG_WATCHDOG */
335 #endif /* #ifdef CONFIG_M5275 */
338 #if defined(CONFIG_DISPLAY_CPUINFO)
339 int print_cpuinfo(void)
341 unsigned char resetsource = MCFRESET_RSR;
343 printf("CPU: Freescale Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n",
344 MCFCCM_CIR >> 8, MCFCCM_CIR & MCFCCM_CIR_PRN_MASK);
345 printf("Reset:%s%s%s%s%s%s%s\n",
346 (resetsource & MCFRESET_RSR_LOL) ? " Loss of Lock" : "",
347 (resetsource & MCFRESET_RSR_LOC) ? " Loss of Clock" : "",
348 (resetsource & MCFRESET_RSR_EXT) ? " External" : "",
349 (resetsource & MCFRESET_RSR_POR) ? " Power On" : "",
350 (resetsource & MCFRESET_RSR_WDR) ? " Watchdog" : "",
351 (resetsource & MCFRESET_RSR_SOFT) ? " Software" : "",
352 (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : "");
355 #endif /* CONFIG_DISPLAY_CPUINFO */
357 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
359 MCFRESET_RCR = MCFRESET_RCR_SOFTRST;
365 #if defined(CONFIG_DISPLAY_CPUINFO)
366 int print_cpuinfo(void)
370 printf("CPU: Freescale Coldfire MCF5249 at %s MHz\n",
371 strmhz(buf, CONFIG_SYS_CLK));
374 #endif /* CONFIG_DISPLAY_CPUINFO */
376 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
378 /* enable watchdog, set timeout to 0 and wait */
379 mbar_writeByte(MCFSIM_SYPCR, 0xc0);
382 /* we don't return! */
388 #if defined(CONFIG_DISPLAY_CPUINFO)
389 int print_cpuinfo(void)
393 unsigned char resetsource = mbar_readLong(SIM_RSR);
394 printf("CPU: Freescale Coldfire MCF5253 at %s MHz\n",
395 strmhz(buf, CONFIG_SYS_CLK));
397 if ((resetsource & SIM_RSR_HRST) || (resetsource & SIM_RSR_SWTR)) {
398 printf("Reset:%s%s\n",
399 (resetsource & SIM_RSR_HRST) ? " Hardware/ System Reset"
401 (resetsource & SIM_RSR_SWTR) ? " Software Watchdog" :
406 #endif /* CONFIG_DISPLAY_CPUINFO */
408 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
410 /* enable watchdog, set timeout to 0 and wait */
411 mbar_writeByte(SIM_SYPCR, 0xc0);
414 /* we don't return! */
419 #if defined(CONFIG_MCFFEC)
420 /* Default initializations for MCFFEC controllers. To override,
421 * create a board-specific function called:
422 * int board_eth_init(bd_t *bis)
425 int cpu_eth_init(bd_t *bis)
427 return mcffec_initialize(bis);