smp_spin_table.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Spin Table SMP initialisation
  3. *
  4. * Copyright (C) 2013 ARM Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/of.h>
  20. #include <linux/smp.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/cpu_ops.h>
  23. static phys_addr_t cpu_release_addr[NR_CPUS];
  24. static int smp_spin_table_cpu_init(struct device_node *dn, unsigned int cpu)
  25. {
  26. /*
  27. * Determine the address from which the CPU is polling.
  28. */
  29. if (of_property_read_u64(dn, "cpu-release-addr",
  30. &cpu_release_addr[cpu])) {
  31. pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
  32. cpu);
  33. return -1;
  34. }
  35. return 0;
  36. }
  37. static int smp_spin_table_cpu_prepare(unsigned int cpu)
  38. {
  39. void **release_addr;
  40. if (!cpu_release_addr[cpu])
  41. return -ENODEV;
  42. release_addr = __va(cpu_release_addr[cpu]);
  43. release_addr[0] = (void *)__pa(secondary_holding_pen);
  44. __flush_dcache_area(release_addr, sizeof(release_addr[0]));
  45. /*
  46. * Send an event to wake up the secondary CPU.
  47. */
  48. sev();
  49. return 0;
  50. }
  51. const struct cpu_operations smp_spin_table_ops = {
  52. .name = "spin-table",
  53. .cpu_init = smp_spin_table_cpu_init,
  54. .cpu_prepare = smp_spin_table_cpu_prepare,
  55. };