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