platsmp-realview.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2015 Linus Walleij
  4. */
  5. #include <linux/smp.h>
  6. #include <linux/io.h>
  7. #include <linux/of.h>
  8. #include <linux/of_address.h>
  9. #include <linux/regmap.h>
  10. #include <linux/mfd/syscon.h>
  11. #include <asm/cacheflush.h>
  12. #include <asm/smp_plat.h>
  13. #include <asm/smp_scu.h>
  14. #include "platsmp.h"
  15. #define REALVIEW_SYS_FLAGSSET_OFFSET 0x30
  16. static const struct of_device_id realview_scu_match[] = {
  17. { .compatible = "arm,arm11mp-scu", },
  18. { .compatible = "arm,cortex-a9-scu", },
  19. { .compatible = "arm,cortex-a5-scu", },
  20. { }
  21. };
  22. static const struct of_device_id realview_syscon_match[] = {
  23. { .compatible = "arm,core-module-integrator", },
  24. { .compatible = "arm,realview-eb-syscon", },
  25. { .compatible = "arm,realview-pb11mp-syscon", },
  26. { .compatible = "arm,realview-pbx-syscon", },
  27. { },
  28. };
  29. static void __init realview_smp_prepare_cpus(unsigned int max_cpus)
  30. {
  31. struct device_node *np;
  32. void __iomem *scu_base;
  33. struct regmap *map;
  34. unsigned int ncores;
  35. int i;
  36. np = of_find_matching_node(NULL, realview_scu_match);
  37. if (!np) {
  38. pr_err("PLATSMP: No SCU base address\n");
  39. return;
  40. }
  41. scu_base = of_iomap(np, 0);
  42. of_node_put(np);
  43. if (!scu_base) {
  44. pr_err("PLATSMP: No SCU remap\n");
  45. return;
  46. }
  47. scu_enable(scu_base);
  48. ncores = scu_get_core_count(scu_base);
  49. pr_info("SCU: %d cores detected\n", ncores);
  50. for (i = 0; i < ncores; i++)
  51. set_cpu_possible(i, true);
  52. iounmap(scu_base);
  53. /* The syscon contains the magic SMP start address registers */
  54. np = of_find_matching_node(NULL, realview_syscon_match);
  55. if (!np) {
  56. pr_err("PLATSMP: No syscon match\n");
  57. return;
  58. }
  59. map = syscon_node_to_regmap(np);
  60. if (IS_ERR(map)) {
  61. pr_err("PLATSMP: No syscon regmap\n");
  62. return;
  63. }
  64. /* Put the boot address in this magic register */
  65. regmap_write(map, REALVIEW_SYS_FLAGSSET_OFFSET,
  66. __pa_symbol(versatile_secondary_startup));
  67. }
  68. #ifdef CONFIG_HOTPLUG_CPU
  69. static void realview_cpu_die(unsigned int cpu)
  70. {
  71. return versatile_immitation_cpu_die(cpu, 0x20);
  72. }
  73. #endif
  74. static const struct smp_operations realview_dt_smp_ops __initconst = {
  75. .smp_prepare_cpus = realview_smp_prepare_cpus,
  76. .smp_secondary_init = versatile_secondary_init,
  77. .smp_boot_secondary = versatile_boot_secondary,
  78. #ifdef CONFIG_HOTPLUG_CPU
  79. .cpu_die = realview_cpu_die,
  80. #endif
  81. };
  82. CPU_METHOD_OF_DECLARE(realview_smp, "arm,realview-smp", &realview_dt_smp_ops);