blob: e6e5d9bee963b082aa26a505818c19b1266e0970 [file] [log] [blame]
wdenke65527f2004-02-12 00:47:09 +00001/*
2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <watchdog.h>
26#include <command.h>
27
Zachary P. Landau0bba8622006-01-26 17:35:56 -050028#ifdef CONFIG_M5271
29#include <asm/immap_5271.h>
30#include <asm/m5271.h>
31#endif
32
wdenke65527f2004-02-12 00:47:09 +000033#ifdef CONFIG_M5272
34#include <asm/immap_5272.h>
35#include <asm/m5272.h>
36#endif
37
38#ifdef CONFIG_M5282
39
40#endif
41
stroese53395a22004-12-16 18:09:49 +000042#ifdef CONFIG_M5249
43#include <asm/m5249.h>
44#endif
45
Zachary P. Landau0bba8622006-01-26 17:35:56 -050046#ifdef CONFIG_M5271
47int checkcpu (void)
48{
Marian Balakowiczecb6d0b2006-05-09 11:45:31 +020049 char buf[32];
50
51 printf ("CPU: Freescale Coldfire MCF5271 at %s MHz\n", strmhz(buf, CFG_CLK));
Zachary P. Landau0bba8622006-01-26 17:35:56 -050052 return 0;
53}
54
55int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
56 mbar_writeByte(MCF_RCM_RCR,
57 MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT);
58 return 0;
59};
60
61#if defined(CONFIG_WATCHDOG)
62void watchdog_reset (void)
63{
64 mbar_writeShort(MCF_WTM_WSR, 0x5555);
65 mbar_writeShort(MCF_WTM_WSR, 0xAAAA);
66}
67
68int watchdog_disable (void)
69{
70 mbar_writeShort(MCF_WTM_WCR, 0);
71 return (0);
72}
73
74int watchdog_init (void)
75{
Zachary P. Landau0bba8622006-01-26 17:35:56 -050076 mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN);
77 return (0);
78}
79#endif /* #ifdef CONFIG_WATCHDOG */
80
81#endif
wdenke65527f2004-02-12 00:47:09 +000082
83#ifdef CONFIG_M5272
84int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
85 volatile wdog_t * wdp = (wdog_t *)(CFG_MBAR + MCFSIM_WRRR);
86
87 wdp->wdog_wrrr = 0;
88 udelay (1000);
89
90 /* enable watchdog, set timeout to 0 and wait */
91 wdp->wdog_wrrr = 1;
92 while (1);
93
94 /* we don't return! */
95 return 0;
96};
97
98int checkcpu(void) {
99 ulong *dirp = (ulong *)(CFG_MBAR + MCFSIM_DIR);
100 uchar msk;
101 char *suf;
102
103 puts ("CPU: ");
104 msk = (*dirp > 28) & 0xf;
105 switch (msk) {
106 case 0x2: suf = "1K75N"; break;
107 case 0x4: suf = "3K75N"; break;
108 default:
109 suf = NULL;
Marian Balakowiczecb6d0b2006-05-09 11:45:31 +0200110 printf ("Freescale MCF5272 (Mask:%01x)\n", msk);
wdenke65527f2004-02-12 00:47:09 +0000111 break;
112 }
113
114 if (suf)
Marian Balakowiczecb6d0b2006-05-09 11:45:31 +0200115 printf ("Freescale MCF5272 %s\n", suf);
wdenke65527f2004-02-12 00:47:09 +0000116 return 0;
117};
118
119
120#if defined(CONFIG_WATCHDOG)
121/* Called by macro WATCHDOG_RESET */
122void watchdog_reset (void)
123{
124 volatile immap_t * regp = (volatile immap_t *)CFG_MBAR;
125 regp->wdog_reg.wdog_wcr = 0;
126}
127
128int watchdog_disable (void)
129{
130 volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
131
132 regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
133 regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
134 regp->wdog_reg.wdog_wrrr = 0; /* disable watchdog timer */
135
136 puts ("WATCHDOG:disabled\n");
137 return (0);
138}
139
140int watchdog_init (void)
141{
142 volatile immap_t *regp = (volatile immap_t *)CFG_MBAR;
143
144 regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */
145
146 /* set timeout and enable watchdog */
147 regp->wdog_reg.wdog_wrrr = ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1;
148 regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */
149
150 puts ("WATCHDOG:enabled\n");
151 return (0);
152}
153#endif /* #ifdef CONFIG_WATCHDOG */
154
155#endif /* #ifdef CONFIG_M5272 */
156
157
158#ifdef CONFIG_M5282
159int checkcpu (void)
160{
Marian Balakowiczecb6d0b2006-05-09 11:45:31 +0200161 puts ("CPU: Freescale Coldfire MCF5282\n");
wdenke65527f2004-02-12 00:47:09 +0000162 return 0;
163}
164
165int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
166 return 0;
167};
168#endif
stroese53395a22004-12-16 18:09:49 +0000169
170#ifdef CONFIG_M5249 /* test-only: todo... */
171int checkcpu (void)
172{
173 char buf[32];
174
Marian Balakowiczecb6d0b2006-05-09 11:45:31 +0200175 printf ("CPU: Freescale Coldfire MCF5249 at %s MHz\n", strmhz(buf, CFG_CLK));
stroese53395a22004-12-16 18:09:49 +0000176 return 0;
177}
178
179int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) {
180 /* enable watchdog, set timeout to 0 and wait */
181 mbar_writeByte(MCFSIM_SYPCR, 0xc0);
182 while (1);
183
184 /* we don't return! */
185 return 0;
186};
187#endif