wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 2 | * Copyright 2004,2007-2010 Freescale Semiconductor, Inc. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 3 | * (C) Copyright 2002, 2003 Motorola Inc. |
| 4 | * Xianghua Xiao (X.Xiao@motorola.com) |
| 5 | * |
| 6 | * (C) Copyright 2000 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 28 | #include <config.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 29 | #include <common.h> |
| 30 | #include <watchdog.h> |
| 31 | #include <command.h> |
Andy Fleming | 6843a6e | 2008-10-30 16:51:33 -0500 | [diff] [blame] | 32 | #include <fsl_esdhc.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 33 | #include <asm/cache.h> |
Sergei Poselenov | ddc1a47 | 2008-06-06 15:42:40 +0200 | [diff] [blame] | 34 | #include <asm/io.h> |
Becky Bruce | ee888da | 2010-06-17 11:37:25 -0500 | [diff] [blame] | 35 | #include <asm/mmu.h> |
| 36 | #include <asm/fsl_law.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 37 | |
James Yang | 957b191 | 2008-02-08 16:44:53 -0600 | [diff] [blame] | 38 | DECLARE_GLOBAL_DATA_PTR; |
| 39 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 40 | int checkcpu (void) |
| 41 | { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 42 | sys_info_t sysinfo; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 43 | uint pvr, svr; |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 44 | uint fam; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 45 | uint ver; |
| 46 | uint major, minor; |
Kumar Gala | 8ddf00c | 2008-06-10 16:53:46 -0500 | [diff] [blame] | 47 | struct cpu_type *cpu; |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 48 | char buf1[32], buf2[32]; |
Kumar Gala | 1d39c9a | 2010-04-13 11:07:57 -0500 | [diff] [blame] | 49 | #if defined(CONFIG_DDR_CLK_FREQ) || defined(CONFIG_FSL_CORENET) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 1d39c9a | 2010-04-13 11:07:57 -0500 | [diff] [blame] | 51 | #endif /* CONFIG_FSL_CORENET */ |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 52 | #ifdef CONFIG_DDR_CLK_FREQ |
Jason Jin | bfcd6c3 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 53 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 54 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 55 | #else |
| 56 | #ifdef CONFIG_FSL_CORENET |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 57 | u32 ddr_sync = ((gur->rcwsr[5]) & FSL_CORENET_RCWSR5_DDR_SYNC) |
| 58 | >> FSL_CORENET_RCWSR5_DDR_SYNC_SHIFT; |
Kumar Gala | 54b6810 | 2008-05-29 01:21:24 -0500 | [diff] [blame] | 59 | #else |
| 60 | u32 ddr_ratio = 0; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 61 | #endif /* CONFIG_FSL_CORENET */ |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 62 | #endif /* CONFIG_DDR_CLK_FREQ */ |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 63 | int i; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 64 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 65 | svr = get_svr(); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 66 | major = SVR_MAJ(svr); |
Kumar Gala | cd77728 | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 67 | #ifdef CONFIG_MPC8536 |
| 68 | major &= 0x7; /* the msb of this nibble is a mfg code */ |
| 69 | #endif |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 70 | minor = SVR_MIN(svr); |
| 71 | |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 72 | if (cpu_numcores() > 1) { |
Poonam Aggrwal | 36a6843 | 2009-09-03 19:42:40 +0530 | [diff] [blame] | 73 | #ifndef CONFIG_MP |
| 74 | puts("Unicore software on multiprocessor system!!\n" |
| 75 | "To enable mutlticore build define CONFIG_MP\n"); |
| 76 | #endif |
Kim Phillips | 2ecbfeb | 2010-08-09 18:39:57 -0500 | [diff] [blame] | 77 | volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR); |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 78 | printf("CPU%d: ", pic->whoami); |
| 79 | } else { |
| 80 | puts("CPU: "); |
| 81 | } |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 82 | |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 83 | cpu = gd->cpu; |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 84 | |
Poonam Aggrwal | da6e1ca | 2009-09-02 13:35:21 +0530 | [diff] [blame] | 85 | puts(cpu->name); |
| 86 | if (IS_E_PROCESSOR(svr)) |
| 87 | puts("E"); |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 88 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 89 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 90 | |
wdenk | 3f3262b | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 91 | pvr = get_pvr(); |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 92 | fam = PVR_FAM(pvr); |
wdenk | 3f3262b | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 93 | ver = PVR_VER(pvr); |
| 94 | major = PVR_MAJ(pvr); |
| 95 | minor = PVR_MIN(pvr); |
| 96 | |
| 97 | printf("Core: "); |
Kumar Gala | bd2985c | 2009-10-21 13:23:54 -0500 | [diff] [blame] | 98 | if (PVR_FAM(PVR_85xx)) { |
| 99 | switch(PVR_MEM(pvr)) { |
| 100 | case 0x1: |
| 101 | case 0x2: |
| 102 | puts("E500"); |
| 103 | break; |
| 104 | case 0x3: |
| 105 | puts("E500MC"); |
| 106 | break; |
| 107 | case 0x4: |
| 108 | puts("E5500"); |
| 109 | break; |
| 110 | default: |
| 111 | puts("Unknown"); |
| 112 | break; |
| 113 | } |
| 114 | } else { |
| 115 | puts("Unknown"); |
wdenk | 3f3262b | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 116 | } |
Kumar Gala | 9f4a689 | 2008-10-23 01:47:38 -0500 | [diff] [blame] | 117 | |
wdenk | 3f3262b | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 118 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
| 119 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 120 | get_sys_info(&sysinfo); |
| 121 | |
Kumar Gala | f92794c | 2009-02-04 09:35:57 -0600 | [diff] [blame] | 122 | puts("Clock Configuration:"); |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 123 | for (i = 0; i < cpu_numcores(); i++) { |
Wolfgang Denk | 1f79d14 | 2009-02-19 00:41:08 +0100 | [diff] [blame] | 124 | if (!(i & 3)) |
| 125 | printf ("\n "); |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 126 | printf("CPU%d:%-4s MHz, ", |
| 127 | i,strmhz(buf1, sysinfo.freqProcessor[i])); |
Kumar Gala | f92794c | 2009-02-04 09:35:57 -0600 | [diff] [blame] | 128 | } |
| 129 | printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus)); |
Kumar Gala | 54b6810 | 2008-05-29 01:21:24 -0500 | [diff] [blame] | 130 | |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 131 | #ifdef CONFIG_FSL_CORENET |
| 132 | if (ddr_sync == 1) { |
| 133 | printf(" DDR:%-4s MHz (%s MT/s data rate) " |
| 134 | "(Synchronous), ", |
| 135 | strmhz(buf1, sysinfo.freqDDRBus/2), |
| 136 | strmhz(buf2, sysinfo.freqDDRBus)); |
| 137 | } else { |
| 138 | printf(" DDR:%-4s MHz (%s MT/s data rate) " |
| 139 | "(Asynchronous), ", |
| 140 | strmhz(buf1, sysinfo.freqDDRBus/2), |
| 141 | strmhz(buf2, sysinfo.freqDDRBus)); |
| 142 | } |
| 143 | #else |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 144 | switch (ddr_ratio) { |
| 145 | case 0x0: |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 146 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
| 147 | strmhz(buf1, sysinfo.freqDDRBus/2), |
| 148 | strmhz(buf2, sysinfo.freqDDRBus)); |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 149 | break; |
| 150 | case 0x7: |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 151 | printf(" DDR:%-4s MHz (%s MT/s data rate) " |
| 152 | "(Synchronous), ", |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 153 | strmhz(buf1, sysinfo.freqDDRBus/2), |
| 154 | strmhz(buf2, sysinfo.freqDDRBus)); |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 155 | break; |
| 156 | default: |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 157 | printf(" DDR:%-4s MHz (%s MT/s data rate) " |
| 158 | "(Asynchronous), ", |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 159 | strmhz(buf1, sysinfo.freqDDRBus/2), |
| 160 | strmhz(buf2, sysinfo.freqDDRBus)); |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 161 | break; |
| 162 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 163 | #endif |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 164 | |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 165 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) { |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 166 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 167 | } else { |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 168 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
| 169 | sysinfo.freqLocalBus); |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 170 | } |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 171 | |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 172 | #ifdef CONFIG_CPM2 |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 173 | printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 174 | #endif |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 175 | |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 176 | #ifdef CONFIG_QE |
| 177 | printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE)); |
| 178 | #endif |
| 179 | |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 180 | #ifdef CONFIG_SYS_DPAA_FMAN |
| 181 | for (i = 0; i < CONFIG_SYS_NUM_FMAN; i++) { |
Emil Medve | 3a9ed2f | 2010-06-17 00:08:29 -0500 | [diff] [blame] | 182 | printf(" FMAN%d: %s MHz\n", i + 1, |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 183 | strmhz(buf1, sysinfo.freqFMan[i])); |
| 184 | } |
| 185 | #endif |
| 186 | |
| 187 | #ifdef CONFIG_SYS_DPAA_PME |
| 188 | printf(" PME: %s MHz\n", strmhz(buf1, sysinfo.freqPME)); |
| 189 | #endif |
| 190 | |
wdenk | 3f3262b | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 191 | puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n"); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | /* ------------------------------------------------------------------------- */ |
| 198 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 199 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char * const argv[]) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 200 | { |
Kumar Gala | aff0153 | 2009-09-08 13:46:46 -0500 | [diff] [blame] | 201 | /* Everything after the first generation of PQ3 parts has RSTCR */ |
| 202 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
| 203 | defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560) |
Sergei Poselenov | 2514742 | 2008-05-08 14:17:08 +0200 | [diff] [blame] | 204 | unsigned long val, msr; |
| 205 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 206 | /* |
| 207 | * Initiate hard reset in debug control register DBCR0 |
Kumar Gala | aff0153 | 2009-09-08 13:46:46 -0500 | [diff] [blame] | 208 | * Make sure MSR[DE] = 1. This only resets the core. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 209 | */ |
Sergei Poselenov | 2514742 | 2008-05-08 14:17:08 +0200 | [diff] [blame] | 210 | msr = mfmsr (); |
| 211 | msr |= MSR_DE; |
| 212 | mtmsr (msr); |
urwithsughosh@gmail.com | 06c2fb9 | 2007-09-24 13:32:13 -0400 | [diff] [blame] | 213 | |
Sergei Poselenov | 2514742 | 2008-05-08 14:17:08 +0200 | [diff] [blame] | 214 | val = mfspr(DBCR0); |
| 215 | val |= 0x70000000; |
| 216 | mtspr(DBCR0,val); |
Kumar Gala | aff0153 | 2009-09-08 13:46:46 -0500 | [diff] [blame] | 217 | #else |
| 218 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 219 | out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */ |
| 220 | udelay(100); |
| 221 | #endif |
Sergei Poselenov | 2514742 | 2008-05-08 14:17:08 +0200 | [diff] [blame] | 222 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 223 | return 1; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | /* |
| 228 | * Get timebase clock frequency |
| 229 | */ |
| 230 | unsigned long get_tbclk (void) |
| 231 | { |
Kumar Gala | 24f86a8 | 2009-09-17 01:52:37 -0500 | [diff] [blame] | 232 | #ifdef CONFIG_FSL_CORENET |
| 233 | return (gd->bus_clk + 8) / 16; |
| 234 | #else |
James Yang | 957b191 | 2008-02-08 16:44:53 -0600 | [diff] [blame] | 235 | return (gd->bus_clk + 4UL)/8UL; |
Kumar Gala | 24f86a8 | 2009-09-17 01:52:37 -0500 | [diff] [blame] | 236 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | |
| 240 | #if defined(CONFIG_WATCHDOG) |
| 241 | void |
| 242 | watchdog_reset(void) |
| 243 | { |
| 244 | int re_enable = disable_interrupts(); |
| 245 | reset_85xx_watchdog(); |
| 246 | if (re_enable) enable_interrupts(); |
| 247 | } |
| 248 | |
| 249 | void |
| 250 | reset_85xx_watchdog(void) |
| 251 | { |
| 252 | /* |
| 253 | * Clear TSR(WIS) bit by writing 1 |
| 254 | */ |
| 255 | unsigned long val; |
Andy Fleming | eac342d | 2007-04-23 01:44:44 -0500 | [diff] [blame] | 256 | val = mfspr(SPRN_TSR); |
| 257 | val |= TSR_WIS; |
| 258 | mtspr(SPRN_TSR, val); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 259 | } |
| 260 | #endif /* CONFIG_WATCHDOG */ |
| 261 | |
Sergei Poselenov | ddc1a47 | 2008-06-06 15:42:40 +0200 | [diff] [blame] | 262 | /* |
Andy Fleming | 6843a6e | 2008-10-30 16:51:33 -0500 | [diff] [blame] | 263 | * Initializes on-chip MMC controllers. |
| 264 | * to override, implement board_mmc_init() |
| 265 | */ |
| 266 | int cpu_mmc_init(bd_t *bis) |
| 267 | { |
| 268 | #ifdef CONFIG_FSL_ESDHC |
| 269 | return fsl_esdhc_mmc_init(bis); |
| 270 | #else |
| 271 | return 0; |
| 272 | #endif |
| 273 | } |
Becky Bruce | ee888da | 2010-06-17 11:37:25 -0500 | [diff] [blame] | 274 | |
| 275 | /* |
| 276 | * Print out the state of various machine registers. |
| 277 | * Currently prints out LAWs, BR0/OR0, and TLBs |
| 278 | */ |
| 279 | void mpc85xx_reginfo(void) |
| 280 | { |
| 281 | print_tlbcam(); |
| 282 | print_laws(); |
| 283 | print_lbc_regs(); |
| 284 | } |