platsmp.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2010-2011 Calxeda, Inc.
  3. * Based on platsmp.c, Copyright (C) 2002 ARM Ltd.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <linux/init.h>
  18. #include <linux/smp.h>
  19. #include <linux/io.h>
  20. #include <asm/smp_scu.h>
  21. #include <asm/hardware/gic.h>
  22. #include "core.h"
  23. extern void secondary_startup(void);
  24. static void __cpuinit highbank_secondary_init(unsigned int cpu)
  25. {
  26. gic_secondary_init(0);
  27. }
  28. static int __cpuinit highbank_boot_secondary(unsigned int cpu, struct task_struct *idle)
  29. {
  30. gic_raise_softirq(cpumask_of(cpu), 0);
  31. return 0;
  32. }
  33. /*
  34. * Initialise the CPU possible map early - this describes the CPUs
  35. * which may be present or become present in the system.
  36. */
  37. static void __init highbank_smp_init_cpus(void)
  38. {
  39. unsigned int i, ncores = 4;
  40. /* sanity check */
  41. if (ncores > NR_CPUS) {
  42. printk(KERN_WARNING
  43. "highbank: no. of cores (%d) greater than configured "
  44. "maximum of %d - clipping\n",
  45. ncores, NR_CPUS);
  46. ncores = NR_CPUS;
  47. }
  48. for (i = 0; i < ncores; i++)
  49. set_cpu_possible(i, true);
  50. set_smp_cross_call(gic_raise_softirq);
  51. }
  52. static void __init highbank_smp_prepare_cpus(unsigned int max_cpus)
  53. {
  54. int i;
  55. if (scu_base_addr)
  56. scu_enable(scu_base_addr);
  57. /*
  58. * Write the address of secondary startup into the jump table
  59. * The cores are in wfi and wait until they receive a soft interrupt
  60. * and a non-zero value to jump to. Then the secondary CPU branches
  61. * to this address.
  62. */
  63. for (i = 1; i < max_cpus; i++)
  64. highbank_set_cpu_jump(i, secondary_startup);
  65. }
  66. struct smp_operations highbank_smp_ops __initdata = {
  67. .smp_init_cpus = highbank_smp_init_cpus,
  68. .smp_prepare_cpus = highbank_smp_prepare_cpus,
  69. .smp_secondary_init = highbank_secondary_init,
  70. .smp_boot_secondary = highbank_boot_secondary,
  71. #ifdef CONFIG_HOTPLUG_CPU
  72. .cpu_die = highbank_cpu_die,
  73. #endif
  74. };