wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
| 4 | * |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 5 | * MCF5282 additionals |
| 6 | * (C) Copyright 2005 |
| 7 | * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de> |
| 8 | * |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 9 | * MCF5275 additions |
| 10 | * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com) |
| 11 | * |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 12 | * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved. |
| 13 | * |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 14 | * See file CREDITS for list of people who contributed to this |
| 15 | * project. |
| 16 | * |
| 17 | * This program is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU General Public License as |
| 19 | * published by the Free Software Foundation; either version 2 of |
| 20 | * the License, or (at your option) any later version. |
| 21 | * |
| 22 | * This program is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | * GNU General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU General Public License |
| 28 | * along with this program; if not, write to the Free Software |
| 29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 30 | * MA 02111-1307 USA |
| 31 | */ |
| 32 | |
| 33 | #include <common.h> |
| 34 | #include <watchdog.h> |
| 35 | #include <command.h> |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 36 | #include <asm/immap.h> |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 37 | #include <asm/io.h> |
Ben Warren | 89973f8 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 38 | #include <netdev.h> |
Richard Retanubun | bb907ab | 2009-10-26 14:19:17 -0400 | [diff] [blame] | 39 | #include "cpu.h" |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 40 | |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | |
| 43 | #ifdef CONFIG_M5208 |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 44 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 45 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 46 | rcm_t *rcm = (rcm_t *)(MMAP_RCM); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 47 | |
| 48 | udelay(1000); |
| 49 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 50 | out_8(&rcm->rcr, RCM_RCR_SOFTRST); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 51 | |
| 52 | /* we don't return! */ |
| 53 | return 0; |
| 54 | }; |
| 55 | |
| 56 | int checkcpu(void) |
| 57 | { |
| 58 | char buf1[32], buf2[32]; |
| 59 | |
| 60 | printf("CPU: Freescale Coldfire MCF5208\n" |
| 61 | " CPU CLK %s MHz BUS CLK %s MHz\n", |
| 62 | strmhz(buf1, gd->cpu_clk), |
| 63 | strmhz(buf2, gd->bus_clk)); |
| 64 | return 0; |
| 65 | }; |
| 66 | |
| 67 | #if defined(CONFIG_WATCHDOG) |
| 68 | /* Called by macro WATCHDOG_RESET */ |
| 69 | void watchdog_reset(void) |
| 70 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 71 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
| 72 | |
| 73 | out_be16(&wdt->sr, 0x5555); |
| 74 | out_be16(&wdt->sr, 0xaaaa); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | int watchdog_disable(void) |
| 78 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 79 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 80 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 81 | /* reset watchdog counter */ |
| 82 | out_be16(&wdt->sr, 0x5555); |
| 83 | out_be16(&wdt->sr, 0xaaaa); |
| 84 | /* disable watchdog timer */ |
| 85 | out_be16(&wdt->cr, 0); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 86 | |
| 87 | puts("WATCHDOG:disabled\n"); |
| 88 | return (0); |
| 89 | } |
| 90 | |
| 91 | int watchdog_init(void) |
| 92 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 93 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 94 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 95 | /* disable watchdog */ |
| 96 | out_be16(&wdt->cr, 0); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 97 | |
| 98 | /* set timeout and enable watchdog */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 99 | out_be16(&wdt->mr, |
| 100 | (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1); |
| 101 | |
| 102 | /* reset watchdog counter */ |
| 103 | out_be16(&wdt->sr, 0x5555); |
| 104 | out_be16(&wdt->sr, 0xaaaa); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 105 | |
| 106 | puts("WATCHDOG:enabled\n"); |
| 107 | return (0); |
| 108 | } |
| 109 | #endif /* #ifdef CONFIG_WATCHDOG */ |
| 110 | #endif /* #ifdef CONFIG_M5208 */ |
| 111 | |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 112 | #ifdef CONFIG_M5271 |
Bartlomiej Sieka | 363d1d8 | 2007-01-23 13:25:22 +0100 | [diff] [blame] | 113 | /* |
| 114 | * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to |
| 115 | * determine which one we are running on, based on the Chip Identification |
| 116 | * Register (CIR). |
| 117 | */ |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 118 | int checkcpu(void) |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 119 | { |
Marian Balakowicz | b75ef85 | 2006-05-09 11:45:31 +0200 | [diff] [blame] | 120 | char buf[32]; |
Bartlomiej Sieka | 363d1d8 | 2007-01-23 13:25:22 +0100 | [diff] [blame] | 121 | unsigned short cir; /* Chip Identification Register */ |
| 122 | unsigned short pin; /* Part identification number */ |
| 123 | unsigned char prn; /* Part revision number */ |
| 124 | char *cpu_model; |
Marian Balakowicz | b75ef85 | 2006-05-09 11:45:31 +0200 | [diff] [blame] | 125 | |
Bartlomiej Sieka | 363d1d8 | 2007-01-23 13:25:22 +0100 | [diff] [blame] | 126 | cir = mbar_readShort(MCF_CCM_CIR); |
| 127 | pin = cir >> MCF_CCM_CIR_PIN_LEN; |
| 128 | prn = cir & MCF_CCM_CIR_PRN_MASK; |
| 129 | |
| 130 | switch (pin) { |
| 131 | case MCF_CCM_CIR_PIN_MCF5270: |
| 132 | cpu_model = "5270"; |
| 133 | break; |
| 134 | case MCF_CCM_CIR_PIN_MCF5271: |
| 135 | cpu_model = "5271"; |
| 136 | break; |
| 137 | default: |
| 138 | cpu_model = NULL; |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | if (cpu_model) |
| 143 | printf("CPU: Freescale ColdFire MCF%s rev. %hu, at %s MHz\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 144 | cpu_model, prn, strmhz(buf, CONFIG_SYS_CLK)); |
Bartlomiej Sieka | 363d1d8 | 2007-01-23 13:25:22 +0100 | [diff] [blame] | 145 | else |
| 146 | printf("CPU: Unknown - Freescale ColdFire MCF5271 family" |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 147 | " (PIN: 0x%x) rev. %hu, at %s MHz\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 148 | pin, prn, strmhz(buf, CONFIG_SYS_CLK)); |
Bartlomiej Sieka | 363d1d8 | 2007-01-23 13:25:22 +0100 | [diff] [blame] | 149 | |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 150 | return 0; |
| 151 | } |
| 152 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 153 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 154 | { |
Richard Retanubun | bb907ab | 2009-10-26 14:19:17 -0400 | [diff] [blame] | 155 | /* Call the board specific reset actions first. */ |
| 156 | if(board_reset) { |
| 157 | board_reset(); |
| 158 | } |
| 159 | |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 160 | mbar_writeByte(MCF_RCM_RCR, |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 161 | MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT); |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 162 | return 0; |
| 163 | }; |
| 164 | |
| 165 | #if defined(CONFIG_WATCHDOG) |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 166 | void watchdog_reset(void) |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 167 | { |
| 168 | mbar_writeShort(MCF_WTM_WSR, 0x5555); |
| 169 | mbar_writeShort(MCF_WTM_WSR, 0xAAAA); |
| 170 | } |
| 171 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 172 | int watchdog_disable(void) |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 173 | { |
| 174 | mbar_writeShort(MCF_WTM_WCR, 0); |
| 175 | return (0); |
| 176 | } |
| 177 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 178 | int watchdog_init(void) |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 179 | { |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 180 | mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN); |
| 181 | return (0); |
| 182 | } |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 183 | #endif /* #ifdef CONFIG_WATCHDOG */ |
Zachary P. Landau | eacbd31 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 184 | |
| 185 | #endif |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 186 | |
| 187 | #ifdef CONFIG_M5272 |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 188 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 189 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 190 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 191 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 192 | out_be16(&wdp->wdog_wrrr, 0); |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 193 | udelay(1000); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 194 | |
| 195 | /* enable watchdog, set timeout to 0 and wait */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 196 | out_be16(&wdp->wdog_wrrr, 1); |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 197 | while (1) ; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 198 | |
| 199 | /* we don't return! */ |
| 200 | return 0; |
| 201 | }; |
| 202 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 203 | int checkcpu(void) |
| 204 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 205 | sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 206 | uchar msk; |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 207 | char *suf; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 208 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 209 | puts("CPU: "); |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 210 | msk = (in_be32(&sysctrl->sc_dir) > 28) & 0xf; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 211 | switch (msk) { |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 212 | case 0x2: |
| 213 | suf = "1K75N"; |
| 214 | break; |
| 215 | case 0x4: |
| 216 | suf = "3K75N"; |
| 217 | break; |
| 218 | default: |
| 219 | suf = NULL; |
| 220 | printf("Freescale MCF5272 (Mask:%01x)\n", msk); |
| 221 | break; |
| 222 | } |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 223 | |
| 224 | if (suf) |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 225 | printf("Freescale MCF5272 %s\n", suf); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 226 | return 0; |
| 227 | }; |
| 228 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 229 | #if defined(CONFIG_WATCHDOG) |
| 230 | /* Called by macro WATCHDOG_RESET */ |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 231 | void watchdog_reset(void) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 232 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 233 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
| 234 | |
| 235 | out_be16(&wdt->wdog_wcr, 0); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 236 | } |
| 237 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 238 | int watchdog_disable(void) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 239 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 240 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 241 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 242 | /* reset watchdog counter */ |
| 243 | out_be16(&wdt->wdog_wcr, 0); |
| 244 | /* disable watchdog interrupt */ |
| 245 | out_be16(&wdt->wdog_wirr, 0); |
| 246 | /* disable watchdog timer */ |
| 247 | out_be16(&wdt->wdog_wrrr, 0); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 248 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 249 | puts("WATCHDOG:disabled\n"); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 250 | return (0); |
| 251 | } |
| 252 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 253 | int watchdog_init(void) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 254 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 255 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 256 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 257 | /* disable watchdog interrupt */ |
| 258 | out_be16(&wdt->wdog_wirr, 0); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 259 | |
| 260 | /* set timeout and enable watchdog */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 261 | out_be16(&wdt->wdog_wrrr, |
| 262 | (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1); |
| 263 | |
| 264 | /* reset watchdog counter */ |
| 265 | out_be16(&wdt->wdog_wcr, 0); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 266 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 267 | puts("WATCHDOG:enabled\n"); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 268 | return (0); |
| 269 | } |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 270 | #endif /* #ifdef CONFIG_WATCHDOG */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 271 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 272 | #endif /* #ifdef CONFIG_M5272 */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 273 | |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 274 | #ifdef CONFIG_M5275 |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 275 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 276 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 277 | rcm_t *rcm = (rcm_t *)(MMAP_RCM); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 278 | |
| 279 | udelay(1000); |
| 280 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 281 | out_8(&rcm->rcr, RCM_RCR_SOFTRST); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 282 | |
| 283 | /* we don't return! */ |
| 284 | return 0; |
| 285 | }; |
| 286 | |
| 287 | int checkcpu(void) |
| 288 | { |
| 289 | char buf[32]; |
| 290 | |
| 291 | printf("CPU: Freescale Coldfire MCF5275 at %s MHz\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 292 | strmhz(buf, CONFIG_SYS_CLK)); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 293 | return 0; |
| 294 | }; |
| 295 | |
| 296 | |
| 297 | #if defined(CONFIG_WATCHDOG) |
| 298 | /* Called by macro WATCHDOG_RESET */ |
| 299 | void watchdog_reset(void) |
| 300 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 301 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
| 302 | |
| 303 | out_be16(&wdt->wsr, 0x5555); |
| 304 | out_be16(&wdt->wsr, 0xaaaa); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | int watchdog_disable(void) |
| 308 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 309 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 310 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 311 | /* reset watchdog counter */ |
| 312 | out_be16(&wdt->wsr, 0x5555); |
| 313 | out_be16(&wdt->wsr, 0xaaaa); |
| 314 | |
| 315 | /* disable watchdog timer */ |
| 316 | out_be16(&wdt->wcr, 0); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 317 | |
| 318 | puts("WATCHDOG:disabled\n"); |
| 319 | return (0); |
| 320 | } |
| 321 | |
| 322 | int watchdog_init(void) |
| 323 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 324 | wdog_t *wdt = (wdog_t *)(MMAP_WDOG); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 325 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 326 | /* disable watchdog */ |
| 327 | out_be16(&wdt->wcr, 0); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 328 | |
| 329 | /* set timeout and enable watchdog */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame^] | 330 | out_be16(&wdt->wmr, |
| 331 | (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1); |
| 332 | |
| 333 | /* reset watchdog counter */ |
| 334 | out_be16(&wdt->wsr, 0x5555); |
| 335 | out_be16(&wdt->wsr, 0xaaaa); |
Matthew Fettke | f71d9d9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 336 | |
| 337 | puts("WATCHDOG:enabled\n"); |
| 338 | return (0); |
| 339 | } |
| 340 | #endif /* #ifdef CONFIG_WATCHDOG */ |
| 341 | |
| 342 | #endif /* #ifdef CONFIG_M5275 */ |
| 343 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 344 | #ifdef CONFIG_M5282 |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 345 | int checkcpu(void) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 346 | { |
Wolfgang Denk | 4176c79 | 2006-06-10 19:27:47 +0200 | [diff] [blame] | 347 | unsigned char resetsource = MCFRESET_RSR; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 348 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 349 | printf("CPU: Freescale Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n", |
| 350 | MCFCCM_CIR >> 8, MCFCCM_CIR & MCFCCM_CIR_PRN_MASK); |
| 351 | printf("Reset:%s%s%s%s%s%s%s\n", |
| 352 | (resetsource & MCFRESET_RSR_LOL) ? " Loss of Lock" : "", |
| 353 | (resetsource & MCFRESET_RSR_LOC) ? " Loss of Clock" : "", |
| 354 | (resetsource & MCFRESET_RSR_EXT) ? " External" : "", |
| 355 | (resetsource & MCFRESET_RSR_POR) ? " Power On" : "", |
| 356 | (resetsource & MCFRESET_RSR_WDR) ? " Watchdog" : "", |
| 357 | (resetsource & MCFRESET_RSR_SOFT) ? " Software" : "", |
| 358 | (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : ""); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 359 | return 0; |
| 360 | } |
| 361 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 362 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 363 | { |
| 364 | MCFRESET_RCR = MCFRESET_RCR_SOFTRST; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 365 | return 0; |
| 366 | }; |
| 367 | #endif |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 368 | |
TsiChungLiew | a1436a8 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 369 | #ifdef CONFIG_M5249 |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 370 | int checkcpu(void) |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 371 | { |
| 372 | char buf[32]; |
| 373 | |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 374 | printf("CPU: Freescale Coldfire MCF5249 at %s MHz\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 375 | strmhz(buf, CONFIG_SYS_CLK)); |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 376 | return 0; |
| 377 | } |
| 378 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 379 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 380 | { |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 381 | /* enable watchdog, set timeout to 0 and wait */ |
| 382 | mbar_writeByte(MCFSIM_SYPCR, 0xc0); |
TsiChungLiew | 83ec20b | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 383 | while (1) ; |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 384 | |
| 385 | /* we don't return! */ |
| 386 | return 0; |
| 387 | }; |
| 388 | #endif |
TsiChungLiew | a1436a8 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 389 | |
| 390 | #ifdef CONFIG_M5253 |
| 391 | int checkcpu(void) |
| 392 | { |
| 393 | char buf[32]; |
| 394 | |
| 395 | unsigned char resetsource = mbar_readLong(SIM_RSR); |
| 396 | printf("CPU: Freescale Coldfire MCF5253 at %s MHz\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 397 | strmhz(buf, CONFIG_SYS_CLK)); |
TsiChungLiew | a1436a8 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 398 | |
| 399 | if ((resetsource & SIM_RSR_HRST) || (resetsource & SIM_RSR_SWTR)) { |
| 400 | printf("Reset:%s%s\n", |
| 401 | (resetsource & SIM_RSR_HRST) ? " Hardware/ System Reset" |
| 402 | : "", |
| 403 | (resetsource & SIM_RSR_SWTR) ? " Software Watchdog" : |
| 404 | ""); |
| 405 | } |
| 406 | return 0; |
| 407 | } |
| 408 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 409 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChungLiew | a1436a8 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 410 | { |
| 411 | /* enable watchdog, set timeout to 0 and wait */ |
| 412 | mbar_writeByte(SIM_SYPCR, 0xc0); |
| 413 | while (1) ; |
| 414 | |
| 415 | /* we don't return! */ |
| 416 | return 0; |
| 417 | }; |
| 418 | #endif |
Ben Warren | 86882b8 | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 419 | |
| 420 | #if defined(CONFIG_MCFFEC) |
| 421 | /* Default initializations for MCFFEC controllers. To override, |
| 422 | * create a board-specific function called: |
| 423 | * int board_eth_init(bd_t *bis) |
| 424 | */ |
| 425 | |
Ben Warren | 86882b8 | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 426 | int cpu_eth_init(bd_t *bis) |
| 427 | { |
| 428 | return mcffec_initialize(bis); |
| 429 | } |
| 430 | #endif |