amiints.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Amiga 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/init.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/errno.h>
  11. #ifdef CONFIG_GENERIC_HARDIRQS
  12. #include <linux/irq.h>
  13. #endif
  14. #include <asm/irq.h>
  15. #include <asm/traps.h>
  16. #include <asm/amigahw.h>
  17. #include <asm/amigaints.h>
  18. #include <asm/amipcmcia.h>
  19. /*
  20. * Enable/disable a particular machine specific interrupt source.
  21. * Note that this may affect other interrupts in case of a shared interrupt.
  22. * This function should only be called for a _very_ short time to change some
  23. * internal data, that may not be changed by the interrupt at the same time.
  24. */
  25. static void amiga_irq_enable(struct irq_data *data)
  26. {
  27. amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER));
  28. }
  29. static void amiga_irq_disable(struct irq_data *data)
  30. {
  31. amiga_custom.intena = 1 << (data->irq - IRQ_USER);
  32. }
  33. static struct irq_chip amiga_irq_chip = {
  34. .name = "amiga",
  35. .irq_enable = amiga_irq_enable,
  36. .irq_disable = amiga_irq_disable,
  37. };
  38. /*
  39. * The builtin Amiga hardware interrupt handlers.
  40. */
  41. static irqreturn_t ami_int1(int irq, void *dev_id)
  42. {
  43. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  44. /* if serial transmit buffer empty, interrupt */
  45. if (ints & IF_TBE) {
  46. amiga_custom.intreq = IF_TBE;
  47. generic_handle_irq(IRQ_AMIGA_TBE);
  48. }
  49. /* if floppy disk transfer complete, interrupt */
  50. if (ints & IF_DSKBLK) {
  51. amiga_custom.intreq = IF_DSKBLK;
  52. generic_handle_irq(IRQ_AMIGA_DSKBLK);
  53. }
  54. /* if software interrupt set, interrupt */
  55. if (ints & IF_SOFT) {
  56. amiga_custom.intreq = IF_SOFT;
  57. generic_handle_irq(IRQ_AMIGA_SOFT);
  58. }
  59. return IRQ_HANDLED;
  60. }
  61. static irqreturn_t ami_int3(int irq, void *dev_id)
  62. {
  63. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  64. /* if a blitter interrupt */
  65. if (ints & IF_BLIT) {
  66. amiga_custom.intreq = IF_BLIT;
  67. generic_handle_irq(IRQ_AMIGA_BLIT);
  68. }
  69. /* if a copper interrupt */
  70. if (ints & IF_COPER) {
  71. amiga_custom.intreq = IF_COPER;
  72. generic_handle_irq(IRQ_AMIGA_COPPER);
  73. }
  74. /* if a vertical blank interrupt */
  75. if (ints & IF_VERTB) {
  76. amiga_custom.intreq = IF_VERTB;
  77. generic_handle_irq(IRQ_AMIGA_VERTB);
  78. }
  79. return IRQ_HANDLED;
  80. }
  81. static irqreturn_t ami_int4(int irq, void *dev_id)
  82. {
  83. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  84. /* if audio 0 interrupt */
  85. if (ints & IF_AUD0) {
  86. amiga_custom.intreq = IF_AUD0;
  87. generic_handle_irq(IRQ_AMIGA_AUD0);
  88. }
  89. /* if audio 1 interrupt */
  90. if (ints & IF_AUD1) {
  91. amiga_custom.intreq = IF_AUD1;
  92. generic_handle_irq(IRQ_AMIGA_AUD1);
  93. }
  94. /* if audio 2 interrupt */
  95. if (ints & IF_AUD2) {
  96. amiga_custom.intreq = IF_AUD2;
  97. generic_handle_irq(IRQ_AMIGA_AUD2);
  98. }
  99. /* if audio 3 interrupt */
  100. if (ints & IF_AUD3) {
  101. amiga_custom.intreq = IF_AUD3;
  102. generic_handle_irq(IRQ_AMIGA_AUD3);
  103. }
  104. return IRQ_HANDLED;
  105. }
  106. static irqreturn_t ami_int5(int irq, void *dev_id)
  107. {
  108. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  109. /* if serial receive buffer full interrupt */
  110. if (ints & IF_RBF) {
  111. /* acknowledge of IF_RBF must be done by the serial interrupt */
  112. generic_handle_irq(IRQ_AMIGA_RBF);
  113. }
  114. /* if a disk sync interrupt */
  115. if (ints & IF_DSKSYN) {
  116. amiga_custom.intreq = IF_DSKSYN;
  117. generic_handle_irq(IRQ_AMIGA_DSKSYN);
  118. }
  119. return IRQ_HANDLED;
  120. }
  121. /*
  122. * void amiga_init_IRQ(void)
  123. *
  124. * Parameters: None
  125. *
  126. * Returns: Nothing
  127. *
  128. * This function should be called during kernel startup to initialize
  129. * the amiga IRQ handling routines.
  130. */
  131. void __init amiga_init_IRQ(void)
  132. {
  133. if (request_irq(IRQ_AUTO_1, ami_int1, 0, "int1", NULL))
  134. pr_err("Couldn't register int%d\n", 1);
  135. if (request_irq(IRQ_AUTO_3, ami_int3, 0, "int3", NULL))
  136. pr_err("Couldn't register int%d\n", 3);
  137. if (request_irq(IRQ_AUTO_4, ami_int4, 0, "int4", NULL))
  138. pr_err("Couldn't register int%d\n", 4);
  139. if (request_irq(IRQ_AUTO_5, ami_int5, 0, "int5", NULL))
  140. pr_err("Couldn't register int%d\n", 5);
  141. m68k_setup_irq_controller(&amiga_irq_chip, handle_simple_irq, IRQ_USER,
  142. AMI_STD_IRQS);
  143. /* turn off PCMCIA interrupts */
  144. if (AMIGAHW_PRESENT(PCMCIA))
  145. gayle.inten = GAYLE_IRQ_IDE;
  146. /* turn off all interrupts and enable the master interrupt bit */
  147. amiga_custom.intena = 0x7fff;
  148. amiga_custom.intreq = 0x7fff;
  149. amiga_custom.intena = IF_SETCLR | IF_INTEN;
  150. cia_init_IRQ(&ciaa_base);
  151. cia_init_IRQ(&ciab_base);
  152. }