sun3ints.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * linux/arch/m68k/sun3/sun3ints.c -- Sun-3(x) Linux interrupt handling code
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file COPYING in the main directory of this archive
  6. * for more details.
  7. */
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/sched.h>
  11. #include <linux/kernel_stat.h>
  12. #include <linux/interrupt.h>
  13. #include <asm/segment.h>
  14. #include <asm/intersil.h>
  15. #include <asm/oplib.h>
  16. #include <asm/sun3ints.h>
  17. #include <asm/irq_regs.h>
  18. #include <linux/seq_file.h>
  19. extern void sun3_leds (unsigned char);
  20. void sun3_disable_interrupts(void)
  21. {
  22. sun3_disable_irq(0);
  23. }
  24. void sun3_enable_interrupts(void)
  25. {
  26. sun3_enable_irq(0);
  27. }
  28. static int led_pattern[8] = {
  29. ~(0x80), ~(0x01),
  30. ~(0x40), ~(0x02),
  31. ~(0x20), ~(0x04),
  32. ~(0x10), ~(0x08)
  33. };
  34. volatile unsigned char* sun3_intreg;
  35. void sun3_enable_irq(unsigned int irq)
  36. {
  37. *sun3_intreg |= (1 << irq);
  38. }
  39. void sun3_disable_irq(unsigned int irq)
  40. {
  41. *sun3_intreg &= ~(1 << irq);
  42. }
  43. static irqreturn_t sun3_int7(int irq, void *dev_id)
  44. {
  45. *sun3_intreg |= (1 << irq);
  46. if (!(kstat_cpu(0).irqs[irq] % 2000))
  47. sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 16000) / 2000]);
  48. return IRQ_HANDLED;
  49. }
  50. static irqreturn_t sun3_int5(int irq, void *dev_id)
  51. {
  52. #ifdef CONFIG_SUN3
  53. intersil_clear();
  54. #endif
  55. *sun3_intreg |= (1 << irq);
  56. #ifdef CONFIG_SUN3
  57. intersil_clear();
  58. #endif
  59. do_timer(1);
  60. #ifndef CONFIG_SMP
  61. update_process_times(user_mode(get_irq_regs()));
  62. #endif
  63. if (!(kstat_cpu(0).irqs[irq] % 20))
  64. sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]);
  65. return IRQ_HANDLED;
  66. }
  67. static irqreturn_t sun3_vec255(int irq, void *dev_id)
  68. {
  69. // intersil_clear();
  70. return IRQ_HANDLED;
  71. }
  72. static void sun3_inthandle(unsigned int irq, struct pt_regs *fp)
  73. {
  74. *sun3_intreg &= ~(1 << irq);
  75. __m68k_handle_int(irq, fp);
  76. }
  77. static struct irq_controller sun3_irq_controller = {
  78. .name = "sun3",
  79. .lock = __SPIN_LOCK_UNLOCKED(sun3_irq_controller.lock),
  80. .startup = m68k_irq_startup,
  81. .shutdown = m68k_irq_shutdown,
  82. .enable = sun3_enable_irq,
  83. .disable = sun3_disable_irq,
  84. };
  85. void __init sun3_init_IRQ(void)
  86. {
  87. *sun3_intreg = 1;
  88. m68k_setup_auto_interrupt(sun3_inthandle);
  89. m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7);
  90. m68k_setup_user_interrupt(VEC_USER, 128, NULL);
  91. if (request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL))
  92. pr_err("Couldn't register %s interrupt\n", "int5");
  93. if (request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL))
  94. pr_err("Couldn't register %s interrupt\n", "int7");
  95. if (request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL))
  96. pr_err("Couldn't register %s interrupt\n", "vec255");
  97. }