malta_smtc.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Malta Platform-specific hooks for SMP operation
  3. */
  4. #include <linux/irq.h>
  5. #include <linux/init.h>
  6. #include <asm/mipsregs.h>
  7. #include <asm/mipsmtregs.h>
  8. #include <asm/smtc.h>
  9. #include <asm/smtc_ipi.h>
  10. /* VPE/SMP Prototype implements platform interfaces directly */
  11. /*
  12. * Cause the specified action to be performed on a targeted "CPU"
  13. */
  14. void core_send_ipi(int cpu, unsigned int action)
  15. {
  16. /* "CPU" may be TC of same VPE, VPE of same CPU, or different CPU */
  17. smtc_send_ipi(cpu, LINUX_SMP_IPI, action);
  18. }
  19. /*
  20. * Platform "CPU" startup hook
  21. */
  22. void __cpuinit prom_boot_secondary(int cpu, struct task_struct *idle)
  23. {
  24. smtc_boot_secondary(cpu, idle);
  25. }
  26. /*
  27. * Post-config but pre-boot cleanup entry point
  28. */
  29. void __cpuinit prom_init_secondary(void)
  30. {
  31. void smtc_init_secondary(void);
  32. int myvpe;
  33. /* Don't enable Malta I/O interrupts (IP2) for secondary VPEs */
  34. myvpe = read_c0_tcbind() & TCBIND_CURVPE;
  35. if (myvpe != 0) {
  36. /* Ideally, this should be done only once per VPE, but... */
  37. clear_c0_status(ST0_IM);
  38. set_c0_status((0x100 << cp0_compare_irq)
  39. | (0x100 << MIPS_CPU_IPI_IRQ));
  40. if (cp0_perfcount_irq >= 0)
  41. set_c0_status(0x100 << cp0_perfcount_irq);
  42. }
  43. smtc_init_secondary();
  44. }
  45. /*
  46. * Platform SMP pre-initialization
  47. *
  48. * As noted above, we can assume a single CPU for now
  49. * but it may be multithreaded.
  50. */
  51. void __cpuinit plat_smp_setup(void)
  52. {
  53. if (read_c0_config3() & (1<<2))
  54. mipsmt_build_cpu_map(0);
  55. }
  56. void __init plat_prepare_cpus(unsigned int max_cpus)
  57. {
  58. if (read_c0_config3() & (1<<2))
  59. mipsmt_prepare_cpus();
  60. }
  61. /*
  62. * SMP initialization finalization entry point
  63. */
  64. void __cpuinit prom_smp_finish(void)
  65. {
  66. smtc_smp_finish();
  67. }
  68. /*
  69. * Hook for after all CPUs are online
  70. */
  71. void prom_cpus_done(void)
  72. {
  73. }
  74. #ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
  75. /*
  76. * IRQ affinity hook
  77. */
  78. void plat_set_irq_affinity(unsigned int irq, cpumask_t affinity)
  79. {
  80. cpumask_t tmask = affinity;
  81. int cpu = 0;
  82. void smtc_set_irq_affinity(unsigned int irq, cpumask_t aff);
  83. /*
  84. * On the legacy Malta development board, all I/O interrupts
  85. * are routed through the 8259 and combined in a single signal
  86. * to the CPU daughterboard, and on the CoreFPGA2/3 34K models,
  87. * that signal is brought to IP2 of both VPEs. To avoid racing
  88. * concurrent interrupt service events, IP2 is enabled only on
  89. * one VPE, by convention VPE0. So long as no bits are ever
  90. * cleared in the affinity mask, there will never be any
  91. * interrupt forwarding. But as soon as a program or operator
  92. * sets affinity for one of the related IRQs, we need to make
  93. * sure that we don't ever try to forward across the VPE boundry,
  94. * at least not until we engineer a system where the interrupt
  95. * _ack() or _end() function can somehow know that it corresponds
  96. * to an interrupt taken on another VPE, and perform the appropriate
  97. * restoration of Status.IM state using MFTR/MTTR instead of the
  98. * normal local behavior. We also ensure that no attempt will
  99. * be made to forward to an offline "CPU".
  100. */
  101. for_each_cpu_mask(cpu, affinity) {
  102. if ((cpu_data[cpu].vpe_id != 0) || !cpu_online(cpu))
  103. cpu_clear(cpu, tmask);
  104. }
  105. irq_desc[irq].affinity = tmask;
  106. if (cpus_empty(tmask))
  107. /*
  108. * We could restore a default mask here, but the
  109. * runtime code can anyway deal with the null set
  110. */
  111. printk(KERN_WARNING
  112. "IRQ affinity leaves no legal CPU for IRQ %d\n", irq);
  113. /* Do any generic SMTC IRQ affinity setup */
  114. smtc_set_irq_affinity(irq, tmask);
  115. }
  116. #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */