blob: e53adeb46b55bfb9f8fde4343c795e69951eb37a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew8999e6b2008-01-15 13:37:34 -06002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wang027f76f2012-03-26 21:49:07 +00007 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew8999e6b2008-01-15 13:37:34 -06008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew8999e6b2008-01-15 13:37:34 -06009 */
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>
TsiChungLiew8999e6b2008-01-15 13:37:34 -060015#include <watchdog.h>
16#include <command.h>
Ben Warren2f2b6b62008-08-31 22:22:04 -070017#include <netdev.h>
TsiChungLiew8999e6b2008-01-15 13:37:34 -060018
19#include <asm/immap.h>
Alison Wang027f76f2012-03-26 21:49:07 +000020#include <asm/io.h>
TsiChungLiew8999e6b2008-01-15 13:37:34 -060021
22DECLARE_GLOBAL_DATA_PTR;
23
Simon Glassed38aef2020-05-10 11:40:03 -060024int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
TsiChungLiew8999e6b2008-01-15 13:37:34 -060025{
Alison Wang027f76f2012-03-26 21:49:07 +000026 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060027
Alison Wang027f76f2012-03-26 21:49:07 +000028 out_be16(&gptmr->pre, 10);
29 out_be16(&gptmr->cnt, 1);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060030
31 /* enable watchdog, set timeout to 0 and wait */
Alison Wang027f76f2012-03-26 21:49:07 +000032 out_8(&gptmr->mode, GPT_TMS_SGPIO);
33 out_8(&gptmr->ctrl, GPT_CTRL_WDEN | GPT_CTRL_CE);
TsiChungLiew8999e6b2008-01-15 13:37:34 -060034
35 /* we don't return! */
36 return 1;
37};
38
Angelo Dureghello3146b4d2017-08-20 00:01:55 +020039#if defined(CONFIG_DISPLAY_CPUINFO)
40int print_cpuinfo(void)
TsiChungLiew8999e6b2008-01-15 13:37:34 -060041{
Alison Wang027f76f2012-03-26 21:49:07 +000042 siu_t *siu = (siu_t *) MMAP_SIU;
TsiChungLiew8999e6b2008-01-15 13:37:34 -060043 u16 id = 0;
44
45 puts("CPU: ");
46
Alison Wang027f76f2012-03-26 21:49:07 +000047 switch ((in_be32(&siu->jtagid) & 0x000FF000) >> 12) {
TsiChungLiew8999e6b2008-01-15 13:37:34 -060048 case 0x0C:
49 id = 5485;
50 break;
51 case 0x0D:
52 id = 5484;
53 break;
54 case 0x0E:
55 id = 5483;
56 break;
57 case 0x0F:
58 id = 5482;
59 break;
60 case 0x10:
61 id = 5481;
62 break;
63 case 0x11:
64 id = 5480;
65 break;
66 case 0x12:
67 id = 5475;
68 break;
69 case 0x13:
70 id = 5474;
71 break;
72 case 0x14:
73 id = 5473;
74 break;
75 case 0x15:
76 id = 5472;
77 break;
78 case 0x16:
79 id = 5471;
80 break;
81 case 0x17:
82 id = 5470;
83 break;
84 }
85
86 if (id) {
Wolfgang Denk20591042008-10-19 02:35:49 +020087 char buf1[32], buf2[32];
88
TsiChungLiew8999e6b2008-01-15 13:37:34 -060089 printf("Freescale MCF%d\n", id);
Wolfgang Denk20591042008-10-19 02:35:49 +020090 printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
91 strmhz(buf1, gd->cpu_clk),
92 strmhz(buf2, gd->bus_clk));
TsiChungLiew8999e6b2008-01-15 13:37:34 -060093 }
94
95 return 0;
96};
Angelo Dureghello3146b4d2017-08-20 00:01:55 +020097#endif /* CONFIG_DISPLAY_CPUINFO */
TsiChungLiew8999e6b2008-01-15 13:37:34 -060098
99#if defined(CONFIG_HW_WATCHDOG)
100/* Called by macro WATCHDOG_RESET */
101void hw_watchdog_reset(void)
102{
Alison Wang027f76f2012-03-26 21:49:07 +0000103 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600104
Alison Wang027f76f2012-03-26 21:49:07 +0000105 out_8(&gptmr->ocpw, 0xa5);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600106}
107
108int watchdog_disable(void)
109{
Alison Wang027f76f2012-03-26 21:49:07 +0000110 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600111
112 /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
Alison Wang027f76f2012-03-26 21:49:07 +0000113 out_8(&gptmr->mode, 0);
114 out_8(&gptmr->ctrl, 0);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600115
116 puts("WATCHDOG:disabled\n");
117
118 return (0);
119}
120
121int watchdog_init(void)
122{
Alison Wang027f76f2012-03-26 21:49:07 +0000123 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600124
Alison Wang027f76f2012-03-26 21:49:07 +0000125 out_be16(&gptmr->pre, CONFIG_WATCHDOG_TIMEOUT);
126 out_be16(&gptmr->cnt, CONFIG_SYS_TIMER_PRESCALER * 1000);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600127
Alison Wang027f76f2012-03-26 21:49:07 +0000128 out_8(&gptmr->mode, GPT_TMS_SGPIO);
129 out_8(&gptmr->ctrl, GPT_CTRL_CE | GPT_CTRL_WDEN);
TsiChungLiew8999e6b2008-01-15 13:37:34 -0600130 puts("WATCHDOG:enabled\n");
131
132 return (0);
133}
134#endif /* CONFIG_HW_WATCHDOG */
Ben Warrene7edd4e2008-08-26 22:12:36 -0700135
Ben Warren90c96db2008-08-26 22:16:25 -0700136#if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC)
137/* Default initializations for MCFFEC controllers. To override,
138 * create a board-specific function called:
Masahiro Yamada940a9222020-06-26 15:13:34 +0900139 * int board_eth_init(struct bd_info *bis)
Ben Warren90c96db2008-08-26 22:16:25 -0700140 */
141
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900142int cpu_eth_init(struct bd_info *bis)
Ben Warrene7edd4e2008-08-26 22:12:36 -0700143{
Ben Warren90c96db2008-08-26 22:16:25 -0700144#if defined(CONFIG_FSLDMAFEC)
145 mcdmafec_initialize(bis);
146#endif
147#if defined(CONFIG_MCFFEC)
148 mcffec_initialize(bis);
149#endif
150 return 0;
Ben Warrene7edd4e2008-08-26 22:12:36 -0700151}
152#endif