]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/mpc86xx/mp.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / cpu / mpc86xx / mp.c
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 <asm/mp.h>
8
9 DECLARE_GLOBAL_DATA_PTR;
10
11 int cpu_reset(int nr)
12 {
13         /* 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 }
20
21 int cpu_status(int nr)
22 {
23         /* dummy function so common/cmd_mp.c will build */
24         return 0;
25 }
26
27 int 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
34 u32 determine_mp_bootpg(void)
35 {
36         /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
37         if ((u64)gd->ram_size > 0xfffff000)
38                 return (0xfff00000);
39
40         return (gd->ram_size - (1024 * 1024));
41 }
42
43 void cpu_mp_lmb_reserve(struct lmb *lmb)
44 {
45         u32 bootpg = determine_mp_bootpg();
46
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  */
55 void setup_mp(void)
56 {
57         extern ulong __secondary_start_page;
58         ulong fixup = (ulong)&__secondary_start_page;
59         u32 bootpg = determine_mp_bootpg();
60         u32 bootpg_va;
61
62         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 }