platsmp-realview.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /*
  18. * The ARM11MP SCU compatible is only provided as fallback for
  19. * old RealView EB Cortex-A9 device trees that were using this
  20. * compatible by mistake.
  21. */
  22. { .compatible = "arm,arm11mp-scu", },
  23. { .compatible = "arm,cortex-a9-scu", },
  24. { .compatible = "arm,cortex-a5-scu", },
  25. { }
  26. };
  27. static const struct of_device_id realview_syscon_match[] = {
  28. { .compatible = "arm,core-module-integrator", },
  29. { .compatible = "arm,realview-eb-syscon", },
  30. { .compatible = "arm,realview-pbx-syscon", },
  31. { },
  32. };
  33. static void __init realview_smp_prepare_cpus(unsigned int max_cpus)
  34. {
  35. struct device_node *np;
  36. void __iomem *scu_base;
  37. struct regmap *map;
  38. unsigned int ncores;
  39. int i;
  40. np = of_find_matching_node(NULL, realview_scu_match);
  41. if (!np) {
  42. pr_err("PLATSMP: No SCU base address\n");
  43. return;
  44. }
  45. scu_base = of_iomap(np, 0);
  46. of_node_put(np);
  47. if (!scu_base) {
  48. pr_err("PLATSMP: No SCU remap\n");
  49. return;
  50. }
  51. scu_enable(scu_base);
  52. ncores = scu_get_core_count(scu_base);
  53. pr_info("SCU: %d cores detected\n", ncores);
  54. for (i = 0; i < ncores; i++)
  55. set_cpu_possible(i, true);
  56. iounmap(scu_base);
  57. /* The syscon contains the magic SMP start address registers */
  58. np = of_find_matching_node(NULL, realview_syscon_match);
  59. if (!np) {
  60. pr_err("PLATSMP: No syscon match\n");
  61. return;
  62. }
  63. map = syscon_node_to_regmap(np);
  64. of_node_put(np);
  65. if (IS_ERR(map)) {
  66. pr_err("PLATSMP: No syscon regmap\n");
  67. return;
  68. }
  69. /* Put the boot address in this magic register */
  70. regmap_write(map, REALVIEW_SYS_FLAGSSET_OFFSET,
  71. __pa_symbol(versatile_secondary_startup));
  72. }
  73. #ifdef CONFIG_HOTPLUG_CPU
  74. static void realview_cpu_die(unsigned int cpu)
  75. {
  76. return versatile_immitation_cpu_die(cpu, 0x20);
  77. }
  78. #endif
  79. static const struct smp_operations realview_dt_smp_ops __initconst = {
  80. .smp_prepare_cpus = realview_smp_prepare_cpus,
  81. .smp_secondary_init = versatile_secondary_init,
  82. .smp_boot_secondary = versatile_boot_secondary,
  83. #ifdef CONFIG_HOTPLUG_CPU
  84. .cpu_die = realview_cpu_die,
  85. #endif
  86. };
  87. CPU_METHOD_OF_DECLARE(realview_smp, "arm,realview-smp", &realview_dt_smp_ops);