mp.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright 2008-2010 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/processor.h>
  24. #include <asm/mmu.h>
  25. #include <ioports.h>
  26. #include <lmb.h>
  27. #include <asm/io.h>
  28. #include <asm/mp.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. int cpu_reset(int nr)
  31. {
  32. /* dummy function so common/cmd_mp.c will build
  33. * should be implemented in the future, when cpu_release()
  34. * is supported. Be aware there may be a similiar bug
  35. * as exists on MPC85xx w/its PIC having a timing window
  36. * associated to resetting the core */
  37. return 1;
  38. }
  39. int cpu_status(int nr)
  40. {
  41. /* dummy function so common/cmd_mp.c will build */
  42. return 0;
  43. }
  44. int cpu_disable(int nr)
  45. {
  46. volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
  47. volatile ccsr_gur_t *gur = &immap->im_gur;
  48. switch (nr) {
  49. case 0:
  50. setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU0);
  51. break;
  52. case 1:
  53. setbits_be32(&gur->devdisr, MPC86xx_DEVDISR_CPU1);
  54. break;
  55. default:
  56. printf("Invalid cpu number for disable %d\n", nr);
  57. return 1;
  58. }
  59. return 0;
  60. }
  61. int is_core_disabled(int nr) {
  62. immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
  63. ccsr_gur_t *gur = &immap->im_gur;
  64. u32 devdisr = in_be32(&gur->devdisr);
  65. switch (nr) {
  66. case 0:
  67. return (devdisr & MPC86xx_DEVDISR_CPU0);
  68. case 1:
  69. return (devdisr & MPC86xx_DEVDISR_CPU1);
  70. default:
  71. printf("Invalid cpu number for disable %d\n", nr);
  72. }
  73. return 0;
  74. }
  75. int cpu_release(int nr, int argc, char * const argv[])
  76. {
  77. /* dummy function so common/cmd_mp.c will build
  78. * should be implemented in the future */
  79. return 1;
  80. }
  81. u32 determine_mp_bootpg(void)
  82. {
  83. /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
  84. if ((u64)gd->ram_size > 0xfffff000)
  85. return (0xfff00000);
  86. return (gd->ram_size - (1024 * 1024));
  87. }
  88. void cpu_mp_lmb_reserve(struct lmb *lmb)
  89. {
  90. u32 bootpg = determine_mp_bootpg();
  91. /* tell u-boot we stole a page */
  92. lmb_reserve(lmb, bootpg, 4096);
  93. }
  94. /*
  95. * Copy the code for other cpus to execute into an
  96. * aligned location accessible via BPTR
  97. */
  98. void setup_mp(void)
  99. {
  100. extern ulong __secondary_start_page;
  101. ulong fixup = (ulong)&__secondary_start_page;
  102. u32 bootpg = determine_mp_bootpg();
  103. u32 bootpg_va;
  104. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE) {
  105. /* We're not covered by the DDR mapping, set up BAT */
  106. write_bat(DBAT7, CONFIG_SYS_SCRATCH_VA | BATU_BL_128K |
  107. BATU_VS | BATU_VP,
  108. bootpg | BATL_PP_RW | BATL_MEMCOHERENCE);
  109. bootpg_va = CONFIG_SYS_SCRATCH_VA;
  110. } else {
  111. bootpg_va = bootpg;
  112. }
  113. memcpy((void *)bootpg_va, (void *)fixup, 4096);
  114. flush_cache(bootpg_va, 4096);
  115. /* remove the temporary BAT mapping */
  116. if (bootpg >= CONFIG_SYS_MAX_DDR_BAT_SIZE)
  117. write_bat(DBAT7, 0, 0);
  118. /* If the physical location of bootpg is not at fff00000, set BPTR */
  119. if (bootpg != 0xfff00000)
  120. out_be32((uint *)(CONFIG_SYS_CCSRBAR + 0x20), 0x80000000 |
  121. (bootpg >> 12));
  122. }