blob: 8c808a6b0ce69c91e7f793d4c5e8aea94fb00194 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew4a442d32007-08-16 19:23:50 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wangc6d88632012-03-26 21:49:06 +00007 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew4a442d32007-08-16 19:23:50 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew4a442d32007-08-16 19:23:50 -05009 */
10
11#include <common.h>
Simon Glass90526e92020-05-10 11:39:56 -060012#include <net.h>
Simon Glass2189d5f2019-11-14 12:57:20 -070013#include <vsprintf.h>
TsiChungLiew4a442d32007-08-16 19:23:50 -050014#include <watchdog.h>
15#include <command.h>
Ben Warren89973f82008-08-31 22:22:04 -070016#include <netdev.h>
TsiChungLiew4a442d32007-08-16 19:23:50 -050017
18#include <asm/immap.h>
Alison Wangc6d88632012-03-26 21:49:06 +000019#include <asm/io.h>
TsiChungLiew4a442d32007-08-16 19:23:50 -050020
21DECLARE_GLOBAL_DATA_PTR;
22
Mike Frysinger882b7d72010-10-20 03:41:17 -040023int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
TsiChungLiew4a442d32007-08-16 19:23:50 -050024{
Alison Wangc6d88632012-03-26 21:49:06 +000025 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChungLiew4a442d32007-08-16 19:23:50 -050026
Alison Wangc6d88632012-03-26 21:49:06 +000027 out_8(&ccm->rcr, CCM_RCR_SOFTRST);
TsiChungLiew4a442d32007-08-16 19:23:50 -050028 /* we don't return! */
29 return 0;
Alison Wangc6d88632012-03-26 21:49:06 +000030}
TsiChungLiew4a442d32007-08-16 19:23:50 -050031
Angelo Dureghellob9153fe32017-08-20 00:01:55 +020032#if defined(CONFIG_DISPLAY_CPUINFO)
33int print_cpuinfo(void)
TsiChungLiew4a442d32007-08-16 19:23:50 -050034{
Alison Wangc6d88632012-03-26 21:49:06 +000035 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChungLiew4a442d32007-08-16 19:23:50 -050036 u16 msk;
37 u16 id = 0;
38 u8 ver;
39
40 puts("CPU: ");
Alison Wangc6d88632012-03-26 21:49:06 +000041 msk = (in_be16(&ccm->cir) >> 6);
42 ver = (in_be16(&ccm->cir) & 0x003f);
TsiChungLiew4a442d32007-08-16 19:23:50 -050043 switch (msk) {
44 case 0x31:
45 id = 5235;
46 break;
47 }
48
49 if (id) {
Wolfgang Denk08ef89e2008-10-19 02:35:49 +020050 char buf1[32], buf2[32];
51
TsiChungLiew4a442d32007-08-16 19:23:50 -050052 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
53 ver);
Wolfgang Denk08ef89e2008-10-19 02:35:49 +020054 printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
TsiChung Liew1b270842008-10-22 11:55:30 +000055 strmhz(buf1, gd->cpu_clk),
56 strmhz(buf2, gd->bus_clk));
TsiChungLiew4a442d32007-08-16 19:23:50 -050057 }
58
59 return 0;
60};
Angelo Dureghellob9153fe32017-08-20 00:01:55 +020061#endif /* CONFIG_DISPLAY_CPUINFO */
TsiChungLiew4a442d32007-08-16 19:23:50 -050062
63#if defined(CONFIG_WATCHDOG)
64/* Called by macro WATCHDOG_RESET */
65void watchdog_reset(void)
66{
Alison Wangc6d88632012-03-26 21:49:06 +000067 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiew4a442d32007-08-16 19:23:50 -050068
Alison Wangc6d88632012-03-26 21:49:06 +000069 /* Count register */
70 out_be16(&wdp->sr, 0x5555);
TsiChungLiew4a442d32007-08-16 19:23:50 -050071 asm("nop");
Alison Wangc6d88632012-03-26 21:49:06 +000072 out_be16(&wdp->sr, 0xaaaa);
TsiChungLiew4a442d32007-08-16 19:23:50 -050073}
74
75int watchdog_disable(void)
76{
Alison Wangc6d88632012-03-26 21:49:06 +000077 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiew4a442d32007-08-16 19:23:50 -050078
79 /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
Alison Wangc6d88632012-03-26 21:49:06 +000080 /* halted watchdog timer */
81 setbits_be16(&wdp->cr, WTM_WCR_HALTED);
TsiChungLiew4a442d32007-08-16 19:23:50 -050082
83 puts("WATCHDOG:disabled\n");
84 return (0);
85}
86
87int watchdog_init(void)
88{
Alison Wangc6d88632012-03-26 21:49:06 +000089 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChungLiew4a442d32007-08-16 19:23:50 -050090 u32 wdog_module = 0;
91
92 /* set timeout and enable watchdog */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093 wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
TsiChungLiew4a442d32007-08-16 19:23:50 -050094 wdog_module |= (wdog_module / 8192);
Alison Wangc6d88632012-03-26 21:49:06 +000095 out_be16(&wdp->mr, wdog_module);
TsiChungLiew4a442d32007-08-16 19:23:50 -050096
Alison Wangc6d88632012-03-26 21:49:06 +000097 out_be16(&wdp->cr, WTM_WCR_EN);
TsiChungLiew4a442d32007-08-16 19:23:50 -050098 puts("WATCHDOG:enabled\n");
99
100 return (0);
101}
102#endif /* CONFIG_WATCHDOG */
Ben Warren86882b82008-08-26 22:16:25 -0700103
104#if defined(CONFIG_MCFFEC)
105/* Default initializations for MCFFEC controllers. To override,
106 * create a board-specific function called:
107 * int board_eth_init(bd_t *bis)
108 */
109
Ben Warren86882b82008-08-26 22:16:25 -0700110int cpu_eth_init(bd_t *bis)
111{
112 return mcffec_initialize(bis);
113}
114#endif