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