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 major, minor; 52a47a12beSStefan Roese char buf1[32], buf2[32]; 53a47a12beSStefan Roese volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; 54a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 55a47a12beSStefan Roese struct cpu_type *cpu; 56a47a12beSStefan Roese uint msscr0 = mfspr(MSSCR0); 57a47a12beSStefan Roese 58a47a12beSStefan Roese svr = get_svr(); 59a47a12beSStefan Roese major = SVR_MAJ(svr); 60a47a12beSStefan Roese minor = SVR_MIN(svr); 61a47a12beSStefan Roese 62a47a12beSStefan Roese if (cpu_numcores() > 1) { 63a47a12beSStefan Roese #ifndef CONFIG_MP 64a47a12beSStefan Roese puts("Unicore software on multiprocessor system!!\n" 65a47a12beSStefan Roese "To enable mutlticore build define CONFIG_MP\n"); 66a47a12beSStefan Roese #endif 67a47a12beSStefan Roese } 68a47a12beSStefan Roese puts("CPU: "); 69a47a12beSStefan Roese 7067ac13b1SSimon Glass cpu = gd->arch.cpu; 71a47a12beSStefan Roese 72a47a12beSStefan Roese puts(cpu->name); 73a47a12beSStefan Roese 74a47a12beSStefan Roese printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); 75a47a12beSStefan Roese puts("Core: "); 76a47a12beSStefan Roese 77a47a12beSStefan Roese pvr = get_pvr(); 78a47a12beSStefan Roese major = PVR_E600_MAJ(pvr); 79a47a12beSStefan Roese minor = PVR_E600_MIN(pvr); 80a47a12beSStefan Roese 81*6770c5e2SFabio Estevam printf("e600 Core %d", (msscr0 & 0x20) ? 1 : 0); 82a47a12beSStefan Roese if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) 83a47a12beSStefan Roese puts("\n Core1Translation Enabled"); 84a47a12beSStefan Roese debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); 85a47a12beSStefan Roese 86a47a12beSStefan Roese printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); 87a47a12beSStefan Roese 88a47a12beSStefan Roese get_sys_info(&sysinfo); 89a47a12beSStefan Roese 90a47a12beSStefan Roese puts("Clock Configuration:\n"); 91a47a12beSStefan Roese printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); 92a47a12beSStefan Roese printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); 93a47a12beSStefan Roese printf(" DDR:%-4s MHz (%s MT/s data rate), ", 94a47a12beSStefan Roese strmhz(buf1, sysinfo.freqSystemBus / 2), 95a47a12beSStefan Roese strmhz(buf2, sysinfo.freqSystemBus)); 96a47a12beSStefan Roese 97a47a12beSStefan Roese if (sysinfo.freqLocalBus > LCRR_CLKDIV) { 98a47a12beSStefan Roese printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); 99a47a12beSStefan Roese } else { 100a47a12beSStefan Roese printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", 101a47a12beSStefan Roese sysinfo.freqLocalBus); 102a47a12beSStefan Roese } 103a47a12beSStefan Roese 104a47a12beSStefan Roese puts("L1: D-cache 32 KB enabled\n"); 105a47a12beSStefan Roese puts(" I-cache 32 KB enabled\n"); 106a47a12beSStefan Roese 107a47a12beSStefan Roese puts("L2: "); 108a47a12beSStefan Roese if (get_l2cr() & 0x80000000) { 109a47a12beSStefan Roese #if defined(CONFIG_MPC8610) 110a47a12beSStefan Roese puts("256"); 111a47a12beSStefan Roese #elif defined(CONFIG_MPC8641) 112a47a12beSStefan Roese puts("512"); 113a47a12beSStefan Roese #endif 114a47a12beSStefan Roese puts(" KB enabled\n"); 115a47a12beSStefan Roese } else { 116a47a12beSStefan Roese puts("Disabled\n"); 117a47a12beSStefan Roese } 118a47a12beSStefan Roese 119a47a12beSStefan Roese return 0; 120a47a12beSStefan Roese } 121a47a12beSStefan Roese 122a47a12beSStefan Roese 123c22a711dSPeter Tyser int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 124a47a12beSStefan Roese { 125a47a12beSStefan Roese volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; 126a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 127a47a12beSStefan Roese 128a47a12beSStefan Roese /* Attempt board-specific reset */ 129a47a12beSStefan Roese board_reset(); 130a47a12beSStefan Roese 131a47a12beSStefan Roese /* Next try asserting HRESET_REQ */ 132a47a12beSStefan Roese out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); 133a47a12beSStefan Roese 134a47a12beSStefan Roese while (1) 135a47a12beSStefan Roese ; 136c22a711dSPeter Tyser 137c22a711dSPeter Tyser return 1; 138a47a12beSStefan Roese } 139a47a12beSStefan Roese 140a47a12beSStefan Roese 141a47a12beSStefan Roese /* 142a47a12beSStefan Roese * Get timebase clock frequency 143a47a12beSStefan Roese */ 144a47a12beSStefan Roese unsigned long 145a47a12beSStefan Roese get_tbclk(void) 146a47a12beSStefan Roese { 147a47a12beSStefan Roese sys_info_t sys_info; 148a47a12beSStefan Roese 149a47a12beSStefan Roese get_sys_info(&sys_info); 150a47a12beSStefan Roese return (sys_info.freqSystemBus + 3L) / 4L; 151a47a12beSStefan Roese } 152a47a12beSStefan Roese 153a47a12beSStefan Roese 154a47a12beSStefan Roese #if defined(CONFIG_WATCHDOG) 155a47a12beSStefan Roese void 156a47a12beSStefan Roese watchdog_reset(void) 157a47a12beSStefan Roese { 158a47a12beSStefan Roese #if defined(CONFIG_MPC8610) 159a47a12beSStefan Roese /* 160a47a12beSStefan Roese * This actually feed the hard enabled watchdog. 161a47a12beSStefan Roese */ 162a47a12beSStefan Roese volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; 163a47a12beSStefan Roese volatile ccsr_wdt_t *wdt = &immap->im_wdt; 164a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 165a47a12beSStefan Roese u32 tmp = gur->pordevsr; 166a47a12beSStefan Roese 167a47a12beSStefan Roese if (tmp & 0x4000) { 168a47a12beSStefan Roese wdt->swsrr = 0x556c; 169a47a12beSStefan Roese wdt->swsrr = 0xaa39; 170a47a12beSStefan Roese } 171a47a12beSStefan Roese #endif 172a47a12beSStefan Roese } 173a47a12beSStefan Roese #endif /* CONFIG_WATCHDOG */ 174a47a12beSStefan Roese 175a47a12beSStefan Roese /* 176a47a12beSStefan Roese * Print out the state of various machine registers. 177a47a12beSStefan Roese * Currently prints out LAWs, BR0/OR0, and BATs 178a47a12beSStefan Roese */ 179a47a12beSStefan Roese void mpc86xx_reginfo(void) 180a47a12beSStefan Roese { 181a47a12beSStefan Roese print_bats(); 182a47a12beSStefan Roese print_laws(); 183f51cdaf1SBecky Bruce print_lbc_regs(); 184a47a12beSStefan Roese } 185a47a12beSStefan Roese 186a47a12beSStefan Roese /* 187a47a12beSStefan Roese * Set the DDR BATs to reflect the actual size of DDR. 188a47a12beSStefan Roese * 189a47a12beSStefan Roese * dram_size is the actual size of DDR, in bytes 190a47a12beSStefan Roese * 191a47a12beSStefan Roese * Note: we assume that CONFIG_MAX_MEM_MAPPED is 2G or smaller as we only 192a47a12beSStefan Roese * are using a single BAT to cover DDR. 193a47a12beSStefan Roese * 194a47a12beSStefan Roese * If this is not true, (e.g. CONFIG_MAX_MEM_MAPPED is 2GB but HID0_XBSEN 195a47a12beSStefan Roese * is not defined) then we might have a situation where U-Boot will attempt 196a47a12beSStefan Roese * to relocated itself outside of the region mapped by DBAT0. 197a47a12beSStefan Roese * This will cause a machine check. 198a47a12beSStefan Roese * 199a47a12beSStefan Roese * Currently we are limited to power of two sized DDR since we only use a 200a47a12beSStefan Roese * single bat. If a non-power of two size is used that is less than 201a47a12beSStefan Roese * CONFIG_MAX_MEM_MAPPED u-boot will crash. 202a47a12beSStefan Roese * 203a47a12beSStefan Roese */ 204a47a12beSStefan Roese void setup_ddr_bat(phys_addr_t dram_size) 205a47a12beSStefan Roese { 206a47a12beSStefan Roese unsigned long batu, bl; 207a47a12beSStefan Roese 208a47a12beSStefan Roese bl = TO_BATU_BL(min(dram_size, CONFIG_MAX_MEM_MAPPED)); 209a47a12beSStefan Roese 210a47a12beSStefan Roese if (BATU_SIZE(bl) != dram_size) { 211a47a12beSStefan Roese u64 sz = (u64)dram_size - BATU_SIZE(bl); 212a47a12beSStefan Roese print_size(sz, " left unmapped\n"); 213a47a12beSStefan Roese } 214a47a12beSStefan Roese 215a47a12beSStefan Roese batu = bl | BATU_VS | BATU_VP; 216a47a12beSStefan Roese write_bat(DBAT0, batu, CONFIG_SYS_DBAT0L); 217a47a12beSStefan Roese write_bat(IBAT0, batu, CONFIG_SYS_IBAT0L); 218a47a12beSStefan Roese } 219