amiints.c 4.0 KB

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