platsmp.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * SMP support for R-Mobile / SH-Mobile
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2011 Paul Mundt
  6. *
  7. * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/errno.h>
  15. #include <linux/delay.h>
  16. #include <linux/device.h>
  17. #include <linux/smp.h>
  18. #include <linux/io.h>
  19. #include <asm/hardware/gic.h>
  20. #include <asm/mach-types.h>
  21. #include <mach/common.h>
  22. #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2())
  23. #define is_r8a7779() machine_is_marzen()
  24. static unsigned int __init shmobile_smp_get_core_count(void)
  25. {
  26. if (is_sh73a0())
  27. return sh73a0_get_core_count();
  28. if (is_r8a7779())
  29. return r8a7779_get_core_count();
  30. return 1;
  31. }
  32. static void __init shmobile_smp_prepare_cpus(void)
  33. {
  34. if (is_sh73a0())
  35. sh73a0_smp_prepare_cpus();
  36. if (is_r8a7779())
  37. r8a7779_smp_prepare_cpus();
  38. }
  39. int shmobile_platform_cpu_kill(unsigned int cpu)
  40. {
  41. if (is_r8a7779())
  42. return r8a7779_platform_cpu_kill(cpu);
  43. return 1;
  44. }
  45. void __cpuinit platform_secondary_init(unsigned int cpu)
  46. {
  47. trace_hardirqs_off();
  48. if (is_sh73a0())
  49. sh73a0_secondary_init(cpu);
  50. if (is_r8a7779())
  51. r8a7779_secondary_init(cpu);
  52. }
  53. int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  54. {
  55. if (is_sh73a0())
  56. return sh73a0_boot_secondary(cpu);
  57. if (is_r8a7779())
  58. return r8a7779_boot_secondary(cpu);
  59. return -ENOSYS;
  60. }
  61. void __init smp_init_cpus(void)
  62. {
  63. unsigned int ncores = shmobile_smp_get_core_count();
  64. unsigned int i;
  65. if (ncores > nr_cpu_ids) {
  66. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  67. ncores, nr_cpu_ids);
  68. ncores = nr_cpu_ids;
  69. }
  70. for (i = 0; i < ncores; i++)
  71. set_cpu_possible(i, true);
  72. set_smp_cross_call(gic_raise_softirq);
  73. }
  74. void __init platform_smp_prepare_cpus(unsigned int max_cpus)
  75. {
  76. shmobile_smp_prepare_cpus();
  77. }