amiints.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * linux/arch/m68k/amiga/amiints.c -- 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. * 11/07/96: rewritten interrupt handling, irq lists are exists now only for
  9. * this sources where it makes sense (VERTB/PORTS/EXTER) and you must
  10. * be careful that dev_id for this sources is unique since this the
  11. * only possibility to distinguish between different handlers for
  12. * free_irq. irq lists also have different irq flags:
  13. * - IRQ_FLG_FAST: handler is inserted at top of list (after other
  14. * fast handlers)
  15. * - IRQ_FLG_SLOW: handler is inserted at bottom of list and before
  16. * they're executed irq level is set to the previous
  17. * one, but handlers don't need to be reentrant, if
  18. * reentrance occurred, slow handlers will be just
  19. * called again.
  20. * The whole interrupt handling for CIAs is moved to cia.c
  21. * /Roman Zippel
  22. *
  23. * 07/08/99: rewamp of the interrupt handling - we now have two types of
  24. * interrupts, normal and fast handlers, fast handlers being
  25. * marked with IRQF_DISABLED and runs with all other interrupts
  26. * disabled. Normal interrupts disable their own source but
  27. * run with all other interrupt sources enabled.
  28. * PORTS and EXTER interrupts are always shared even if the
  29. * drivers do not explicitly mark this when calling
  30. * request_irq which they really should do.
  31. * This is similar to the way interrupts are handled on all
  32. * other architectures and makes a ton of sense besides
  33. * having the advantage of making it easier to share
  34. * drivers.
  35. * /Jes
  36. */
  37. #include <linux/init.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/errno.h>
  40. #include <asm/irq.h>
  41. #include <asm/traps.h>
  42. #include <asm/amigahw.h>
  43. #include <asm/amigaints.h>
  44. #include <asm/amipcmcia.h>
  45. static void amiga_enable_irq(unsigned int irq);
  46. static void amiga_disable_irq(unsigned int irq);
  47. static irqreturn_t ami_int1(int irq, void *dev_id);
  48. static irqreturn_t ami_int3(int irq, void *dev_id);
  49. static irqreturn_t ami_int4(int irq, void *dev_id);
  50. static irqreturn_t ami_int5(int irq, void *dev_id);
  51. static struct irq_controller amiga_irq_controller = {
  52. .name = "amiga",
  53. .lock = __SPIN_LOCK_UNLOCKED(amiga_irq_controller.lock),
  54. .enable = amiga_enable_irq,
  55. .disable = amiga_disable_irq,
  56. };
  57. /*
  58. * void amiga_init_IRQ(void)
  59. *
  60. * Parameters: None
  61. *
  62. * Returns: Nothing
  63. *
  64. * This function should be called during kernel startup to initialize
  65. * the amiga IRQ handling routines.
  66. */
  67. void __init amiga_init_IRQ(void)
  68. {
  69. if (request_irq(IRQ_AUTO_1, ami_int1, 0, "int1", NULL))
  70. pr_err("Couldn't register int%d\n", 1);
  71. if (request_irq(IRQ_AUTO_3, ami_int3, 0, "int3", NULL))
  72. pr_err("Couldn't register int%d\n", 3);
  73. if (request_irq(IRQ_AUTO_4, ami_int4, 0, "int4", NULL))
  74. pr_err("Couldn't register int%d\n", 4);
  75. if (request_irq(IRQ_AUTO_5, ami_int5, 0, "int5", NULL))
  76. pr_err("Couldn't register int%d\n", 5);
  77. m68k_setup_irq_controller(&amiga_irq_controller, IRQ_USER, AMI_STD_IRQS);
  78. /* turn off PCMCIA interrupts */
  79. if (AMIGAHW_PRESENT(PCMCIA))
  80. gayle.inten = GAYLE_IRQ_IDE;
  81. /* turn off all interrupts and enable the master interrupt bit */
  82. amiga_custom.intena = 0x7fff;
  83. amiga_custom.intreq = 0x7fff;
  84. amiga_custom.intena = IF_SETCLR | IF_INTEN;
  85. cia_init_IRQ(&ciaa_base);
  86. cia_init_IRQ(&ciab_base);
  87. }
  88. /*
  89. * Enable/disable a particular machine specific interrupt source.
  90. * Note that this may affect other interrupts in case of a shared interrupt.
  91. * This function should only be called for a _very_ short time to change some
  92. * internal data, that may not be changed by the interrupt at the same time.
  93. */
  94. static void amiga_enable_irq(unsigned int irq)
  95. {
  96. amiga_custom.intena = IF_SETCLR | (1 << (irq - IRQ_USER));
  97. }
  98. static void amiga_disable_irq(unsigned int irq)
  99. {
  100. amiga_custom.intena = 1 << (irq - IRQ_USER);
  101. }
  102. /*
  103. * The builtin Amiga hardware interrupt handlers.
  104. */
  105. static irqreturn_t ami_int1(int irq, void *dev_id)
  106. {
  107. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  108. /* if serial transmit buffer empty, interrupt */
  109. if (ints & IF_TBE) {
  110. amiga_custom.intreq = IF_TBE;
  111. m68k_handle_int(IRQ_AMIGA_TBE);
  112. }
  113. /* if floppy disk transfer complete, interrupt */
  114. if (ints & IF_DSKBLK) {
  115. amiga_custom.intreq = IF_DSKBLK;
  116. m68k_handle_int(IRQ_AMIGA_DSKBLK);
  117. }
  118. /* if software interrupt set, interrupt */
  119. if (ints & IF_SOFT) {
  120. amiga_custom.intreq = IF_SOFT;
  121. m68k_handle_int(IRQ_AMIGA_SOFT);
  122. }
  123. return IRQ_HANDLED;
  124. }
  125. static irqreturn_t ami_int3(int irq, void *dev_id)
  126. {
  127. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  128. /* if a blitter interrupt */
  129. if (ints & IF_BLIT) {
  130. amiga_custom.intreq = IF_BLIT;
  131. m68k_handle_int(IRQ_AMIGA_BLIT);
  132. }
  133. /* if a copper interrupt */
  134. if (ints & IF_COPER) {
  135. amiga_custom.intreq = IF_COPER;
  136. m68k_handle_int(IRQ_AMIGA_COPPER);
  137. }
  138. /* if a vertical blank interrupt */
  139. if (ints & IF_VERTB) {
  140. amiga_custom.intreq = IF_VERTB;
  141. m68k_handle_int(IRQ_AMIGA_VERTB);
  142. }
  143. return IRQ_HANDLED;
  144. }
  145. static irqreturn_t ami_int4(int irq, void *dev_id)
  146. {
  147. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  148. /* if audio 0 interrupt */
  149. if (ints & IF_AUD0) {
  150. amiga_custom.intreq = IF_AUD0;
  151. m68k_handle_int(IRQ_AMIGA_AUD0);
  152. }
  153. /* if audio 1 interrupt */
  154. if (ints & IF_AUD1) {
  155. amiga_custom.intreq = IF_AUD1;
  156. m68k_handle_int(IRQ_AMIGA_AUD1);
  157. }
  158. /* if audio 2 interrupt */
  159. if (ints & IF_AUD2) {
  160. amiga_custom.intreq = IF_AUD2;
  161. m68k_handle_int(IRQ_AMIGA_AUD2);
  162. }
  163. /* if audio 3 interrupt */
  164. if (ints & IF_AUD3) {
  165. amiga_custom.intreq = IF_AUD3;
  166. m68k_handle_int(IRQ_AMIGA_AUD3);
  167. }
  168. return IRQ_HANDLED;
  169. }
  170. static irqreturn_t ami_int5(int irq, void *dev_id)
  171. {
  172. unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
  173. /* if serial receive buffer full interrupt */
  174. if (ints & IF_RBF) {
  175. /* acknowledge of IF_RBF must be done by the serial interrupt */
  176. m68k_handle_int(IRQ_AMIGA_RBF);
  177. }
  178. /* if a disk sync interrupt */
  179. if (ints & IF_DSKSYN) {
  180. amiga_custom.intreq = IF_DSKSYN;
  181. m68k_handle_int(IRQ_AMIGA_DSKSYN);
  182. }
  183. return IRQ_HANDLED;
  184. }