irq-rm9000.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (C) 2003 Ralf Baechle
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * Handler for RM9000 extended interrupts. These are a non-standard
  10. * feature so we handle them separately from standard interrupts.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <asm/irq_cpu.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/system.h>
  19. static int irq_base;
  20. static inline void unmask_rm9k_irq(unsigned int irq)
  21. {
  22. set_c0_intcontrol(0x1000 << (irq - irq_base));
  23. }
  24. static inline void mask_rm9k_irq(unsigned int irq)
  25. {
  26. clear_c0_intcontrol(0x1000 << (irq - irq_base));
  27. }
  28. static inline void rm9k_cpu_irq_enable(unsigned int irq)
  29. {
  30. unsigned long flags;
  31. local_irq_save(flags);
  32. unmask_rm9k_irq(irq);
  33. local_irq_restore(flags);
  34. }
  35. static void rm9k_cpu_irq_disable(unsigned int irq)
  36. {
  37. unsigned long flags;
  38. local_irq_save(flags);
  39. mask_rm9k_irq(irq);
  40. local_irq_restore(flags);
  41. }
  42. static unsigned int rm9k_cpu_irq_startup(unsigned int irq)
  43. {
  44. rm9k_cpu_irq_enable(irq);
  45. return 0;
  46. }
  47. #define rm9k_cpu_irq_shutdown rm9k_cpu_irq_disable
  48. /*
  49. * Performance counter interrupts are global on all processors.
  50. */
  51. static void local_rm9k_perfcounter_irq_startup(void *args)
  52. {
  53. unsigned int irq = (unsigned int) args;
  54. rm9k_cpu_irq_enable(irq);
  55. }
  56. static unsigned int rm9k_perfcounter_irq_startup(unsigned int irq)
  57. {
  58. on_each_cpu(local_rm9k_perfcounter_irq_startup, (void *) irq, 0, 1);
  59. return 0;
  60. }
  61. static void local_rm9k_perfcounter_irq_shutdown(void *args)
  62. {
  63. unsigned int irq = (unsigned int) args;
  64. unsigned long flags;
  65. local_irq_save(flags);
  66. mask_rm9k_irq(irq);
  67. local_irq_restore(flags);
  68. }
  69. static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
  70. {
  71. on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1);
  72. }
  73. /*
  74. * While we ack the interrupt interrupts are disabled and thus we don't need
  75. * to deal with concurrency issues. Same for rm9k_cpu_irq_end.
  76. */
  77. static void rm9k_cpu_irq_ack(unsigned int irq)
  78. {
  79. mask_rm9k_irq(irq);
  80. }
  81. static void rm9k_cpu_irq_end(unsigned int irq)
  82. {
  83. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  84. unmask_rm9k_irq(irq);
  85. }
  86. static hw_irq_controller rm9k_irq_controller = {
  87. "RM9000",
  88. rm9k_cpu_irq_startup,
  89. rm9k_cpu_irq_shutdown,
  90. rm9k_cpu_irq_enable,
  91. rm9k_cpu_irq_disable,
  92. rm9k_cpu_irq_ack,
  93. rm9k_cpu_irq_end,
  94. };
  95. static hw_irq_controller rm9k_perfcounter_irq = {
  96. "RM9000",
  97. rm9k_perfcounter_irq_startup,
  98. rm9k_perfcounter_irq_shutdown,
  99. rm9k_cpu_irq_enable,
  100. rm9k_cpu_irq_disable,
  101. rm9k_cpu_irq_ack,
  102. rm9k_cpu_irq_end,
  103. };
  104. unsigned int rm9000_perfcount_irq;
  105. EXPORT_SYMBOL(rm9000_perfcount_irq);
  106. void __init rm9k_cpu_irq_init(int base)
  107. {
  108. int i;
  109. clear_c0_intcontrol(0x0000f000); /* Mask all */
  110. for (i = base; i < base + 4; i++) {
  111. irq_desc[i].status = IRQ_DISABLED;
  112. irq_desc[i].action = NULL;
  113. irq_desc[i].depth = 1;
  114. irq_desc[i].handler = &rm9k_irq_controller;
  115. }
  116. rm9000_perfcount_irq = base + 1;
  117. irq_desc[rm9000_perfcount_irq].handler = &rm9k_perfcounter_irq;
  118. irq_base = base;
  119. }