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