platsmp-a9.c 3.2 KB

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