mp.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2008-2010 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <asm/processor.h>
  7. #include <asm/mmu.h>
  8. #include <ioports.h>
  9. #include <lmb.h>
  10. #include <asm/io.h>
  11. #include <asm/mp.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. int cpu_reset(u32 nr)
  14. {
  15. /* dummy function so common/cmd_mp.c will build
  16. * should be implemented in the future, when cpu_release()
  17. * is supported. Be aware there may be a similiar bug
  18. * as exists on MPC85xx w/its PIC having a timing window
  19. * associated to resetting the core */
  20. return 1;
  21. }
  22. int cpu_status(u32 nr)
  23. {
  24. /* dummy function so common/cmd_mp.c will build */
  25. return 0;
  26. }
  27. int cpu_disable(u32 nr)
  28. {
  29. volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
  30. volatile ccsr_gur_t *gur = &immap->im_gur;
  31. switch (nr) {
  32. case 0:
  33. setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU0);
  34. break;
  35. case 1:
  36. setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU1);
  37. break;
  38. default:
  39. printf("Invalid cpu number for disable %d\n", nr);
  40. return 1;
  41. }
  42. return 0;
  43. }
  44. int is_core_disabled(int nr) {
  45. immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
  46. ccsr_gur_t *gur = &immap->im_gur;
  47. u32 devdisr = in_be32(&gur->devdisr);
  48. switch (nr) {
  49. case 0:
  50. return (devdisr & MPC86xx_DEVDISR_CPU0);
  51. case 1:
  52. return (devdisr & MPC86xx_DEVDISR_CPU1);
  53. default:
  54. printf("Invalid cpu number for disable %d\n", nr);
  55. }
  56. return 0;
  57. }
  58. int cpu_release(u32 nr, int argc, char * const argv[])
  59. {
  60. /* dummy function so common/cmd_mp.c will build
  61. * should be implemented in the future */
  62. return 1;
  63. }
  64. u32 determine_mp_bootpg(unsigned int *pagesize)
  65. {
  66. if (pagesize)
  67. *pagesize = 4096;
  68. /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
  69. if ((u64)gd->ram_size > 0xfffff000)
  70. return (0xfff00000);
  71. return (gd->ram_size - (1024 * 1024));
  72. }
  73. void cpu_mp_lmb_reserve(struct lmb *lmb)
  74. {
  75. u32 bootpg = determine_mp_bootpg(NULL);
  76. /* tell u-boot we stole a page */
  77. lmb_reserve(lmb, bootpg, 4096);
  78. }
  79. /*
  80. * Copy the code for other cpus to execute into an
  81. * aligned location accessible via BPTR
  82. */
  83. void setup_mp(void)
  84. {
  85. extern ulong __secondary_start_page;
  86. ulong fixup = (ulong)&__secondary_start_page;
  87. u32 bootpg = determine_mp_bootpg(NULL);
  88. u32 bootpg_va;
  89. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) {
  90. /* We're not covered by the DDR mapping, set up BAT */
  91. write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K |
  92. BATU_VS | BATU_VP,
  93. bootpg | BATL_PP_RW | BATL_MEMCOHERENCE);
  94. bootpg_va = CONFIG_SYS_SCRATCH_VA;
  95. } else {
  96. bootpg_va = bootpg;
  97. }
  98. memcpy((void *)bootpg_va, (void *)fixup, 4096);
  99. flush_cache(bootpg_va, 4096);
  100. /* remove the temporary BAT mapping */
  101. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE)
  102. write_bat(DBAT7, 0, 0);
  103. /* If the physical location of bootpg is not at fff00000, set BPTR */
  104. if (bootpg != 0xfff00000)
  105. out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 |
  106. (bootpg >> 12));
  107. }