Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame^] | 1 | #include <common.h> |
| 2 | #include <asm/processor.h> |
| 3 | #include <asm/mmu.h> |
| 4 | #include <ioports.h> |
| 5 | #include <lmb.h> |
| 6 | #include <asm/io.h> |
| 7 | #include "mp.h" |
| 8 | |
| 9 | DECLARE_GLOBAL_DATA_PTR; |
| 10 | |
| 11 | #if (CONFIG_NUM_CPUS > 1) |
| 12 | void cpu_mp_lmb_reserve(struct lmb *lmb) |
| 13 | { |
| 14 | u32 bootpg; |
| 15 | |
| 16 | /* if we have 4G or more of memory, put the boot page at 4Gb-1M */ |
| 17 | if ((u64)gd->ram_size > 0xfffff000) |
| 18 | bootpg = 0xfff00000; |
| 19 | else |
| 20 | bootpg = gd->ram_size - (1024 * 1024); |
| 21 | |
| 22 | /* tell u-boot we stole a page */ |
| 23 | lmb_reserve(lmb, bootpg, 4096); |
| 24 | } |
| 25 | |
| 26 | /* |
| 27 | * Copy the code for other cpus to execute into an |
| 28 | * aligned location accessible via BPTR |
| 29 | */ |
| 30 | void setup_mp(void) |
| 31 | { |
| 32 | extern ulong __secondary_start_page; |
| 33 | ulong fixup = (ulong)&__secondary_start_page; |
| 34 | u32 bootpg; |
| 35 | u32 bootpg_va; |
| 36 | |
| 37 | /* |
| 38 | * If we have 4G or more of memory, put the boot page at 4Gb-1M. |
| 39 | * Otherwise, put it at the very end of RAM. |
| 40 | */ |
| 41 | if (gd->ram_size > 0xfffff000) |
| 42 | bootpg = 0xfff00000; |
| 43 | else |
| 44 | bootpg = gd->ram_size - (1024 * 1024); |
| 45 | |
| 46 | if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) { |
| 47 | /* We're not covered by the DDR mapping, set up BAT */ |
| 48 | write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K | |
| 49 | BATU_VS | BATU_VP, |
| 50 | bootpg | BATL_PP_RW | BATL_MEMCOHERENCE); |
| 51 | bootpg_va = CONFIG_SYS_SCRATCH_VA; |
| 52 | } else { |
| 53 | bootpg_va = bootpg; |
| 54 | } |
| 55 | |
| 56 | memcpy((void *)bootpg_va, (void *)fixup, 4096); |
| 57 | flush_cache(bootpg_va, 4096); |
| 58 | |
| 59 | /* remove the temporary BAT mapping */ |
| 60 | if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) |
| 61 | write_bat(DBAT7, 0, 0); |
| 62 | |
| 63 | /* If the physical location of bootpg is not at fff00000, set BPTR */ |
| 64 | if (bootpg != 0xfff00000) |
| 65 | out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 | |
| 66 | (bootpg >> 12)); |
| 67 | } |
| 68 | #endif |