blob: 429781945bfc038eb3bfa965f28bd9eea6827337 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiewb859ef12007-08-16 19:23:50 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wangd132fe62012-03-26 21:49:06 +00007 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiewb859ef12007-08-16 19:23:50 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiewb859ef12007-08-16 19:23:50 -05009 */
10
11#include <common.h>
Simon Glassf5c208d2019-11-14 12:57:20 -070012#include <vsprintf.h>
TsiChungLiewb859ef12007-08-16 19:23:50 -050013#include <watchdog.h>
14#include <command.h>
Ben Warren2f2b6b62008-08-31 22:22:04 -070015#include <netdev.h>
TsiChungLiewb859ef12007-08-16 19:23:50 -050016
17#include <asm/immap.h>
Alison Wangd132fe62012-03-26 21:49:06 +000018#include <asm/io.h>
TsiChungLiewb859ef12007-08-16 19:23:50 -050019
20DECLARE_GLOBAL_DATA_PTR;
21
Mike Frysinger6d1f6982010-10-20 03:41:17 -040022int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
TsiChungLiewb859ef12007-08-16 19:23:50 -050023{
Alison Wangd132fe62012-03-26 21:49:06 +000024 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChungLiewb859ef12007-08-16 19:23:50 -050025
Alison Wangd132fe62012-03-26 21:49:06 +000026 out_8(&ccm->rcr, CCM_RCR_SOFTRST);
TsiChungLiewb859ef12007-08-16 19:23:50 -050027 /* we don't return! */
28 return 0;
Alison Wangd132fe62012-03-26 21:49:06 +000029}
TsiChungLiewb859ef12007-08-16 19:23:50 -050030
Angelo Dureghello3146b4d2017-08-20 00:01:55 +020031#if defined(CONFIG_DISPLAY_CPUINFO)
32int print_cpuinfo(void)
TsiChungLiewb859ef12007-08-16 19:23:50 -050033{
Alison Wangd132fe62012-03-26 21:49:06 +000034 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChungLiewb859ef12007-08-16 19:23:50 -050035 u16 msk;
36 u16 id = 0;
37 u8 ver;
38
39 puts("CPU: ");
Alison Wangd132fe62012-03-26 21:49:06 +000040 msk = (in_be16(&ccm->cir) >> 6);
41 ver = (in_be16(&ccm->cir) & 0x003f);
TsiChungLiewb859ef12007-08-16 19:23:50 -050042 switch (msk) {
43 case 0x31:
44 id = 5235;
45 break;
46 }
47
48 if (id) {
Wolfgang Denk20591042008-10-19 02:35:49 +020049 char buf1[32], buf2[32];
50
TsiChungLiewb859ef12007-08-16 19:23:50 -050051 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
52 ver);
Wolfgang Denk20591042008-10-19 02:35:49 +020053 printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
TsiChung Liew10e9a6e2008-10-22 11:55:30 +000054 strmhz(buf1, gd->cpu_clk),
55 strmhz(buf2, gd->bus_clk));
TsiChungLiewb859ef12007-08-16 19:23:50 -050056 }
57
58 return 0;
59};
Angelo Dureghello3146b4d2017-08-20 00:01:55 +020060#endif /* CONFIG_DISPLAY_CPUINFO */
TsiChungLiewb859ef12007-08-16 19:23:50 -050061
62#if defined(CONFIG_WATCHDOG)
63/* Called by macro WATCHDOG_RESET */
64void watchdog_reset(void)
65{
Alison Wangd132fe62012-03-26 21:49:06 +000066 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiewb859ef12007-08-16 19:23:50 -050067
Alison Wangd132fe62012-03-26 21:49:06 +000068 /* Count register */
69 out_be16(&wdp->sr, 0x5555);
TsiChungLiewb859ef12007-08-16 19:23:50 -050070 asm("nop");
Alison Wangd132fe62012-03-26 21:49:06 +000071 out_be16(&wdp->sr, 0xaaaa);
TsiChungLiewb859ef12007-08-16 19:23:50 -050072}
73
74int watchdog_disable(void)
75{
Alison Wangd132fe62012-03-26 21:49:06 +000076 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiewb859ef12007-08-16 19:23:50 -050077
78 /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
Alison Wangd132fe62012-03-26 21:49:06 +000079 /* halted watchdog timer */
80 setbits_be16(&wdp->cr, WTM_WCR_HALTED);
TsiChungLiewb859ef12007-08-16 19:23:50 -050081
82 puts("WATCHDOG:disabled\n");
83 return (0);
84}
85
86int watchdog_init(void)
87{
Alison Wangd132fe62012-03-26 21:49:06 +000088 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiewb859ef12007-08-16 19:23:50 -050089 u32 wdog_module = 0;
90
91 /* set timeout and enable watchdog */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
TsiChungLiewb859ef12007-08-16 19:23:50 -050093 wdog_module |= (wdog_module / 8192);
Alison Wangd132fe62012-03-26 21:49:06 +000094 out_be16(&wdp->mr, wdog_module);
TsiChungLiewb859ef12007-08-16 19:23:50 -050095
Alison Wangd132fe62012-03-26 21:49:06 +000096 out_be16(&wdp->cr, WTM_WCR_EN);
TsiChungLiewb859ef12007-08-16 19:23:50 -050097 puts("WATCHDOG:enabled\n");
98
99 return (0);
100}
101#endif /* CONFIG_WATCHDOG */
Ben Warren90c96db2008-08-26 22:16:25 -0700102
103#if defined(CONFIG_MCFFEC)
104/* Default initializations for MCFFEC controllers. To override,
105 * create a board-specific function called:
106 * int board_eth_init(bd_t *bis)
107 */
108
Ben Warren90c96db2008-08-26 22:16:25 -0700109int cpu_eth_init(bd_t *bis)
110{
111 return mcffec_initialize(bis);
112}
113#endif