platsmp.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/of_address.h>
  14. #include <linux/of.h>
  15. #include <linux/smp.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/page.h>
  18. #include <asm/smp_scu.h>
  19. #include <asm/mach/map.h>
  20. #include "common.h"
  21. #include "hardware.h"
  22. u32 g_diag_reg;
  23. static void __iomem *scu_base;
  24. static struct map_desc scu_io_desc __initdata = {
  25. /* .virtual and .pfn are run-time assigned */
  26. .length = SZ_4K,
  27. .type = MT_DEVICE,
  28. };
  29. void __init imx_scu_map_io(void)
  30. {
  31. unsigned long base;
  32. /* Get SCU base */
  33. asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
  34. scu_io_desc.virtual = IMX_IO_P2V(base);
  35. scu_io_desc.pfn = __phys_to_pfn(base);
  36. iotable_init(&scu_io_desc, 1);
  37. scu_base = IMX_IO_ADDRESS(base);
  38. }
  39. static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
  40. {
  41. imx_set_cpu_jump(cpu, v7_secondary_startup);
  42. imx_enable_cpu(cpu, true);
  43. return 0;
  44. }
  45. /*
  46. * Initialise the CPU possible map early - this describes the CPUs
  47. * which may be present or become present in the system.
  48. */
  49. static void __init imx_smp_init_cpus(void)
  50. {
  51. int i, ncores;
  52. ncores = scu_get_core_count(scu_base);
  53. for (i = ncores; i < NR_CPUS; i++)
  54. set_cpu_possible(i, false);
  55. }
  56. void imx_smp_prepare(void)
  57. {
  58. scu_enable(scu_base);
  59. }
  60. static void __init imx_smp_prepare_cpus(unsigned int max_cpus)
  61. {
  62. imx_smp_prepare();
  63. /*
  64. * The diagnostic register holds the errata bits. Mostly bootloader
  65. * does not bring up secondary cores, so that when errata bits are set
  66. * in bootloader, they are set only for boot cpu. But on a SMP
  67. * configuration, it should be equally done on every single core.
  68. * Read the register from boot cpu here, and will replicate it into
  69. * secondary cores when booting them.
  70. */
  71. asm("mrc p15, 0, %0, c15, c0, 1" : "=r" (g_diag_reg) : : "cc");
  72. sync_cache_w(&g_diag_reg);
  73. }
  74. const struct smp_operations imx_smp_ops __initconst = {
  75. .smp_init_cpus = imx_smp_init_cpus,
  76. .smp_prepare_cpus = imx_smp_prepare_cpus,
  77. .smp_boot_secondary = imx_boot_secondary,
  78. #ifdef CONFIG_HOTPLUG_CPU
  79. .cpu_die = imx_cpu_die,
  80. .cpu_kill = imx_cpu_kill,
  81. #endif
  82. };
  83. #define DCFG_CCSR_SCRATCHRW1 0x200
  84. static int ls1021a_boot_secondary(unsigned int cpu, struct task_struct *idle)
  85. {
  86. arch_send_wakeup_ipi_mask(cpumask_of(cpu));
  87. return 0;
  88. }
  89. static void __init ls1021a_smp_prepare_cpus(unsigned int max_cpus)
  90. {
  91. struct device_node *np;
  92. void __iomem *dcfg_base;
  93. unsigned long paddr;
  94. np = of_find_compatible_node(NULL, NULL, "fsl,ls1021a-dcfg");
  95. dcfg_base = of_iomap(np, 0);
  96. BUG_ON(!dcfg_base);
  97. paddr = virt_to_phys(secondary_startup);
  98. writel_relaxed(cpu_to_be32(paddr), dcfg_base + DCFG_CCSR_SCRATCHRW1);
  99. iounmap(dcfg_base);
  100. }
  101. const struct smp_operations ls1021a_smp_ops __initconst = {
  102. .smp_prepare_cpus = ls1021a_smp_prepare_cpus,
  103. .smp_boot_secondary = ls1021a_boot_secondary,
  104. };