platsmp-a9.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Symmetric Multi Processing (SMP) support for Marvell EBU Cortex-A9
  3. * based SOCs (Armada 375/38x).
  4. *
  5. * Copyright (C) 2014 Marvell
  6. *
  7. * Gregory CLEMENT <gregory.clement@free-electrons.com>
  8. * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <linux/of.h>
  17. #include <linux/smp.h>
  18. #include <linux/mbus.h>
  19. #include <asm/smp_scu.h>
  20. #include <asm/smp_plat.h>
  21. #include "common.h"
  22. #include "pmsu.h"
  23. extern void mvebu_cortex_a9_secondary_startup(void);
  24. static int mvebu_cortex_a9_boot_secondary(unsigned int cpu,
  25. struct task_struct *idle)
  26. {
  27. int ret, hw_cpu;
  28. pr_info("Booting CPU %d\n", cpu);
  29. /*
  30. * Write the address of secondary startup into the system-wide
  31. * flags register. The boot monitor waits until it receives a
  32. * soft interrupt, and then the secondary CPU branches to this
  33. * address.
  34. */
  35. hw_cpu = cpu_logical_map(cpu);
  36. if (of_machine_is_compatible("marvell,armada375"))
  37. mvebu_system_controller_set_cpu_boot_addr(mvebu_cortex_a9_secondary_startup);
  38. else
  39. mvebu_pmsu_set_cpu_boot_addr(hw_cpu, mvebu_cortex_a9_secondary_startup);
  40. smp_wmb();
  41. /*
  42. * Doing this before deasserting the CPUs is needed to wake up CPUs
  43. * in the offline state after using CPU hotplug.
  44. */
  45. arch_send_wakeup_ipi_mask(cpumask_of(cpu));
  46. ret = mvebu_cpu_reset_deassert(hw_cpu);
  47. if (ret) {
  48. pr_err("Could not start the secondary CPU: %d\n", ret);
  49. return ret;
  50. }
  51. return 0;
  52. }
  53. /*
  54. * When a CPU is brought back online, either through CPU hotplug, or
  55. * because of the boot of a kexec'ed kernel, the PMSU configuration
  56. * for this CPU might be in the deep idle state, preventing this CPU
  57. * from receiving interrupts. Here, we therefore take out the current
  58. * CPU from this state, which was entered by armada_38x_cpu_die()
  59. * below.
  60. */
  61. static void armada_38x_secondary_init(unsigned int cpu)
  62. {
  63. mvebu_v7_pmsu_idle_exit();
  64. }
  65. #ifdef CONFIG_HOTPLUG_CPU
  66. static void armada_38x_cpu_die(unsigned int cpu)
  67. {
  68. /*
  69. * CPU hotplug is implemented by putting offline CPUs into the
  70. * deep idle sleep state.
  71. */
  72. armada_38x_do_cpu_suspend(true);
  73. }
  74. /*
  75. * We need a dummy function, so that platform_can_cpu_hotplug() knows
  76. * we support CPU hotplug. However, the function does not need to do
  77. * anything, because CPUs going offline can enter the deep idle state
  78. * by themselves, without any help from a still alive CPU.
  79. */
  80. static int armada_38x_cpu_kill(unsigned int cpu)
  81. {
  82. return 1;
  83. }
  84. #endif
  85. static const struct smp_operations mvebu_cortex_a9_smp_ops __initconst = {
  86. .smp_boot_secondary = mvebu_cortex_a9_boot_secondary,
  87. };
  88. static const struct smp_operations armada_38x_smp_ops __initconst = {
  89. .smp_boot_secondary = mvebu_cortex_a9_boot_secondary,
  90. .smp_secondary_init = armada_38x_secondary_init,
  91. #ifdef CONFIG_HOTPLUG_CPU
  92. .cpu_die = armada_38x_cpu_die,
  93. .cpu_kill = armada_38x_cpu_kill,
  94. #endif
  95. };
  96. CPU_METHOD_OF_DECLARE(mvebu_armada_375_smp, "marvell,armada-375-smp",
  97. &mvebu_cortex_a9_smp_ops);
  98. CPU_METHOD_OF_DECLARE(mvebu_armada_380_smp, "marvell,armada-380-smp",
  99. &armada_38x_smp_ops);
  100. CPU_METHOD_OF_DECLARE(mvebu_armada_390_smp, "marvell,armada-390-smp",
  101. &armada_38x_smp_ops);