platsmp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/smp.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/page.h>
  16. #include <asm/smp_scu.h>
  17. #include <asm/mach/map.h>
  18. #include "common.h"
  19. #include "hardware.h"
  20. #define SCU_STANDBY_ENABLE (1 << 5)
  21. u32 g_diag_reg;
  22. static void __iomem *scu_base;
  23. static struct map_desc scu_io_desc __initdata = {
  24. /* .virtual and .pfn are run-time assigned */
  25. .length = SZ_4K,
  26. .type = MT_DEVICE,
  27. };
  28. void __init imx_scu_map_io(void)
  29. {
  30. unsigned long base;
  31. /* Get SCU base */
  32. asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
  33. scu_io_desc.virtual = IMX_IO_P2V(base);
  34. scu_io_desc.pfn = __phys_to_pfn(base);
  35. iotable_init(&scu_io_desc, 1);
  36. scu_base = IMX_IO_ADDRESS(base);
  37. }
  38. void imx_scu_standby_enable(void)
  39. {
  40. u32 val = readl_relaxed(scu_base);
  41. val |= SCU_STANDBY_ENABLE;
  42. writel_relaxed(val, scu_base);
  43. }
  44. static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
  45. {
  46. imx_set_cpu_jump(cpu, v7_secondary_startup);
  47. imx_enable_cpu(cpu, true);
  48. return 0;
  49. }
  50. /*
  51. * Initialise the CPU possible map early - this describes the CPUs
  52. * which may be present or become present in the system.
  53. */
  54. static void __init imx_smp_init_cpus(void)
  55. {
  56. int i, ncores;
  57. ncores = scu_get_core_count(scu_base);
  58. for (i = ncores; i < NR_CPUS; i++)
  59. set_cpu_possible(i, false);
  60. }
  61. void imx_smp_prepare(void)
  62. {
  63. scu_enable(scu_base);
  64. }
  65. static void __init imx_smp_prepare_cpus(unsigned int max_cpus)
  66. {
  67. imx_smp_prepare();
  68. /*
  69. * The diagnostic register holds the errata bits. Mostly bootloader
  70. * does not bring up secondary cores, so that when errata bits are set
  71. * in bootloader, they are set only for boot cpu. But on a SMP
  72. * configuration, it should be equally done on every single core.
  73. * Read the register from boot cpu here, and will replicate it into
  74. * secondary cores when booting them.
  75. */
  76. asm("mrc p15, 0, %0, c15, c0, 1" : "=r" (g_diag_reg) : : "cc");
  77. __cpuc_flush_dcache_area(&g_diag_reg, sizeof(g_diag_reg));
  78. outer_clean_range(__pa(&g_diag_reg), __pa(&g_diag_reg + 1));
  79. }
  80. struct smp_operations imx_smp_ops __initdata = {
  81. .smp_init_cpus = imx_smp_init_cpus,
  82. .smp_prepare_cpus = imx_smp_prepare_cpus,
  83. .smp_boot_secondary = imx_boot_secondary,
  84. #ifdef CONFIG_HOTPLUG_CPU
  85. .cpu_die = imx_cpu_die,
  86. .cpu_kill = imx_cpu_kill,
  87. #endif
  88. };