malta_smp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Malta Platform-specific hooks for SMP operation
  3. */
  4. #include <linux/kernel.h>
  5. #include <linux/sched.h>
  6. #include <linux/cpumask.h>
  7. #include <linux/interrupt.h>
  8. #include <asm/atomic.h>
  9. #include <asm/cpu.h>
  10. #include <asm/processor.h>
  11. #include <asm/system.h>
  12. #include <asm/hardirq.h>
  13. #include <asm/mmu_context.h>
  14. #include <asm/smp.h>
  15. #ifdef CONFIG_MIPS_MT_SMTC
  16. #include <asm/smtc_ipi.h>
  17. #endif /* CONFIG_MIPS_MT_SMTC */
  18. /* VPE/SMP Prototype implements platform interfaces directly */
  19. #if !defined(CONFIG_MIPS_MT_SMP)
  20. /*
  21. * Cause the specified action to be performed on a targeted "CPU"
  22. */
  23. void core_send_ipi(int cpu, unsigned int action)
  24. {
  25. /* "CPU" may be TC of same VPE, VPE of same CPU, or different CPU */
  26. #ifdef CONFIG_MIPS_MT_SMTC
  27. smtc_send_ipi(cpu, LINUX_SMP_IPI, action);
  28. #endif /* CONFIG_MIPS_MT_SMTC */
  29. }
  30. /*
  31. * Detect available CPUs/VPEs/TCs and populate phys_cpu_present_map
  32. */
  33. void __init prom_build_cpu_map(void)
  34. {
  35. int nextslot;
  36. /*
  37. * As of November, 2004, MIPSsim only simulates one core
  38. * at a time. However, that core may be a MIPS MT core
  39. * with multiple virtual processors and thread contexts.
  40. */
  41. if (read_c0_config3() & (1<<2)) {
  42. nextslot = mipsmt_build_cpu_map(1);
  43. }
  44. }
  45. /*
  46. * Platform "CPU" startup hook
  47. */
  48. void prom_boot_secondary(int cpu, struct task_struct *idle)
  49. {
  50. #ifdef CONFIG_MIPS_MT_SMTC
  51. smtc_boot_secondary(cpu, idle);
  52. #endif /* CONFIG_MIPS_MT_SMTC */
  53. }
  54. /*
  55. * Post-config but pre-boot cleanup entry point
  56. */
  57. void prom_init_secondary(void)
  58. {
  59. #ifdef CONFIG_MIPS_MT_SMTC
  60. void smtc_init_secondary(void);
  61. int myvpe;
  62. /* Don't enable Malta I/O interrupts (IP2) for secondary VPEs */
  63. myvpe = read_c0_tcbind() & TCBIND_CURVPE;
  64. if (myvpe != 0) {
  65. /* Ideally, this should be done only once per VPE, but... */
  66. clear_c0_status(STATUSF_IP2);
  67. set_c0_status(STATUSF_IP0 | STATUSF_IP1 | STATUSF_IP3
  68. | STATUSF_IP4 | STATUSF_IP5 | STATUSF_IP6
  69. | STATUSF_IP7);
  70. }
  71. smtc_init_secondary();
  72. #endif /* CONFIG_MIPS_MT_SMTC */
  73. }
  74. /*
  75. * Platform SMP pre-initialization
  76. *
  77. * As noted above, we can assume a single CPU for now
  78. * but it may be multithreaded.
  79. */
  80. void plat_smp_setup(void)
  81. {
  82. if (read_c0_config3() & (1<<2))
  83. mipsmt_build_cpu_map(0);
  84. }
  85. void __init plat_prepare_cpus(unsigned int max_cpus)
  86. {
  87. if (read_c0_config3() & (1<<2))
  88. mipsmt_prepare_cpus();
  89. }
  90. /*
  91. * SMP initialization finalization entry point
  92. */
  93. void prom_smp_finish(void)
  94. {
  95. #ifdef CONFIG_MIPS_MT_SMTC
  96. smtc_smp_finish();
  97. #endif /* CONFIG_MIPS_MT_SMTC */
  98. }
  99. /*
  100. * Hook for after all CPUs are online
  101. */
  102. void prom_cpus_done(void)
  103. {
  104. }
  105. #endif /* CONFIG_MIPS32R2_MT_SMP */