platsmp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #define is_sh73a0() (machine_is_ag5evm() || machine_is_kota2() || \
  24. of_machine_is_compatible("renesas,sh73a0"))
  25. #define is_r8a7779() machine_is_marzen()
  26. static unsigned int __init shmobile_smp_get_core_count(void)
  27. {
  28. if (is_sh73a0())
  29. return sh73a0_get_core_count();
  30. if (is_r8a7779())
  31. return r8a7779_get_core_count();
  32. return 1;
  33. }
  34. static void __init shmobile_smp_prepare_cpus(void)
  35. {
  36. if (is_sh73a0())
  37. sh73a0_smp_prepare_cpus();
  38. if (is_r8a7779())
  39. r8a7779_smp_prepare_cpus();
  40. }
  41. int shmobile_platform_cpu_kill(unsigned int cpu)
  42. {
  43. if (is_r8a7779())
  44. return r8a7779_platform_cpu_kill(cpu);
  45. return 1;
  46. }
  47. void __cpuinit platform_secondary_init(unsigned int cpu)
  48. {
  49. trace_hardirqs_off();
  50. if (is_sh73a0())
  51. sh73a0_secondary_init(cpu);
  52. if (is_r8a7779())
  53. r8a7779_secondary_init(cpu);
  54. }
  55. int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  56. {
  57. if (is_sh73a0())
  58. return sh73a0_boot_secondary(cpu);
  59. if (is_r8a7779())
  60. return r8a7779_boot_secondary(cpu);
  61. return -ENOSYS;
  62. }
  63. void __init smp_init_cpus(void)
  64. {
  65. unsigned int ncores = shmobile_smp_get_core_count();
  66. unsigned int i;
  67. if (ncores > nr_cpu_ids) {
  68. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  69. ncores, nr_cpu_ids);
  70. ncores = nr_cpu_ids;
  71. }
  72. for (i = 0; i < ncores; i++)
  73. set_cpu_possible(i, true);
  74. set_smp_cross_call(gic_raise_softirq);
  75. }
  76. void __init platform_smp_prepare_cpus(unsigned int max_cpus)
  77. {
  78. shmobile_smp_prepare_cpus();
  79. }