1a47a12beSStefan Roese /* 2a47a12beSStefan Roese * Copyright 2008-2010 Freescale Semiconductor, Inc. 3a47a12beSStefan Roese * 4a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 5a47a12beSStefan Roese * project. 6a47a12beSStefan Roese * 7a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 8a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 9a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 10a47a12beSStefan Roese * the License, or (at your option) any later version. 11a47a12beSStefan Roese * 12a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 13a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 14a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15a47a12beSStefan Roese * GNU General Public License for more details. 16a47a12beSStefan Roese * 17a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 18a47a12beSStefan Roese * along with this program; if not, write to the Free Software 19a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20a47a12beSStefan Roese * MA 02111-1307 USA 21a47a12beSStefan Roese */ 22a47a12beSStefan Roese 23a47a12beSStefan Roese #include <common.h> 24a47a12beSStefan Roese #include <asm/processor.h> 25a47a12beSStefan Roese #include <asm/mmu.h> 26a47a12beSStefan Roese #include <ioports.h> 27a47a12beSStefan Roese #include <lmb.h> 28a47a12beSStefan Roese #include <asm/io.h> 29a47a12beSStefan Roese #include <asm/mp.h> 30a47a12beSStefan Roese 31a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 32a47a12beSStefan Roese 33a47a12beSStefan Roese int cpu_reset(int nr) 34a47a12beSStefan Roese { 35a47a12beSStefan Roese /* dummy function so common/cmd_mp.c will build 36a47a12beSStefan Roese * should be implemented in the future, when cpu_release() 37a47a12beSStefan Roese * is supported. Be aware there may be a similiar bug 38a47a12beSStefan Roese * as exists on MPC85xx w/its PIC having a timing window 39a47a12beSStefan Roese * associated to resetting the core */ 40a47a12beSStefan Roese return 1; 41a47a12beSStefan Roese } 42a47a12beSStefan Roese 43a47a12beSStefan Roese int cpu_status(int nr) 44a47a12beSStefan Roese { 45a47a12beSStefan Roese /* dummy function so common/cmd_mp.c will build */ 46a47a12beSStefan Roese return 0; 47a47a12beSStefan Roese } 48a47a12beSStefan Roese 49a47a12beSStefan Roese int cpu_disable(int nr) 50a47a12beSStefan Roese { 51a47a12beSStefan Roese volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR; 52a47a12beSStefan Roese volatile ccsr_gur_t *gur = &immap->im_gur; 53a47a12beSStefan Roese 54a47a12beSStefan Roese switch (nr) { 55a47a12beSStefan Roese case 0: 56a47a12beSStefan Roese setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU0); 57a47a12beSStefan Roese break; 58a47a12beSStefan Roese case 1: 59a47a12beSStefan Roese setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU1); 60a47a12beSStefan Roese break; 61a47a12beSStefan Roese default: 62a47a12beSStefan Roese printf("Invalid cpu number for disable %d\n", nr); 63a47a12beSStefan Roese return 1; 64a47a12beSStefan Roese } 65a47a12beSStefan Roese 66a47a12beSStefan Roese return 0; 67a47a12beSStefan Roese } 68a47a12beSStefan Roese 69*8f3a7fa4SKumar Gala int is_core_disabled(int nr) { 70*8f3a7fa4SKumar Gala immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR; 71*8f3a7fa4SKumar Gala ccsr_gur_t *gur = &immap->im_gur; 72*8f3a7fa4SKumar Gala u32 devdisr = in_be32(&gur->devdisr); 73*8f3a7fa4SKumar Gala 74*8f3a7fa4SKumar Gala switch (nr) { 75*8f3a7fa4SKumar Gala case 0: 76*8f3a7fa4SKumar Gala return (devdisr & MPC86xx_DEVDISR_CPU0); 77*8f3a7fa4SKumar Gala case 1: 78*8f3a7fa4SKumar Gala return (devdisr & MPC86xx_DEVDISR_CPU1); 79*8f3a7fa4SKumar Gala default: 80*8f3a7fa4SKumar Gala printf("Invalid cpu number for disable %d\n", nr); 81*8f3a7fa4SKumar Gala } 82*8f3a7fa4SKumar Gala 83*8f3a7fa4SKumar Gala return 0; 84*8f3a7fa4SKumar Gala } 85*8f3a7fa4SKumar Gala 8654841ab5SWolfgang Denk int cpu_release(int nr, int argc, char * const argv[]) 87a47a12beSStefan Roese { 88a47a12beSStefan Roese /* dummy function so common/cmd_mp.c will build 89a47a12beSStefan Roese * should be implemented in the future */ 90a47a12beSStefan Roese return 1; 91a47a12beSStefan Roese } 92a47a12beSStefan Roese 93a47a12beSStefan Roese u32 determine_mp_bootpg(void) 94a47a12beSStefan Roese { 95a47a12beSStefan Roese /* if we have 4G or more of memory, put the boot page at 4Gb-1M */ 96a47a12beSStefan Roese if ((u64)gd->ram_size > 0xfffff000) 97a47a12beSStefan Roese return (0xfff00000); 98a47a12beSStefan Roese 99a47a12beSStefan Roese return (gd->ram_size - (1024 * 1024)); 100a47a12beSStefan Roese } 101a47a12beSStefan Roese 102a47a12beSStefan Roese void cpu_mp_lmb_reserve(struct lmb *lmb) 103a47a12beSStefan Roese { 104a47a12beSStefan Roese u32 bootpg = determine_mp_bootpg(); 105a47a12beSStefan Roese 106a47a12beSStefan Roese /* tell u-boot we stole a page */ 107a47a12beSStefan Roese lmb_reserve(lmb, bootpg, 4096); 108a47a12beSStefan Roese } 109a47a12beSStefan Roese 110a47a12beSStefan Roese /* 111a47a12beSStefan Roese * Copy the code for other cpus to execute into an 112a47a12beSStefan Roese * aligned location accessible via BPTR 113a47a12beSStefan Roese */ 114a47a12beSStefan Roese void setup_mp(void) 115a47a12beSStefan Roese { 116a47a12beSStefan Roese extern ulong __secondary_start_page; 117a47a12beSStefan Roese ulong fixup = (ulong)&__secondary_start_page; 118a47a12beSStefan Roese u32 bootpg = determine_mp_bootpg(); 119a47a12beSStefan Roese u32 bootpg_va; 120a47a12beSStefan Roese 121a47a12beSStefan Roese if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) { 122a47a12beSStefan Roese /* We're not covered by the DDR mapping, set up BAT */ 123a47a12beSStefan Roese write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K | 124a47a12beSStefan Roese BATU_VS | BATU_VP, 125a47a12beSStefan Roese bootpg | BATL_PP_RW | BATL_MEMCOHERENCE); 126a47a12beSStefan Roese bootpg_va = CONFIG_SYS_SCRATCH_VA; 127a47a12beSStefan Roese } else { 128a47a12beSStefan Roese bootpg_va = bootpg; 129a47a12beSStefan Roese } 130a47a12beSStefan Roese 131a47a12beSStefan Roese memcpy((void *)bootpg_va, (void *)fixup, 4096); 132a47a12beSStefan Roese flush_cache(bootpg_va, 4096); 133a47a12beSStefan Roese 134a47a12beSStefan Roese /* remove the temporary BAT mapping */ 135a47a12beSStefan Roese if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) 136a47a12beSStefan Roese write_bat(DBAT7, 0, 0); 137a47a12beSStefan Roese 138a47a12beSStefan Roese /* If the physical location of bootpg is not at fff00000, set BPTR */ 139a47a12beSStefan Roese if (bootpg != 0xfff00000) 140a47a12beSStefan Roese out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 | 141a47a12beSStefan Roese (bootpg >> 12)); 142a47a12beSStefan Roese } 143