Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1 | /* |
Timur Tabi | 107e9cd | 2010-03-29 12:51:07 -0500 | [diff] [blame^] | 2 | * Copyright 2006,2009-2010 Freescale Semiconductor, Inc. |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 3 | * Jeff Brown |
Jon Loeliger | 5c8aa97 | 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 | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 29 | #include <asm/mmu.h> |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 30 | #include <mpc86xx.h> |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 31 | #include <asm/fsl_law.h> |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 32 | |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Peter Tyser | 6945440 | 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 | 21d2cd2 | 2009-04-20 11:08:46 -0500 | [diff] [blame] | 43 | void board_reset(void) __attribute__((weak, alias("__board_reset"))); |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 44 | |
| 45 | |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 46 | int |
| 47 | checkcpu(void) |
Jon Loeliger | 5c8aa97 | 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 | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 53 | char buf1[32], buf2[32]; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 54 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 3b971c9 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 55 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 56 | struct cpu_type *cpu; |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 57 | uint msscr0 = mfspr(MSSCR0); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 58 | |
| 59 | svr = get_svr(); |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 60 | ver = SVR_SOC_VER(svr); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 61 | major = SVR_MAJ(svr); |
| 62 | minor = SVR_MIN(svr); |
| 63 | |
Poonam Aggrwal | 36a6843 | 2009-09-03 19:42:40 +0530 | [diff] [blame] | 64 | if (cpu_numcores() > 1) { |
| 65 | #ifndef CONFIG_MP |
| 66 | puts("Unicore software on multiprocessor system!!\n" |
| 67 | "To enable mutlticore build define CONFIG_MP\n"); |
| 68 | #endif |
| 69 | } |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 70 | puts("CPU: "); |
| 71 | |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 72 | cpu = gd->cpu; |
| 73 | |
Poonam Aggrwal | da6e1ca | 2009-09-02 13:35:21 +0530 | [diff] [blame] | 74 | puts(cpu->name); |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 75 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 76 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 77 | puts("Core: "); |
| 78 | |
| 79 | pvr = get_pvr(); |
| 80 | ver = PVR_E600_VER(pvr); |
| 81 | major = PVR_E600_MAJ(pvr); |
| 82 | minor = PVR_E600_MIN(pvr); |
| 83 | |
| 84 | printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); |
| 85 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) |
| 86 | puts("\n Core1Translation Enabled"); |
| 87 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); |
| 88 | |
| 89 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 90 | |
| 91 | get_sys_info(&sysinfo); |
| 92 | |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 93 | puts("Clock Configuration:\n"); |
| 94 | printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); |
| 95 | printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); |
| 96 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
| 97 | strmhz(buf1, sysinfo.freqSystemBus / 2), |
| 98 | strmhz(buf2, sysinfo.freqSystemBus)); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 99 | |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 100 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) { |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 101 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 102 | } else { |
Wolfgang Denk | 3fe630c | 2009-01-12 14:50:35 +0100 | [diff] [blame] | 103 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 104 | sysinfo.freqLocalBus); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 105 | } |
| 106 | |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 107 | puts("L1: D-cache 32 KB enabled\n"); |
| 108 | puts(" I-cache 32 KB enabled\n"); |
| 109 | |
| 110 | puts("L2: "); |
| 111 | if (get_l2cr() & 0x80000000) { |
| 112 | #if defined(CONFIG_MPC8610) |
| 113 | puts("256"); |
| 114 | #elif defined(CONFIG_MPC8641) |
| 115 | puts("512"); |
| 116 | #endif |
| 117 | puts(" KB enabled\n"); |
| 118 | } else { |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 119 | puts("Disabled\n"); |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 120 | } |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 121 | |
| 122 | return 0; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 126 | void |
Jon Loeliger | d68e2ba | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 127 | do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 128 | { |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 129 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
| 130 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 131 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 132 | /* Attempt board-specific reset */ |
| 133 | board_reset(); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 134 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 135 | /* Next try asserting HRESET_REQ */ |
| 136 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 137 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 138 | while (1) |
| 139 | ; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 143 | /* |
| 144 | * Get timebase clock frequency |
| 145 | */ |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 146 | unsigned long |
| 147 | get_tbclk(void) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 148 | { |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 149 | sys_info_t sys_info; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 150 | |
| 151 | get_sys_info(&sys_info); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 152 | return (sys_info.freqSystemBus + 3L) / 4L; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 153 | } |
| 154 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 155 | |
| 156 | #if defined(CONFIG_WATCHDOG) |
| 157 | void |
| 158 | watchdog_reset(void) |
| 159 | { |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 160 | #if defined(CONFIG_MPC8610) |
| 161 | /* |
| 162 | * This actually feed the hard enabled watchdog. |
| 163 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 164 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 165 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
| 166 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 167 | u32 tmp = gur->pordevsr; |
| 168 | |
| 169 | if (tmp & 0x4000) { |
| 170 | wdt->swsrr = 0x556c; |
| 171 | wdt->swsrr = 0xaa39; |
| 172 | } |
| 173 | #endif |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 174 | } |
| 175 | #endif /* CONFIG_WATCHDOG */ |
| 176 | |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 177 | /* |
| 178 | * Print out the state of various machine registers. |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 179 | * Currently prints out LAWs, BR0/OR0, and BATs |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 180 | */ |
| 181 | void mpc86xx_reginfo(void) |
| 182 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 183 | immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 184 | ccsr_lbc_t *lbc = &immap->im_lbc; |
| 185 | |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 186 | print_bats(); |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 187 | print_laws(); |
| 188 | |
| 189 | printf ("Local Bus Controller Registers\n" |
| 190 | "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0)); |
| 191 | printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1)); |
| 192 | printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2)); |
| 193 | printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3)); |
| 194 | printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4)); |
| 195 | printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5)); |
| 196 | printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6)); |
| 197 | printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7)); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 198 | |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 199 | } |
Timur Tabi | 107e9cd | 2010-03-29 12:51:07 -0500 | [diff] [blame^] | 200 | |
| 201 | /* |
| 202 | * Set the DDR BATs to reflect the actual size of DDR. |
| 203 | * |
| 204 | * dram_size is the actual size of DDR, in bytes |
| 205 | * |
| 206 | * Note: we assume that CONFIG_MAX_MEM_MAPPED is 2G or smaller as we only |
| 207 | * are using a single BAT to cover DDR. |
| 208 | * |
| 209 | * If this is not true, (e.g. CONFIG_MAX_MEM_MAPPED is 2GB but HID0_XBSEN |
| 210 | * is not defined) then we might have a situation where U-Boot will attempt |
| 211 | * to relocated itself outside of the region mapped by DBAT0. |
| 212 | * This will cause a machine check. |
| 213 | * |
| 214 | * Currently we are limited to power of two sized DDR since we only use a |
| 215 | * single bat. If a non-power of two size is used that is less than |
| 216 | * CONFIG_MAX_MEM_MAPPED u-boot will crash. |
| 217 | * |
| 218 | */ |
| 219 | void setup_ddr_bat(phys_addr_t dram_size) |
| 220 | { |
| 221 | unsigned long batu, bl; |
| 222 | |
| 223 | bl = TO_BATU_BL(min(dram_size, CONFIG_MAX_MEM_MAPPED)); |
| 224 | |
| 225 | if (BATU_SIZE(bl) != dram_size) { |
| 226 | u64 sz = (u64)dram_size - BATU_SIZE(bl); |
| 227 | print_size(sz, " left unmapped\n"); |
| 228 | } |
| 229 | |
| 230 | batu = bl | BATU_VS | BATU_VP; |
| 231 | write_bat(DBAT0, batu, CONFIG_SYS_DBAT0L); |
| 232 | write_bat(IBAT0, batu, CONFIG_SYS_IBAT0L); |
| 233 | } |