blob: 2940673c7c7bfc89ba6de040685781abe334c351 [file] [log] [blame]
Becky Bruce1266df82008-11-03 15:44:01 -06001#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>
Kumar Gala7649a592009-03-31 23:02:38 -05007#include <asm/mp.h>
Becky Bruce1266df82008-11-03 15:44:01 -06008
9DECLARE_GLOBAL_DATA_PTR;
10
Kumar Gala7649a592009-03-31 23:02:38 -050011int cpu_reset(int nr)
Becky Bruce1266df82008-11-03 15:44:01 -060012{
Kumar Gala7649a592009-03-31 23:02:38 -050013 /* dummy function so common/cmd_mp.c will build
14 * should be implemented in the future, when cpu_release()
15 * is supported. Be aware there may be a similiar bug
16 * as exists on MPC85xx w/its PIC having a timing window
17 * associated to resetting the core */
18 return 1;
19}
Becky Bruce1266df82008-11-03 15:44:01 -060020
Kumar Gala7649a592009-03-31 23:02:38 -050021int cpu_status(int nr)
22{
23 /* dummy function so common/cmd_mp.c will build */
24 return 0;
25}
26
27int cpu_release(int nr, int argc, char *argv[])
28{
29 /* dummy function so common/cmd_mp.c will build
30 * should be implemented in the future */
31 return 1;
32}
33
34u32 determine_mp_bootpg(void)
35{
Becky Bruce1266df82008-11-03 15:44:01 -060036 /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
37 if ((u64)gd->ram_size > 0xfffff000)
Kumar Gala7649a592009-03-31 23:02:38 -050038 return (0xfff00000);
39
40 return (gd->ram_size - (1024 * 1024));
41}
42
43void cpu_mp_lmb_reserve(struct lmb *lmb)
44{
45 u32 bootpg = determine_mp_bootpg();
Becky Bruce1266df82008-11-03 15:44:01 -060046
47 /* tell u-boot we stole a page */
48 lmb_reserve(lmb, bootpg, 4096);
49}
50
51/*
52 * Copy the code for other cpus to execute into an
53 * aligned location accessible via BPTR
54 */
55void setup_mp(void)
56{
57 extern ulong __secondary_start_page;
58 ulong fixup = (ulong)&__secondary_start_page;
Kumar Gala7649a592009-03-31 23:02:38 -050059 u32 bootpg = determine_mp_bootpg();
Becky Bruce1266df82008-11-03 15:44:01 -060060 u32 bootpg_va;
61
Becky Bruce1266df82008-11-03 15:44:01 -060062 if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) {
63 /* We're not covered by the DDR mapping, set up BAT */
64 write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K |
65 BATU_VS | BATU_VP,
66 bootpg | BATL_PP_RW | BATL_MEMCOHERENCE);
67 bootpg_va = CONFIG_SYS_SCRATCH_VA;
68 } else {
69 bootpg_va = bootpg;
70 }
71
72 memcpy((void *)bootpg_va, (void *)fixup, 4096);
73 flush_cache(bootpg_va, 4096);
74
75 /* remove the temporary BAT mapping */
76 if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE)
77 write_bat(DBAT7, 0, 0);
78
79 /* If the physical location of bootpg is not at fff00000, set BPTR */
80 if (bootpg != 0xfff00000)
81 out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 |
82 (bootpg >> 12));
83}