sun3ints.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. xtime_update(1);
  60. update_process_times(user_mode(get_irq_regs()));
  61. if (!(kstat_cpu(0).irqs[irq] % 20))
  62. sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]);
  63. return IRQ_HANDLED;
  64. }
  65. static irqreturn_t sun3_vec255(int irq, void *dev_id)
  66. {
  67. // intersil_clear();
  68. return IRQ_HANDLED;
  69. }
  70. static void sun3_inthandle(unsigned int irq, struct pt_regs *fp)
  71. {
  72. *sun3_intreg &= ~(1 << irq);
  73. __m68k_handle_int(irq, fp);
  74. }
  75. static struct irq_controller sun3_irq_controller = {
  76. .name = "sun3",
  77. .lock = __SPIN_LOCK_UNLOCKED(sun3_irq_controller.lock),
  78. .startup = m68k_irq_startup,
  79. .shutdown = m68k_irq_shutdown,
  80. .enable = sun3_enable_irq,
  81. .disable = sun3_disable_irq,
  82. };
  83. void __init sun3_init_IRQ(void)
  84. {
  85. *sun3_intreg = 1;
  86. m68k_setup_auto_interrupt(sun3_inthandle);
  87. m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7);
  88. m68k_setup_user_interrupt(VEC_USER, 128, NULL);
  89. if (request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL))
  90. pr_err("Couldn't register %s interrupt\n", "int5");
  91. if (request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL))
  92. pr_err("Couldn't register %s interrupt\n", "int7");
  93. if (request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL))
  94. pr_err("Couldn't register %s interrupt\n", "vec255");
  95. }