3 * Josef Baumgartner <josef.baumgartner@telex.de>
7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/immap.h>
35 * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to
36 * determine which one we are running on, based on the Chip Identification
42 unsigned short cir; /* Chip Identification Register */
43 unsigned short pin; /* Part identification number */
44 unsigned char prn; /* Part revision number */
47 cir = mbar_readShort(MCF_CCM_CIR);
48 pin = cir >> MCF_CCM_CIR_PIN_LEN;
49 prn = cir & MCF_CCM_CIR_PRN_MASK;
52 case MCF_CCM_CIR_PIN_MCF5270:
55 case MCF_CCM_CIR_PIN_MCF5271:
64 printf("CPU: Freescale ColdFire MCF%s rev. %hu, at %s MHz\n",
65 cpu_model, prn, strmhz(buf, CFG_CLK));
67 printf("CPU: Unknown - Freescale ColdFire MCF5271 family"
68 " (PIN: 0x%x) rev. %hu, at %s MHz\n",
69 pin, prn, strmhz(buf, CFG_CLK));
74 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
76 mbar_writeByte(MCF_RCM_RCR,
77 MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT);
81 #if defined(CONFIG_WATCHDOG)
82 void watchdog_reset(void)
84 mbar_writeShort(MCF_WTM_WSR, 0x5555);
85 mbar_writeShort(MCF_WTM_WSR, 0xAAAA);
88 int watchdog_disable(void)
90 mbar_writeShort(MCF_WTM_WCR, 0);
94 int watchdog_init(void)
96 mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN);
99 #endif /* #ifdef CONFIG_WATCHDOG */
104 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
106 volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
111 /* enable watchdog, set timeout to 0 and wait */
115 /* we don't return! */
121 volatile sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG);
126 msk = (sysctrl->sc_dir > 28) & 0xf;
136 printf("Freescale MCF5272 (Mask:%01x)\n", msk);
141 printf("Freescale MCF5272 %s\n", suf);
145 #if defined(CONFIG_WATCHDOG)
146 /* Called by macro WATCHDOG_RESET */
147 void watchdog_reset(void)
149 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
153 int watchdog_disable(void)
155 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
157 wdt->wdog_wcr = 0; /* reset watchdog counter */
158 wdt->wdog_wirr = 0; /* disable watchdog interrupt */
159 wdt->wdog_wrrr = 0; /* disable watchdog timer */
161 puts("WATCHDOG:disabled\n");
165 int watchdog_init(void)
167 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG);
169 wdt->wdog_wirr = 0; /* disable watchdog interrupt */
171 /* set timeout and enable watchdog */
173 ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1;
174 wdt->wdog_wcr = 0; /* reset watchdog counter */
176 puts("WATCHDOG:enabled\n");
179 #endif /* #ifdef CONFIG_WATCHDOG */
181 #endif /* #ifdef CONFIG_M5272 */
186 unsigned char resetsource = MCFRESET_RSR;
188 printf("CPU: Freescale Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n",
189 MCFCCM_CIR >> 8, MCFCCM_CIR & MCFCCM_CIR_PRN_MASK);
190 printf("Reset:%s%s%s%s%s%s%s\n",
191 (resetsource & MCFRESET_RSR_LOL) ? " Loss of Lock" : "",
192 (resetsource & MCFRESET_RSR_LOC) ? " Loss of Clock" : "",
193 (resetsource & MCFRESET_RSR_EXT) ? " External" : "",
194 (resetsource & MCFRESET_RSR_POR) ? " Power On" : "",
195 (resetsource & MCFRESET_RSR_WDR) ? " Watchdog" : "",
196 (resetsource & MCFRESET_RSR_SOFT) ? " Software" : "",
197 (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : "");
201 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
203 MCFRESET_RCR = MCFRESET_RCR_SOFTRST;
213 printf("CPU: Freescale Coldfire MCF5249 at %s MHz\n",
214 strmhz(buf, CFG_CLK));
218 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
220 /* enable watchdog, set timeout to 0 and wait */
221 mbar_writeByte(MCFSIM_SYPCR, 0xc0);
224 /* we don't return! */
234 unsigned char resetsource = mbar_readLong(SIM_RSR);
235 printf("CPU: Freescale Coldfire MCF5253 at %s MHz\n",
236 strmhz(buf, CFG_CLK));
238 if ((resetsource & SIM_RSR_HRST) || (resetsource & SIM_RSR_SWTR)) {
239 printf("Reset:%s%s\n",
240 (resetsource & SIM_RSR_HRST) ? " Hardware/ System Reset"
242 (resetsource & SIM_RSR_SWTR) ? " Software Watchdog" :
248 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
250 /* enable watchdog, set timeout to 0 and wait */
251 mbar_writeByte(SIM_SYPCR, 0xc0);
254 /* we don't return! */