Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 1 | /* |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 2 | * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * CPU specific code for the MPC83xx family. |
| 25 | * |
| 26 | * Derived from the MPC8260 and MPC85xx. |
| 27 | */ |
| 28 | |
| 29 | #include <common.h> |
| 30 | #include <watchdog.h> |
| 31 | #include <command.h> |
| 32 | #include <mpc83xx.h> |
| 33 | #include <asm/processor.h> |
Gerald Van Baren | d6abef4 | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 34 | #include <libfdt.h> |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 35 | #include <tsec.h> |
Ben Warren | 6773169 | 2008-10-22 23:32:48 -0700 | [diff] [blame] | 36 | #include <netdev.h> |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 37 | #include <fsl_esdhc.h> |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 38 | #ifdef CONFIG_BOOTCOUNT_LIMIT |
| 39 | #include <asm/immap_qe.h> |
| 40 | #include <asm/io.h> |
| 41 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 42 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 43 | DECLARE_GLOBAL_DATA_PTR; |
| 44 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 45 | int checkcpu(void) |
| 46 | { |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 47 | volatile immap_t *immr; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 48 | ulong clock = gd->cpu_clk; |
| 49 | u32 pvr = get_pvr(); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 50 | u32 spridr; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 51 | char buf[32]; |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 52 | int i; |
| 53 | |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 54 | const struct cpu_type { |
| 55 | char name[15]; |
| 56 | u32 partid; |
| 57 | } cpu_type_list [] = { |
Ilya Yanok | a3e5fd5 | 2010-06-28 16:44:33 +0400 | [diff] [blame] | 58 | CPU_TYPE_ENTRY(8308), |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 59 | CPU_TYPE_ENTRY(8309), |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 60 | CPU_TYPE_ENTRY(8311), |
| 61 | CPU_TYPE_ENTRY(8313), |
| 62 | CPU_TYPE_ENTRY(8314), |
| 63 | CPU_TYPE_ENTRY(8315), |
| 64 | CPU_TYPE_ENTRY(8321), |
| 65 | CPU_TYPE_ENTRY(8323), |
| 66 | CPU_TYPE_ENTRY(8343), |
| 67 | CPU_TYPE_ENTRY(8347_TBGA_), |
| 68 | CPU_TYPE_ENTRY(8347_PBGA_), |
| 69 | CPU_TYPE_ENTRY(8349), |
| 70 | CPU_TYPE_ENTRY(8358_TBGA_), |
| 71 | CPU_TYPE_ENTRY(8358_PBGA_), |
| 72 | CPU_TYPE_ENTRY(8360), |
| 73 | CPU_TYPE_ENTRY(8377), |
| 74 | CPU_TYPE_ENTRY(8378), |
| 75 | CPU_TYPE_ENTRY(8379), |
| 76 | }; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 77 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 78 | immr = (immap_t *)CONFIG_SYS_IMMR; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 79 | |
Kim Phillips | d82b077 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 80 | puts("CPU: "); |
Scott Wood | 7206a99 | 2007-04-16 14:34:16 -0500 | [diff] [blame] | 81 | |
| 82 | switch (pvr & 0xffff0000) { |
| 83 | case PVR_E300C1: |
| 84 | printf("e300c1, "); |
| 85 | break; |
| 86 | |
| 87 | case PVR_E300C2: |
| 88 | printf("e300c2, "); |
| 89 | break; |
| 90 | |
| 91 | case PVR_E300C3: |
| 92 | printf("e300c3, "); |
| 93 | break; |
| 94 | |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 95 | case PVR_E300C4: |
| 96 | printf("e300c4, "); |
| 97 | break; |
| 98 | |
Scott Wood | 7206a99 | 2007-04-16 14:34:16 -0500 | [diff] [blame] | 99 | default: |
| 100 | printf("Unknown core, "); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 101 | } |
| 102 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 103 | spridr = immr->sysconf.spridr; |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 104 | |
| 105 | for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++) |
| 106 | if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) { |
| 107 | puts("MPC"); |
| 108 | puts(cpu_type_list[i].name); |
| 109 | if (IS_E_PROCESSOR(spridr)) |
| 110 | puts("E"); |
Kim Phillips | 39b4816 | 2010-04-15 17:36:02 -0500 | [diff] [blame] | 111 | if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY || |
| 112 | SPR_FAMILY(spridr) == SPR_836X_FAMILY) && |
| 113 | REVID_MAJOR(spridr) >= 2) |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 114 | puts("A"); |
| 115 | printf(", Rev: %d.%d", REVID_MAJOR(spridr), |
| 116 | REVID_MINOR(spridr)); |
| 117 | break; |
| 118 | } |
| 119 | |
| 120 | if (i == ARRAY_SIZE(cpu_type_list)) |
| 121 | printf("(SPRIDR %08x unknown), ", spridr); |
| 122 | |
| 123 | printf(" at %s MHz, ", strmhz(buf, clock)); |
Rafal Jaworowski | 384da5e | 2005-10-17 02:39:53 +0200 | [diff] [blame] | 124 | |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame^] | 125 | printf("CSB: %s MHz\n", strmhz(buf, gd->arch.csb_clk)); |
Kim Phillips | d82b077 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 126 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 127 | return 0; |
| 128 | } |
| 129 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 130 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 131 | do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 132 | { |
Wolfgang Denk | 301d096 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 133 | ulong msr; |
| 134 | #ifndef MPC83xx_RESET |
| 135 | ulong addr; |
| 136 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 137 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 138 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 139 | |
Michael Zaidman | 184154b | 2010-02-15 10:02:32 +0200 | [diff] [blame] | 140 | puts("Resetting the board.\n"); |
| 141 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 142 | #ifdef MPC83xx_RESET |
Michael Zaidman | 184154b | 2010-02-15 10:02:32 +0200 | [diff] [blame] | 143 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 144 | /* Interrupts and MMU off */ |
| 145 | __asm__ __volatile__ ("mfmsr %0":"=r" (msr):); |
| 146 | |
| 147 | msr &= ~( MSR_EE | MSR_IR | MSR_DR); |
| 148 | __asm__ __volatile__ ("mtmsr %0"::"r" (msr)); |
| 149 | |
| 150 | /* enable Reset Control Reg */ |
| 151 | immap->reset.rpr = 0x52535445; |
Marian Balakowicz | 919b187 | 2006-03-14 16:12:48 +0100 | [diff] [blame] | 152 | __asm__ __volatile__ ("sync"); |
| 153 | __asm__ __volatile__ ("isync"); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 154 | |
| 155 | /* confirm Reset Control Reg is enabled */ |
| 156 | while(!((immap->reset.rcer) & RCER_CRE)); |
| 157 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 158 | udelay(200); |
| 159 | |
| 160 | /* perform reset, only one bit */ |
Wolfgang Denk | 301d096 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 161 | immap->reset.rcr = RCR_SWHR; |
| 162 | |
| 163 | #else /* ! MPC83xx_RESET */ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 164 | |
Wolfgang Denk | 301d096 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 165 | immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */ |
| 166 | |
| 167 | /* Interrupts and MMU off */ |
| 168 | __asm__ __volatile__ ("mfmsr %0":"=r" (msr):); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 169 | |
| 170 | msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR); |
| 171 | __asm__ __volatile__ ("mtmsr %0"::"r" (msr)); |
| 172 | |
| 173 | /* |
| 174 | * Trying to execute the next instruction at a non-existing address |
| 175 | * should cause a machine check, resulting in reset |
| 176 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 177 | addr = CONFIG_SYS_RESET_ADDRESS; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 178 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 179 | ((void (*)(void)) addr) (); |
Wolfgang Denk | 301d096 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 180 | #endif /* MPC83xx_RESET */ |
| 181 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 182 | return 1; |
| 183 | } |
| 184 | |
| 185 | |
| 186 | /* |
| 187 | * Get timebase clock frequency (like cpu_clk in Hz) |
| 188 | */ |
| 189 | |
| 190 | unsigned long get_tbclk(void) |
| 191 | { |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 192 | ulong tbclk; |
| 193 | |
| 194 | tbclk = (gd->bus_clk + 3L) / 4L; |
| 195 | |
| 196 | return tbclk; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | #if defined(CONFIG_WATCHDOG) |
| 201 | void watchdog_reset (void) |
| 202 | { |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 203 | int re_enable = disable_interrupts(); |
| 204 | |
| 205 | /* Reset the 83xx watchdog */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 206 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 207 | immr->wdt.swsrr = 0x556c; |
| 208 | immr->wdt.swsrr = 0xaa39; |
| 209 | |
| 210 | if (re_enable) |
| 211 | enable_interrupts (); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 212 | } |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 213 | #endif |
Kumar Gala | 5bbb045 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 214 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 215 | /* |
| 216 | * Initializes on-chip ethernet controllers. |
| 217 | * to override, implement board_eth_init() |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 218 | */ |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 219 | int cpu_eth_init(bd_t *bis) |
| 220 | { |
Haiying Wang | 511d828 | 2009-06-04 16:12:41 -0400 | [diff] [blame] | 221 | #if defined(CONFIG_UEC_ETH) |
| 222 | uec_standard_init(bis); |
Ben Warren | 6773169 | 2008-10-22 23:32:48 -0700 | [diff] [blame] | 223 | #endif |
Haiying Wang | 511d828 | 2009-06-04 16:12:41 -0400 | [diff] [blame] | 224 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 225 | #if defined(CONFIG_TSEC_ENET) |
| 226 | tsec_standard_init(bis); |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 227 | #endif |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 228 | return 0; |
| 229 | } |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 230 | |
| 231 | /* |
| 232 | * Initializes on-chip MMC controllers. |
| 233 | * to override, implement board_mmc_init() |
| 234 | */ |
| 235 | int cpu_mmc_init(bd_t *bis) |
| 236 | { |
| 237 | #ifdef CONFIG_FSL_ESDHC |
| 238 | return fsl_esdhc_mmc_init(bis); |
| 239 | #else |
| 240 | return 0; |
| 241 | #endif |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 242 | } |