mp.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. DECLARE_GLOBAL_DATA_PTR;
  9. #if (CONFIG_NUM_CPUS > 1)
  10. void cpu_mp_lmb_reserve(struct lmb *lmb)
  11. {
  12. u32 bootpg;
  13. /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
  14. if ((u64)gd->ram_size > 0xfffff000)
  15. bootpg = 0xfff00000;
  16. else
  17. bootpg = gd->ram_size - (1024 * 1024);
  18. /* tell u-boot we stole a page */
  19. lmb_reserve(lmb, bootpg, 4096);
  20. }
  21. /*
  22. * Copy the code for other cpus to execute into an
  23. * aligned location accessible via BPTR
  24. */
  25. void setup_mp(void)
  26. {
  27. extern ulong __secondary_start_page;
  28. ulong fixup = (ulong)&__secondary_start_page;
  29. u32 bootpg;
  30. u32 bootpg_va;
  31. /*
  32. * If we have 4G or more of memory, put the boot page at 4Gb-1M.
  33. * Otherwise, put it at the very end of RAM.
  34. */
  35. if (gd->ram_size > 0xfffff000)
  36. bootpg = 0xfff00000;
  37. else
  38. bootpg = gd->ram_size - (1024 * 1024);
  39. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) {
  40. /* We're not covered by the DDR mapping, set up BAT */
  41. write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K |
  42. BATU_VS | BATU_VP,
  43. bootpg | BATL_PP_RW | BATL_MEMCOHERENCE);
  44. bootpg_va = CONFIG_SYS_SCRATCH_VA;
  45. } else {
  46. bootpg_va = bootpg;
  47. }
  48. memcpy((void *)bootpg_va, (void *)fixup, 4096);
  49. flush_cache(bootpg_va, 4096);
  50. /* remove the temporary BAT mapping */
  51. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE)
  52. write_bat(DBAT7, 0, 0);
  53. /* If the physical location of bootpg is not at fff00000, set BPTR */
  54. if (bootpg != 0xfff00000)
  55. out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 |
  56. (bootpg >> 12));
  57. }
  58. #endif