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