platsmp.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 <linux/of.h>
  20. #include <asm/hardware/gic.h>
  21. #include <asm/mach-types.h>
  22. #include <mach/common.h>
  23. #include <mach/emev2.h>
  24. #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
  25. of_machine_is_compatible("renesas,sh73a0"))
  26. #define is_r8a7779() machine_is_marzen()
  27. #ifdef CONFIG_ARCH_EMEV2
  28. #define is_emev2() of_machine_is_compatible("renesas,emev2")
  29. #else
  30. #define is_emev2() (0)
  31. #endif
  32. static unsigned int __init shmobile_smp_get_core_count(void)
  33. {
  34. if (is_sh73a0())
  35. return sh73a0_get_core_count();
  36. if (is_r8a7779())
  37. return r8a7779_get_core_count();
  38. if (is_emev2())
  39. return emev2_get_core_count();
  40. return 1;
  41. }
  42. static void __init shmobile_smp_prepare_cpus(void)
  43. {
  44. if (is_sh73a0())
  45. sh73a0_smp_prepare_cpus();
  46. if (is_r8a7779())
  47. r8a7779_smp_prepare_cpus();
  48. if (is_emev2())
  49. emev2_smp_prepare_cpus();
  50. }
  51. int shmobile_platform_cpu_kill(unsigned int cpu)
  52. {
  53. if (is_r8a7779())
  54. return r8a7779_platform_cpu_kill(cpu);
  55. if (is_emev2())
  56. return emev2_platform_cpu_kill(cpu);
  57. return 1;
  58. }
  59. void __cpuinit platform_secondary_init(unsigned int cpu)
  60. {
  61. trace_hardirqs_off();
  62. if (is_sh73a0())
  63. sh73a0_secondary_init(cpu);
  64. if (is_r8a7779())
  65. r8a7779_secondary_init(cpu);
  66. if (is_emev2())
  67. emev2_secondary_init(cpu);
  68. }
  69. int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  70. {
  71. if (is_sh73a0())
  72. return sh73a0_boot_secondary(cpu);
  73. if (is_r8a7779())
  74. return r8a7779_boot_secondary(cpu);
  75. if (is_emev2())
  76. return emev2_boot_secondary(cpu);
  77. return -ENOSYS;
  78. }
  79. void __init smp_init_cpus(void)
  80. {
  81. unsigned int ncores = shmobile_smp_get_core_count();
  82. unsigned int i;
  83. if (ncores > nr_cpu_ids) {
  84. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  85. ncores, nr_cpu_ids);
  86. ncores = nr_cpu_ids;
  87. }
  88. for (i = 0; i < ncores; i++)
  89. set_cpu_possible(i, true);
  90. set_smp_cross_call(gic_raise_softirq);
  91. }
  92. void __init platform_smp_prepare_cpus(unsigned int max_cpus)
  93. {
  94. shmobile_smp_prepare_cpus();
  95. }