1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
7 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
8 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
9 */
10
11 #include <common.h>
12 #include <init.h>
13 #include <net.h>
14 #include <vsprintf.h>
15 #include <watchdog.h>
16 #include <command.h>
17 #include <netdev.h>
18 #include <asm/global_data.h>
19
20 #include <asm/immap.h>
21 #include <asm/io.h>
22
23 DECLARE_GLOBAL_DATA_PTR;
24
do_reset(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])25 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
26 {
27 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
28
29 out_be16(&gptmr->pre, 10);
30 out_be16(&gptmr->cnt, 1);
31
32 /* enable watchdog, set timeout to 0 and wait */
33 out_8(&gptmr->mode, GPT_TMS_SGPIO);
34 out_8(&gptmr->ctrl, GPT_CTRL_WDEN | GPT_CTRL_CE);
35
36 /* we don't return! */
37 return 1;
38 };
39
40 #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo(void)41 int print_cpuinfo(void)
42 {
43 siu_t *siu = (siu_t *) MMAP_SIU;
44 u16 id = 0;
45
46 puts("CPU: ");
47
48 switch ((in_be32(&siu->jtagid) & 0x000FF000) >> 12) {
49 case 0x0C:
50 id = 5485;
51 break;
52 case 0x0D:
53 id = 5484;
54 break;
55 case 0x0E:
56 id = 5483;
57 break;
58 case 0x0F:
59 id = 5482;
60 break;
61 case 0x10:
62 id = 5481;
63 break;
64 case 0x11:
65 id = 5480;
66 break;
67 case 0x12:
68 id = 5475;
69 break;
70 case 0x13:
71 id = 5474;
72 break;
73 case 0x14:
74 id = 5473;
75 break;
76 case 0x15:
77 id = 5472;
78 break;
79 case 0x16:
80 id = 5471;
81 break;
82 case 0x17:
83 id = 5470;
84 break;
85 }
86
87 if (id) {
88 char buf1[32], buf2[32];
89
90 printf("Freescale MCF%d\n", id);
91 printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
92 strmhz(buf1, gd->cpu_clk),
93 strmhz(buf2, gd->bus_clk));
94 }
95
96 return 0;
97 };
98 #endif /* CONFIG_DISPLAY_CPUINFO */
99
100 #if defined(CONFIG_HW_WATCHDOG)
101 /* Called by macro WATCHDOG_RESET */
hw_watchdog_reset(void)102 void hw_watchdog_reset(void)
103 {
104 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
105
106 out_8(&gptmr->ocpw, 0xa5);
107 }
108
watchdog_disable(void)109 int watchdog_disable(void)
110 {
111 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
112
113 /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
114 out_8(&gptmr->mode, 0);
115 out_8(&gptmr->ctrl, 0);
116
117 puts("WATCHDOG:disabled\n");
118
119 return (0);
120 }
121
watchdog_init(void)122 int watchdog_init(void)
123 {
124 gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
125
126 out_be16(&gptmr->pre, CONFIG_WATCHDOG_TIMEOUT);
127 out_be16(&gptmr->cnt, CONFIG_SYS_TIMER_PRESCALER * 1000);
128
129 out_8(&gptmr->mode, GPT_TMS_SGPIO);
130 out_8(&gptmr->ctrl, GPT_CTRL_CE | GPT_CTRL_WDEN);
131 puts("WATCHDOG:enabled\n");
132
133 return (0);
134 }
135 #endif /* CONFIG_HW_WATCHDOG */
136
137 #if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC)
138 /* Default initializations for MCFFEC controllers. To override,
139 * create a board-specific function called:
140 * int board_eth_init(struct bd_info *bis)
141 */
142
cpu_eth_init(struct bd_info * bis)143 int cpu_eth_init(struct bd_info *bis)
144 {
145 #if defined(CONFIG_FSLDMAFEC)
146 mcdmafec_initialize(bis);
147 #endif
148 #if defined(CONFIG_MCFFEC)
149 mcffec_initialize(bis);
150 #endif
151 return 0;
152 }
153 #endif
154