1a47a12beSStefan Roese /* 2*af042474SKumar Gala * Copyright 2004,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 /* 26a47a12beSStefan Roese * cpu_init.c - low level cpu init 27a47a12beSStefan Roese */ 28a47a12beSStefan Roese 29a47a12beSStefan Roese #include <config.h> 30a47a12beSStefan Roese #include <common.h> 31a47a12beSStefan Roese #include <mpc86xx.h> 32a47a12beSStefan Roese #include <asm/mmu.h> 33a47a12beSStefan Roese #include <asm/fsl_law.h> 34*af042474SKumar Gala #include <asm/fsl_serdes.h> 35a47a12beSStefan Roese #include <asm/mp.h> 36a47a12beSStefan Roese 37a47a12beSStefan Roese void setup_bats(void); 38a47a12beSStefan Roese 39a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 40a47a12beSStefan Roese 41a47a12beSStefan Roese /* 42a47a12beSStefan Roese * Breathe some life into the CPU... 43a47a12beSStefan Roese * 44a47a12beSStefan Roese * Set up the memory map 45a47a12beSStefan Roese * initialize a bunch of registers 46a47a12beSStefan Roese */ 47a47a12beSStefan Roese 48a47a12beSStefan Roese void cpu_init_f(void) 49a47a12beSStefan Roese { 50a47a12beSStefan Roese /* Pointer is writable since we allocated a register for it */ 51a47a12beSStefan Roese gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); 52a47a12beSStefan Roese 53a47a12beSStefan Roese /* Clear initial global data */ 54a47a12beSStefan Roese memset ((void *) gd, 0, sizeof (gd_t)); 55a47a12beSStefan Roese 56a47a12beSStefan Roese #ifdef CONFIG_FSL_LAW 57a47a12beSStefan Roese init_laws(); 58a47a12beSStefan Roese #endif 59a47a12beSStefan Roese 60a47a12beSStefan Roese setup_bats(); 61a47a12beSStefan Roese 62f51cdaf1SBecky Bruce init_early_memctl_regs(); 63a47a12beSStefan Roese 64a47a12beSStefan Roese #if defined(CONFIG_FSL_DMA) 65a47a12beSStefan Roese dma_init(); 66a47a12beSStefan Roese #endif 67a47a12beSStefan Roese 68a47a12beSStefan Roese /* enable the timebase bit in HID0 */ 69a47a12beSStefan Roese set_hid0(get_hid0() | 0x4000000); 70a47a12beSStefan Roese 71a47a12beSStefan Roese /* enable EMCP, SYNCBE | ABE bits in HID1 */ 72a47a12beSStefan Roese set_hid1(get_hid1() | 0x80000C00); 73a47a12beSStefan Roese } 74a47a12beSStefan Roese 75a47a12beSStefan Roese /* 76a47a12beSStefan Roese * initialize higher level parts of CPU like timers 77a47a12beSStefan Roese */ 78a47a12beSStefan Roese int cpu_init_r(void) 79a47a12beSStefan Roese { 80*af042474SKumar Gala /* needs to be in ram since code uses global static vars */ 81*af042474SKumar Gala fsl_serdes_init(); 82*af042474SKumar Gala 83a47a12beSStefan Roese #if defined(CONFIG_MP) 84a47a12beSStefan Roese setup_mp(); 85a47a12beSStefan Roese #endif 86a47a12beSStefan Roese return 0; 87a47a12beSStefan Roese } 88a47a12beSStefan Roese 89a47a12beSStefan Roese /* Set up BAT registers */ 90a47a12beSStefan Roese void setup_bats(void) 91a47a12beSStefan Roese { 92a47a12beSStefan Roese #if defined(CONFIG_SYS_DBAT0U) && defined(CONFIG_SYS_DBAT0L) 93a47a12beSStefan Roese write_bat(DBAT0, CONFIG_SYS_DBAT0U, CONFIG_SYS_DBAT0L); 94a47a12beSStefan Roese #endif 95a47a12beSStefan Roese #if defined(CONFIG_SYS_IBAT0U) && defined(CONFIG_SYS_IBAT0L) 96a47a12beSStefan Roese write_bat(IBAT0, CONFIG_SYS_IBAT0U, CONFIG_SYS_IBAT0L); 97a47a12beSStefan Roese #endif 98a47a12beSStefan Roese write_bat(DBAT1, CONFIG_SYS_DBAT1U, CONFIG_SYS_DBAT1L); 99a47a12beSStefan Roese write_bat(IBAT1, CONFIG_SYS_IBAT1U, CONFIG_SYS_IBAT1L); 100a47a12beSStefan Roese write_bat(DBAT2, CONFIG_SYS_DBAT2U, CONFIG_SYS_DBAT2L); 101a47a12beSStefan Roese write_bat(IBAT2, CONFIG_SYS_IBAT2U, CONFIG_SYS_IBAT2L); 102a47a12beSStefan Roese write_bat(DBAT3, CONFIG_SYS_DBAT3U, CONFIG_SYS_DBAT3L); 103a47a12beSStefan Roese write_bat(IBAT3, CONFIG_SYS_IBAT3U, CONFIG_SYS_IBAT3L); 104a47a12beSStefan Roese write_bat(DBAT4, CONFIG_SYS_DBAT4U, CONFIG_SYS_DBAT4L); 105a47a12beSStefan Roese write_bat(IBAT4, CONFIG_SYS_IBAT4U, CONFIG_SYS_IBAT4L); 106a47a12beSStefan Roese write_bat(DBAT5, CONFIG_SYS_DBAT5U, CONFIG_SYS_DBAT5L); 107a47a12beSStefan Roese write_bat(IBAT5, CONFIG_SYS_IBAT5U, CONFIG_SYS_IBAT5L); 108a47a12beSStefan Roese write_bat(DBAT6, CONFIG_SYS_DBAT6U, CONFIG_SYS_DBAT6L); 109a47a12beSStefan Roese write_bat(IBAT6, CONFIG_SYS_IBAT6U, CONFIG_SYS_IBAT6L); 110a47a12beSStefan Roese write_bat(DBAT7, CONFIG_SYS_DBAT7U, CONFIG_SYS_DBAT7L); 111a47a12beSStefan Roese write_bat(IBAT7, CONFIG_SYS_IBAT7U, CONFIG_SYS_IBAT7L); 112a47a12beSStefan Roese 113a47a12beSStefan Roese return; 114a47a12beSStefan Roese } 115a47a12beSStefan Roese 116a47a12beSStefan Roese #ifdef CONFIG_ADDR_MAP 117a47a12beSStefan Roese /* Initialize address mapping array */ 118a47a12beSStefan Roese void init_addr_map(void) 119a47a12beSStefan Roese { 120a47a12beSStefan Roese int i; 121a47a12beSStefan Roese ppc_bat_t bat = DBAT0; 122a47a12beSStefan Roese phys_size_t size; 123a47a12beSStefan Roese unsigned long upper, lower; 124a47a12beSStefan Roese 125a47a12beSStefan Roese for (i = 0; i < CONFIG_SYS_NUM_ADDR_MAP; i++, bat++) { 126a47a12beSStefan Roese if (read_bat(bat, &upper, &lower) != -1) { 127a47a12beSStefan Roese if (!BATU_VALID(upper)) 128a47a12beSStefan Roese size = 0; 129a47a12beSStefan Roese else 130a47a12beSStefan Roese size = BATU_SIZE(upper); 131a47a12beSStefan Roese addrmap_set_entry(BATU_VADDR(upper), BATL_PADDR(lower), 132a47a12beSStefan Roese size, i); 133a47a12beSStefan Roese } 134a47a12beSStefan Roese #ifdef CONFIG_HIGH_BATS 135a47a12beSStefan Roese /* High bats are not contiguous with low BAT numbers */ 136a47a12beSStefan Roese if (bat == DBAT3) 137a47a12beSStefan Roese bat = DBAT4 - 1; 138a47a12beSStefan Roese #endif 139a47a12beSStefan Roese } 140a47a12beSStefan Roese } 141a47a12beSStefan Roese #endif 142