Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1 | /* |
Poonam Aggrwal | 18bacc2 | 2009-07-31 12:07:45 +0530 | [diff] [blame] | 2 | * Copyright 2006,2009 Freescale Semiconductor, Inc. |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 3 | * Jeff Brown |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 4 | * Srikanth Srinivasan (srikanth.srinivasan@freescale.com) |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <watchdog.h> |
| 27 | #include <command.h> |
| 28 | #include <asm/cache.h> |
Becky Bruce | e34a0e9 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 29 | #include <asm/mmu.h> |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 30 | #include <mpc86xx.h> |
Becky Bruce | 4f93f8b | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 31 | #include <asm/fsl_law.h> |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 32 | |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 35 | /* |
| 36 | * Default board reset function |
| 37 | */ |
| 38 | static void |
| 39 | __board_reset(void) |
| 40 | { |
| 41 | /* Do nothing */ |
| 42 | } |
Peter Tyser | f9a109b | 2009-04-20 11:08:46 -0500 | [diff] [blame] | 43 | void board_reset(void) __attribute__((weak, alias("__board_reset"))); |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 44 | |
| 45 | |
Jon Loeliger | ffff3ae | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 46 | int |
| 47 | checkcpu(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 48 | { |
| 49 | sys_info_t sysinfo; |
| 50 | uint pvr, svr; |
| 51 | uint ver; |
| 52 | uint major, minor; |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 53 | char buf1[32], buf2[32]; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 54 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 9553df8 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 55 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Kumar Gala | 480f617 | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 56 | struct cpu_type *cpu; |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 57 | uint msscr0 = mfspr(MSSCR0); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 58 | |
| 59 | svr = get_svr(); |
Andy Fleming | 1ced121 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 60 | ver = SVR_SOC_VER(svr); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 61 | major = SVR_MAJ(svr); |
| 62 | minor = SVR_MIN(svr); |
| 63 | |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 64 | puts("CPU: "); |
| 65 | |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 66 | cpu = gd->cpu; |
| 67 | |
Poonam Aggrwal | 58442dc | 2009-09-02 13:35:21 +0530 | [diff] [blame^] | 68 | puts(cpu->name); |
Kumar Gala | 480f617 | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 69 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 70 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 71 | puts("Core: "); |
| 72 | |
| 73 | pvr = get_pvr(); |
| 74 | ver = PVR_E600_VER(pvr); |
| 75 | major = PVR_E600_MAJ(pvr); |
| 76 | minor = PVR_E600_MIN(pvr); |
| 77 | |
| 78 | printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); |
| 79 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) |
| 80 | puts("\n Core1Translation Enabled"); |
| 81 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); |
| 82 | |
| 83 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 84 | |
| 85 | get_sys_info(&sysinfo); |
| 86 | |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 87 | puts("Clock Configuration:\n"); |
| 88 | printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); |
| 89 | printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); |
| 90 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
| 91 | strmhz(buf1, sysinfo.freqSystemBus / 2), |
| 92 | strmhz(buf2, sysinfo.freqSystemBus)); |
Jon Loeliger | 5c9efb3 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 93 | |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 94 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) { |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 95 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 96 | } else { |
Wolfgang Denk | a9f3acb | 2009-01-12 14:50:35 +0100 | [diff] [blame] | 97 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 98 | sysinfo.freqLocalBus); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 99 | } |
| 100 | |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 101 | puts("L1: D-cache 32 KB enabled\n"); |
| 102 | puts(" I-cache 32 KB enabled\n"); |
| 103 | |
| 104 | puts("L2: "); |
| 105 | if (get_l2cr() & 0x80000000) { |
| 106 | #if defined(CONFIG_MPC8610) |
| 107 | puts("256"); |
| 108 | #elif defined(CONFIG_MPC8641) |
| 109 | puts("512"); |
| 110 | #endif |
| 111 | puts(" KB enabled\n"); |
| 112 | } else { |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 113 | puts("Disabled\n"); |
Peter Tyser | a1c8a71 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 114 | } |
Jon Loeliger | 5c9efb3 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 115 | |
| 116 | return 0; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 120 | void |
Jon Loeliger | 126aa70 | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 121 | do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 122 | { |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 123 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
| 124 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 125 | |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 126 | /* Attempt board-specific reset */ |
| 127 | board_reset(); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 128 | |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 129 | /* Next try asserting HRESET_REQ */ |
| 130 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 131 | |
Peter Tyser | 4ef630d | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 132 | while (1) |
| 133 | ; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 137 | /* |
| 138 | * Get timebase clock frequency |
| 139 | */ |
Jon Loeliger | ffff3ae | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 140 | unsigned long |
| 141 | get_tbclk(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 142 | { |
Jon Loeliger | ffff3ae | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 143 | sys_info_t sys_info; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 144 | |
| 145 | get_sys_info(&sys_info); |
Jon Loeliger | 5c9efb3 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 146 | return (sys_info.freqSystemBus + 3L) / 4L; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 147 | } |
| 148 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 149 | |
| 150 | #if defined(CONFIG_WATCHDOG) |
| 151 | void |
| 152 | watchdog_reset(void) |
| 153 | { |
Jason Jin | 3473ab7 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 154 | #if defined(CONFIG_MPC8610) |
| 155 | /* |
| 156 | * This actually feed the hard enabled watchdog. |
| 157 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 158 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Jason Jin | 3473ab7 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 159 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
| 160 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 161 | u32 tmp = gur->pordevsr; |
| 162 | |
| 163 | if (tmp & 0x4000) { |
| 164 | wdt->swsrr = 0x556c; |
| 165 | wdt->swsrr = 0xaa39; |
| 166 | } |
| 167 | #endif |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 168 | } |
| 169 | #endif /* CONFIG_WATCHDOG */ |
| 170 | |
Becky Bruce | 4f93f8b | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 171 | /* |
| 172 | * Print out the state of various machine registers. |
Becky Bruce | e34a0e9 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 173 | * Currently prints out LAWs, BR0/OR0, and BATs |
Becky Bruce | 4f93f8b | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 174 | */ |
| 175 | void mpc86xx_reginfo(void) |
| 176 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 177 | immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Becky Bruce | 4f93f8b | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 178 | ccsr_lbc_t *lbc = &immap->im_lbc; |
| 179 | |
Becky Bruce | e34a0e9 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 180 | print_bats(); |
Becky Bruce | 4f93f8b | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 181 | print_laws(); |
| 182 | |
| 183 | printf ("Local Bus Controller Registers\n" |
| 184 | "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0)); |
| 185 | printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1)); |
| 186 | printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2)); |
| 187 | printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3)); |
| 188 | printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4)); |
| 189 | printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5)); |
| 190 | printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6)); |
| 191 | printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7)); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 192 | |
| 193 | } |