platsmp-dt.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2015 Linus Walleij
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/smp.h>
  9. #include <linux/io.h>
  10. #include <linux/of.h>
  11. #include <linux/of_address.h>
  12. #include <linux/regmap.h>
  13. #include <linux/mfd/syscon.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/smp_plat.h>
  16. #include <asm/smp_scu.h>
  17. #include <plat/platsmp.h>
  18. #include "hotplug.h"
  19. #define REALVIEW_SYS_FLAGSSET_OFFSET 0x30
  20. static const struct of_device_id realview_scu_match[] = {
  21. { .compatible = "arm,arm11mp-scu", },
  22. { .compatible = "arm,cortex-a9-scu", },
  23. { .compatible = "arm,cortex-a5-scu", },
  24. { }
  25. };
  26. static const struct of_device_id realview_syscon_match[] = {
  27. { .compatible = "arm,core-module-integrator", },
  28. { .compatible = "arm,realview-eb-syscon", },
  29. { .compatible = "arm,realview-pb11mp-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. if (IS_ERR(map)) {
  65. pr_err("PLATSMP: No syscon regmap\n");
  66. return;
  67. }
  68. /* Put the boot address in this magic register */
  69. regmap_write(map, REALVIEW_SYS_FLAGSSET_OFFSET,
  70. virt_to_phys(versatile_secondary_startup));
  71. }
  72. static const struct smp_operations realview_dt_smp_ops __initconst = {
  73. .smp_prepare_cpus = realview_smp_prepare_cpus,
  74. .smp_secondary_init = versatile_secondary_init,
  75. .smp_boot_secondary = versatile_boot_secondary,
  76. #ifdef CONFIG_HOTPLUG_CPU
  77. .cpu_die = realview_cpu_die,
  78. #endif
  79. };
  80. CPU_METHOD_OF_DECLARE(realview_smp, "arm,realview-smp", &realview_dt_smp_ops);