smp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * SMP Support for A2 platforms
  3. *
  4. * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. */
  12. #include <linux/cpumask.h>
  13. #include <linux/init.h>
  14. #include <linux/kernel.h>
  15. #include <linux/of.h>
  16. #include <linux/smp.h>
  17. #include <asm/dbell.h>
  18. #include <asm/machdep.h>
  19. #include <asm/xics.h>
  20. #include "ics.h"
  21. #include "wsp.h"
  22. static void __devinit smp_a2_setup_cpu(int cpu)
  23. {
  24. doorbell_setup_this_cpu();
  25. if (cpu != boot_cpuid)
  26. xics_setup_cpu();
  27. }
  28. int __devinit smp_a2_kick_cpu(int nr)
  29. {
  30. const char *enable_method;
  31. struct device_node *np;
  32. int thr_idx;
  33. if (nr < 0 || nr >= NR_CPUS)
  34. return -ENOENT;
  35. np = of_get_cpu_node(nr, &thr_idx);
  36. if (!np)
  37. return -ENODEV;
  38. enable_method = of_get_property(np, "enable-method", NULL);
  39. pr_devel("CPU%d has enable-method: \"%s\"\n", nr, enable_method);
  40. if (!enable_method) {
  41. printk(KERN_ERR "CPU%d has no enable-method\n", nr);
  42. return -ENOENT;
  43. } else if (strcmp(enable_method, "ibm,a2-scom") == 0) {
  44. if (a2_scom_startup_cpu(nr, thr_idx, np))
  45. return -1;
  46. } else {
  47. printk(KERN_ERR "CPU%d: Don't understand enable-method \"%s\"\n",
  48. nr, enable_method);
  49. return -EINVAL;
  50. }
  51. /*
  52. * The processor is currently spinning, waiting for the
  53. * cpu_start field to become non-zero After we set cpu_start,
  54. * the processor will continue on to secondary_start
  55. */
  56. paca[nr].cpu_start = 1;
  57. return 0;
  58. }
  59. static int __init smp_a2_probe(void)
  60. {
  61. return num_possible_cpus();
  62. }
  63. static struct smp_ops_t a2_smp_ops = {
  64. .message_pass = NULL, /* Use smp_muxed_ipi_message_pass */
  65. .cause_ipi = doorbell_cause_ipi,
  66. .probe = smp_a2_probe,
  67. .kick_cpu = smp_a2_kick_cpu,
  68. .setup_cpu = smp_a2_setup_cpu,
  69. };
  70. void __init a2_setup_smp(void)
  71. {
  72. smp_ops = &a2_smp_ops;
  73. }