platsmp.c 2.5 KB

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