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