platsmp-vexpress.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2002 ARM Ltd.
  4. * All Rights Reserved
  5. */
  6. #include <linux/init.h>
  7. #include <linux/errno.h>
  8. #include <linux/smp.h>
  9. #include <linux/io.h>
  10. #include <linux/of_address.h>
  11. #include <linux/vexpress.h>
  12. #include <asm/mcpm.h>
  13. #include <asm/smp_scu.h>
  14. #include <asm/mach/map.h>
  15. #include "platsmp.h"
  16. #include "vexpress.h"
  17. bool __init vexpress_smp_init_ops(void)
  18. {
  19. #ifdef CONFIG_MCPM
  20. int cpu;
  21. struct device_node *cpu_node, *cci_node;
  22. /*
  23. * The best way to detect a multi-cluster configuration
  24. * is to detect if the kernel can take over CCI ports
  25. * control. Loop over possible CPUs and check if CCI
  26. * port control is available.
  27. * Override the default vexpress_smp_ops if so.
  28. */
  29. for_each_possible_cpu(cpu) {
  30. bool available;
  31. cpu_node = of_get_cpu_node(cpu, NULL);
  32. if (WARN(!cpu_node, "Missing cpu device node!"))
  33. return false;
  34. cci_node = of_parse_phandle(cpu_node, "cci-control-port", 0);
  35. available = cci_node && of_device_is_available(cci_node);
  36. of_node_put(cci_node);
  37. of_node_put(cpu_node);
  38. if (!available)
  39. return false;
  40. }
  41. mcpm_smp_set_ops();
  42. return true;
  43. #else
  44. return false;
  45. #endif
  46. }
  47. static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {
  48. { .compatible = "arm,cortex-a5-scu", },
  49. { .compatible = "arm,cortex-a9-scu", },
  50. {}
  51. };
  52. static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus)
  53. {
  54. struct device_node *scu = of_find_matching_node(NULL,
  55. vexpress_smp_dt_scu_match);
  56. if (scu)
  57. scu_enable(of_iomap(scu, 0));
  58. /*
  59. * Write the address of secondary startup into the
  60. * system-wide flags register. The boot monitor waits
  61. * until it receives a soft interrupt, and then the
  62. * secondary CPU branches to this address.
  63. */
  64. vexpress_flags_set(__pa_symbol(versatile_secondary_startup));
  65. }
  66. #ifdef CONFIG_HOTPLUG_CPU
  67. static void vexpress_cpu_die(unsigned int cpu)
  68. {
  69. versatile_immitation_cpu_die(cpu, 0x40);
  70. }
  71. #endif
  72. const struct smp_operations vexpress_smp_dt_ops __initconst = {
  73. .smp_prepare_cpus = vexpress_smp_dt_prepare_cpus,
  74. .smp_secondary_init = versatile_secondary_init,
  75. .smp_boot_secondary = versatile_boot_secondary,
  76. #ifdef CONFIG_HOTPLUG_CPU
  77. .cpu_die = vexpress_cpu_die,
  78. #endif
  79. };