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