1a47a12beSStefan Roese /* 2a47a12beSStefan Roese * Copyright 2006,2009-2010 Freescale Semiconductor, Inc. 3a47a12beSStefan Roese * Jeff Brown 4a47a12beSStefan Roese * Srikanth Srinivasan (srikanth.srinivasan@freescale.com) 5a47a12beSStefan Roese * 6a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 7a47a12beSStefan Roese * project. 8a47a12beSStefan Roese * 9a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 10a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 11a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 12a47a12beSStefan Roese * the License, or (at your option) any later version. 13a47a12beSStefan Roese * 14a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 15a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 16a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17a47a12beSStefan Roese * GNU General Public License for more details. 18a47a12beSStefan Roese * 19a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 20a47a12beSStefan Roese * along with this program; if not, write to the Free Software 21a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22a47a12beSStefan Roese * MA 02111-1307 USA 23a47a12beSStefan Roese */ 24a47a12beSStefan Roese 25a47a12beSStefan Roese #include <common.h> 26a47a12beSStefan Roese #include <watchdog.h> 27a47a12beSStefan Roese #include <command.h> 28a47a12beSStefan Roese #include <asm/cache.h> 29a47a12beSStefan Roese #include <asm/mmu.h> 30a47a12beSStefan Roese #include <mpc86xx.h> 31a47a12beSStefan Roese #include <asm/fsl_law.h> 32a47a12beSStefan Roese 33a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 34a47a12beSStefan Roese 35a47a12beSStefan Roese /* 36a47a12beSStefan Roese * Default board reset function 37a47a12beSStefan Roese */ 38a47a12beSStefan Roese static void 39a47a12beSStefan Roese __board_reset(void) 40a47a12beSStefan Roese { 41a47a12beSStefan Roese /* Do nothing */ 42a47a12beSStefan Roese } 43a47a12beSStefan Roese void board_reset(void) __attribute__((weak, alias("__board_reset"))); 44a47a12beSStefan Roese 45a47a12beSStefan Roese 46a47a12beSStefan Roese int 47a47a12beSStefan Roese checkcpu(void) 48a47a12beSStefan Roese { 49a47a12beSStefan Roese sys_info_t sysinfo; 50a47a12beSStefan Roese uint pvr, svr; 51a47a12beSStefan Roese uint ver; 52a47a12beSStefan Roese uint major, minor; 53a47a12beSStefan Roese char buf1[32], buf2[32]; 54a47a12beSStefan Roese volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; 55a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 56a47a12beSStefan Roese struct cpu_type *cpu; 57a47a12beSStefan Roese uint msscr0 = mfspr(MSSCR0); 58a47a12beSStefan Roese 59a47a12beSStefan Roese svr = get_svr(); 60a47a12beSStefan Roese ver = SVR_SOC_VER(svr); 61a47a12beSStefan Roese major = SVR_MAJ(svr); 62a47a12beSStefan Roese minor = SVR_MIN(svr); 63a47a12beSStefan Roese 64a47a12beSStefan Roese if (cpu_numcores() > 1) { 65a47a12beSStefan Roese #ifndef CONFIG_MP 66a47a12beSStefan Roese puts("Unicore software on multiprocessor system!!\n" 67a47a12beSStefan Roese "To enable mutlticore build define CONFIG_MP\n"); 68a47a12beSStefan Roese #endif 69a47a12beSStefan Roese } 70a47a12beSStefan Roese puts("CPU: "); 71a47a12beSStefan Roese 72a47a12beSStefan Roese cpu = gd->cpu; 73a47a12beSStefan Roese 74a47a12beSStefan Roese puts(cpu->name); 75a47a12beSStefan Roese 76a47a12beSStefan Roese printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); 77a47a12beSStefan Roese puts("Core: "); 78a47a12beSStefan Roese 79a47a12beSStefan Roese pvr = get_pvr(); 80a47a12beSStefan Roese ver = PVR_E600_VER(pvr); 81a47a12beSStefan Roese major = PVR_E600_MAJ(pvr); 82a47a12beSStefan Roese minor = PVR_E600_MIN(pvr); 83a47a12beSStefan Roese 84a47a12beSStefan Roese printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); 85a47a12beSStefan Roese if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) 86a47a12beSStefan Roese puts("\n Core1Translation Enabled"); 87a47a12beSStefan Roese debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); 88a47a12beSStefan Roese 89a47a12beSStefan Roese printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); 90a47a12beSStefan Roese 91a47a12beSStefan Roese get_sys_info(&sysinfo); 92a47a12beSStefan Roese 93a47a12beSStefan Roese puts("Clock Configuration:\n"); 94a47a12beSStefan Roese printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); 95a47a12beSStefan Roese printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); 96a47a12beSStefan Roese printf(" DDR:%-4s MHz (%s MT/s data rate), ", 97a47a12beSStefan Roese strmhz(buf1, sysinfo.freqSystemBus / 2), 98a47a12beSStefan Roese strmhz(buf2, sysinfo.freqSystemBus)); 99a47a12beSStefan Roese 100a47a12beSStefan Roese if (sysinfo.freqLocalBus > LCRR_CLKDIV) { 101a47a12beSStefan Roese printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); 102a47a12beSStefan Roese } else { 103a47a12beSStefan Roese printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", 104a47a12beSStefan Roese sysinfo.freqLocalBus); 105a47a12beSStefan Roese } 106a47a12beSStefan Roese 107a47a12beSStefan Roese puts("L1: D-cache 32 KB enabled\n"); 108a47a12beSStefan Roese puts(" I-cache 32 KB enabled\n"); 109a47a12beSStefan Roese 110a47a12beSStefan Roese puts("L2: "); 111a47a12beSStefan Roese if (get_l2cr() & 0x80000000) { 112a47a12beSStefan Roese #if defined(CONFIG_MPC8610) 113a47a12beSStefan Roese puts("256"); 114a47a12beSStefan Roese #elif defined(CONFIG_MPC8641) 115a47a12beSStefan Roese puts("512"); 116a47a12beSStefan Roese #endif 117a47a12beSStefan Roese puts(" KB enabled\n"); 118a47a12beSStefan Roese } else { 119a47a12beSStefan Roese puts("Disabled\n"); 120a47a12beSStefan Roese } 121a47a12beSStefan Roese 122a47a12beSStefan Roese return 0; 123a47a12beSStefan Roese } 124a47a12beSStefan Roese 125a47a12beSStefan Roese 126*c22a711dSPeter Tyser int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 127a47a12beSStefan Roese { 128a47a12beSStefan Roese volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; 129a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 130a47a12beSStefan Roese 131a47a12beSStefan Roese /* Attempt board-specific reset */ 132a47a12beSStefan Roese board_reset(); 133a47a12beSStefan Roese 134a47a12beSStefan Roese /* Next try asserting HRESET_REQ */ 135a47a12beSStefan Roese out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); 136a47a12beSStefan Roese 137a47a12beSStefan Roese while (1) 138a47a12beSStefan Roese ; 139*c22a711dSPeter Tyser 140*c22a711dSPeter Tyser return 1; 141a47a12beSStefan Roese } 142a47a12beSStefan Roese 143a47a12beSStefan Roese 144a47a12beSStefan Roese /* 145a47a12beSStefan Roese * Get timebase clock frequency 146a47a12beSStefan Roese */ 147a47a12beSStefan Roese unsigned long 148a47a12beSStefan Roese get_tbclk(void) 149a47a12beSStefan Roese { 150a47a12beSStefan Roese sys_info_t sys_info; 151a47a12beSStefan Roese 152a47a12beSStefan Roese get_sys_info(&sys_info); 153a47a12beSStefan Roese return (sys_info.freqSystemBus + 3L) / 4L; 154a47a12beSStefan Roese } 155a47a12beSStefan Roese 156a47a12beSStefan Roese 157a47a12beSStefan Roese #if defined(CONFIG_WATCHDOG) 158a47a12beSStefan Roese void 159a47a12beSStefan Roese watchdog_reset(void) 160a47a12beSStefan Roese { 161a47a12beSStefan Roese #if defined(CONFIG_MPC8610) 162a47a12beSStefan Roese /* 163a47a12beSStefan Roese * This actually feed the hard enabled watchdog. 164a47a12beSStefan Roese */ 165a47a12beSStefan Roese volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; 166a47a12beSStefan Roese volatile ccsr_wdt_t *wdt = &immap->im_wdt; 167a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 168a47a12beSStefan Roese u32 tmp = gur->pordevsr; 169a47a12beSStefan Roese 170a47a12beSStefan Roese if (tmp & 0x4000) { 171a47a12beSStefan Roese wdt->swsrr = 0x556c; 172a47a12beSStefan Roese wdt->swsrr = 0xaa39; 173a47a12beSStefan Roese } 174a47a12beSStefan Roese #endif 175a47a12beSStefan Roese } 176a47a12beSStefan Roese #endif /* CONFIG_WATCHDOG */ 177a47a12beSStefan Roese 178a47a12beSStefan Roese /* 179a47a12beSStefan Roese * Print out the state of various machine registers. 180a47a12beSStefan Roese * Currently prints out LAWs, BR0/OR0, and BATs 181a47a12beSStefan Roese */ 182a47a12beSStefan Roese void mpc86xx_reginfo(void) 183a47a12beSStefan Roese { 184a47a12beSStefan Roese print_bats(); 185a47a12beSStefan Roese print_laws(); 186f51cdaf1SBecky Bruce print_lbc_regs(); 187a47a12beSStefan Roese } 188a47a12beSStefan Roese 189a47a12beSStefan Roese /* 190a47a12beSStefan Roese * Set the DDR BATs to reflect the actual size of DDR. 191a47a12beSStefan Roese * 192a47a12beSStefan Roese * dram_size is the actual size of DDR, in bytes 193a47a12beSStefan Roese * 194a47a12beSStefan Roese * Note: we assume that CONFIG_MAX_MEM_MAPPED is 2G or smaller as we only 195a47a12beSStefan Roese * are using a single BAT to cover DDR. 196a47a12beSStefan Roese * 197a47a12beSStefan Roese * If this is not true, (e.g. CONFIG_MAX_MEM_MAPPED is 2GB but HID0_XBSEN 198a47a12beSStefan Roese * is not defined) then we might have a situation where U-Boot will attempt 199a47a12beSStefan Roese * to relocated itself outside of the region mapped by DBAT0. 200a47a12beSStefan Roese * This will cause a machine check. 201a47a12beSStefan Roese * 202a47a12beSStefan Roese * Currently we are limited to power of two sized DDR since we only use a 203a47a12beSStefan Roese * single bat. If a non-power of two size is used that is less than 204a47a12beSStefan Roese * CONFIG_MAX_MEM_MAPPED u-boot will crash. 205a47a12beSStefan Roese * 206a47a12beSStefan Roese */ 207a47a12beSStefan Roese void setup_ddr_bat(phys_addr_t dram_size) 208a47a12beSStefan Roese { 209a47a12beSStefan Roese unsigned long batu, bl; 210a47a12beSStefan Roese 211a47a12beSStefan Roese bl = TO_BATU_BL(min(dram_size, CONFIG_MAX_MEM_MAPPED)); 212a47a12beSStefan Roese 213a47a12beSStefan Roese if (BATU_SIZE(bl) != dram_size) { 214a47a12beSStefan Roese u64 sz = (u64)dram_size - BATU_SIZE(bl); 215a47a12beSStefan Roese print_size(sz, " left unmapped\n"); 216a47a12beSStefan Roese } 217a47a12beSStefan Roese 218a47a12beSStefan Roese batu = bl | BATU_VS | BATU_VP; 219a47a12beSStefan Roese write_bat(DBAT0, batu, CONFIG_SYS_DBAT0L); 220a47a12beSStefan Roese write_bat(IBAT0, batu, CONFIG_SYS_IBAT0L); 221a47a12beSStefan Roese } 222