blob: 1dadffd4ca3633e7fa7e88231734e18dde242861 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChung Liewf6afe722007-06-18 13:50:13 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wang35d23df2012-03-26 21:49:05 +00007 * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
TsiChung Liewf6afe722007-06-18 13:50:13 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChung Liewf6afe722007-06-18 13:50:13 -05009 */
10
11#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060013#include <net.h>
Simon Glassf5c208d2019-11-14 12:57:20 -070014#include <vsprintf.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050015#include <watchdog.h>
16#include <command.h>
Ben Warren2f2b6b62008-08-31 22:22:04 -070017#include <netdev.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Simon Glassdbd79542020-05-10 11:40:11 -060019#include <linux/delay.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050020
TsiChungLiewfb661742007-07-05 23:01:22 -050021#include <asm/immap.h>
Alison Wang35d23df2012-03-26 21:49:05 +000022#include <asm/io.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050023
Wolfgang Denkd112a2c2007-09-15 20:48:41 +020024DECLARE_GLOBAL_DATA_PTR;
25
Simon Glassed38aef2020-05-10 11:40:03 -060026int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
TsiChung Liewf6afe722007-06-18 13:50:13 -050027{
Alison Wang35d23df2012-03-26 21:49:05 +000028 rcm_t *rcm = (rcm_t *) (MMAP_RCM);
TsiChung Liewf6afe722007-06-18 13:50:13 -050029
TsiChung Liewf6afe722007-06-18 13:50:13 -050030 udelay(1000);
Alison Wang35d23df2012-03-26 21:49:05 +000031 setbits_8(&rcm->rcr, RCM_RCR_SOFTRST);
TsiChung Liewf6afe722007-06-18 13:50:13 -050032
33 /* we don't return! */
34 return 0;
35};
36
Angelo Dureghello3146b4d2017-08-20 00:01:55 +020037#if defined(CONFIG_DISPLAY_CPUINFO)
38int print_cpuinfo(void)
TsiChung Liewf6afe722007-06-18 13:50:13 -050039{
Alison Wang35d23df2012-03-26 21:49:05 +000040 ccm_t *ccm = (ccm_t *) MMAP_CCM;
TsiChung Liewf6afe722007-06-18 13:50:13 -050041 u16 msk;
42 u16 id = 0;
43 u8 ver;
44
45 puts("CPU: ");
Alison Wang35d23df2012-03-26 21:49:05 +000046 msk = (in_be16(&ccm->cir) >> 6);
47 ver = (in_be16(&ccm->cir) & 0x003f);
TsiChung Liewf6afe722007-06-18 13:50:13 -050048 switch (msk) {
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000049#ifdef CONFIG_MCF5301x
50 case 0x78:
51 id = 53010;
52 break;
53 case 0x77:
54 id = 53012;
55 break;
56 case 0x76:
57 id = 53015;
58 break;
59 case 0x74:
60 id = 53011;
61 break;
62 case 0x73:
63 id = 53013;
64 break;
65#endif
66#ifdef CONFIG_MCF532x
TsiChung Liewf6afe722007-06-18 13:50:13 -050067 case 0x54:
68 id = 5329;
69 break;
70 case 0x59:
71 id = 5328;
72 break;
73 case 0x61:
74 id = 5327;
75 break;
TsiChungLiew6f8a0a32008-01-14 17:23:08 -060076 case 0x65:
77 id = 5373;
78 break;
79 case 0x68:
80 id = 53721;
81 break;
82 case 0x69:
83 id = 5372;
84 break;
85 case 0x6B:
86 id = 5372;
87 break;
TsiChung Liewe7e4fc82008-10-22 11:38:21 +000088#endif
TsiChung Liewf6afe722007-06-18 13:50:13 -050089 }
90
91 if (id) {
Wolfgang Denk20591042008-10-19 02:35:49 +020092 char buf1[32], buf2[32];
93
TsiChung Liewf6afe722007-06-18 13:50:13 -050094 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
95 ver);
Wolfgang Denk20591042008-10-19 02:35:49 +020096 printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
TsiChung Liew10e9a6e2008-10-22 11:55:30 +000097 strmhz(buf1, gd->cpu_clk),
98 strmhz(buf2, gd->bus_clk));
TsiChung Liewf6afe722007-06-18 13:50:13 -050099 }
100
101 return 0;
102};
Angelo Dureghello3146b4d2017-08-20 00:01:55 +0200103#endif /* CONFIG_DISPLAY_CPUINFO */
TsiChung Liewf6afe722007-06-18 13:50:13 -0500104
105#if defined(CONFIG_WATCHDOG)
106/* Called by macro WATCHDOG_RESET */
107void watchdog_reset(void)
108{
Alison Wang35d23df2012-03-26 21:49:05 +0000109 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500110
Alison Wang35d23df2012-03-26 21:49:05 +0000111 /* Count register */
112 out_be16(&wdp->sr, 0x5555);
113 out_be16(&wdp->sr, 0xaaaa);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500114}
115
116int watchdog_disable(void)
117{
Alison Wang35d23df2012-03-26 21:49:05 +0000118 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500119
120 /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
Alison Wang35d23df2012-03-26 21:49:05 +0000121 /* halted watchdog timer */
122 setbits_be16(&wdp->cr, WTM_WCR_HALTED);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500123
124 puts("WATCHDOG:disabled\n");
125 return (0);
126}
127
128int watchdog_init(void)
129{
Alison Wang35d23df2012-03-26 21:49:05 +0000130 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500131 u32 wdog_module = 0;
132
133 /* set timeout and enable watchdog */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200134 wdog_module = ((CONFIG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT);
TsiChungLiew6f8a0a32008-01-14 17:23:08 -0600135#ifdef CONFIG_M5329
Alison Wang35d23df2012-03-26 21:49:05 +0000136 out_be16(&wdp->mr, wdog_module / 8192);
TsiChungLiew6f8a0a32008-01-14 17:23:08 -0600137#else
Alison Wang35d23df2012-03-26 21:49:05 +0000138 out_be16(&wdp->mr, wdog_module / 4096);
TsiChungLiew6f8a0a32008-01-14 17:23:08 -0600139#endif
TsiChung Liewf6afe722007-06-18 13:50:13 -0500140
Alison Wang35d23df2012-03-26 21:49:05 +0000141 out_be16(&wdp->cr, WTM_WCR_EN);
TsiChung Liewf6afe722007-06-18 13:50:13 -0500142 puts("WATCHDOG:enabled\n");
143
144 return (0);
145}
TsiChungLiewfb661742007-07-05 23:01:22 -0500146#endif /* CONFIG_WATCHDOG */
Ben Warren90c96db2008-08-26 22:16:25 -0700147
148#if defined(CONFIG_MCFFEC)
149/* Default initializations for MCFFEC controllers. To override,
150 * create a board-specific function called:
Wolfgang Denk62fb2b42021-09-27 17:42:39 +0200151 * int board_eth_init(struct bd_info *bis)
Ben Warren90c96db2008-08-26 22:16:25 -0700152 */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900153int cpu_eth_init(struct bd_info *bis)
Ben Warren90c96db2008-08-26 22:16:25 -0700154{
155 return mcffec_initialize(bis);
156}
157#endif