irq.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 Linus Torvalds
  7. * Copyright (C) 1994 - 2001, 2003 Ralf Baechle
  8. */
  9. #include <linux/init.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/kernel.h>
  12. #include <linux/spinlock.h>
  13. #include <asm/i8259.h>
  14. #include <asm/io.h>
  15. #include <asm/jazz.h>
  16. static DEFINE_SPINLOCK(r4030_lock);
  17. static void enable_r4030_irq(unsigned int irq)
  18. {
  19. unsigned int mask = 1 << (irq - JAZZ_PARALLEL_IRQ);
  20. unsigned long flags;
  21. spin_lock_irqsave(&r4030_lock, flags);
  22. mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  23. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
  24. spin_unlock_irqrestore(&r4030_lock, flags);
  25. }
  26. void disable_r4030_irq(unsigned int irq)
  27. {
  28. unsigned int mask = ~(1 << (irq - JAZZ_PARALLEL_IRQ));
  29. unsigned long flags;
  30. spin_lock_irqsave(&r4030_lock, flags);
  31. mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  32. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
  33. spin_unlock_irqrestore(&r4030_lock, flags);
  34. }
  35. static struct irq_chip r4030_irq_type = {
  36. .name = "R4030",
  37. .ack = disable_r4030_irq,
  38. .mask = disable_r4030_irq,
  39. .mask_ack = disable_r4030_irq,
  40. .unmask = enable_r4030_irq,
  41. };
  42. void __init init_r4030_ints(void)
  43. {
  44. int i;
  45. for (i = JAZZ_PARALLEL_IRQ; i <= JAZZ_TIMER_IRQ; i++)
  46. set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
  47. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
  48. r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
  49. r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */
  50. }
  51. /*
  52. * On systems with i8259-style interrupt controllers we assume for
  53. * driver compatibility reasons interrupts 0 - 15 to be the i8259
  54. * interrupts even if the hardware uses a different interrupt numbering.
  55. */
  56. void __init arch_init_irq(void)
  57. {
  58. init_i8259_irqs(); /* Integrated i8259 */
  59. init_r4030_ints();
  60. change_c0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1);
  61. }
  62. static void loc_call(unsigned int irq, unsigned int mask)
  63. {
  64. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE,
  65. r4030_read_reg16(JAZZ_IO_IRQ_ENABLE) & mask);
  66. do_IRQ(irq);
  67. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE,
  68. r4030_read_reg16(JAZZ_IO_IRQ_ENABLE) | mask);
  69. }
  70. static void ll_local_dev(void)
  71. {
  72. switch (r4030_read_reg32(JAZZ_IO_IRQ_SOURCE)) {
  73. case 0:
  74. panic("Unimplemented loc_no_irq handler");
  75. break;
  76. case 4:
  77. loc_call(JAZZ_PARALLEL_IRQ, JAZZ_IE_PARALLEL);
  78. break;
  79. case 8:
  80. loc_call(JAZZ_PARALLEL_IRQ, JAZZ_IE_FLOPPY);
  81. break;
  82. case 12:
  83. panic("Unimplemented loc_sound handler");
  84. break;
  85. case 16:
  86. panic("Unimplemented loc_video handler");
  87. break;
  88. case 20:
  89. loc_call(JAZZ_ETHERNET_IRQ, JAZZ_IE_ETHERNET);
  90. break;
  91. case 24:
  92. loc_call(JAZZ_SCSI_IRQ, JAZZ_IE_SCSI);
  93. break;
  94. case 28:
  95. loc_call(JAZZ_KEYBOARD_IRQ, JAZZ_IE_KEYBOARD);
  96. break;
  97. case 32:
  98. loc_call(JAZZ_MOUSE_IRQ, JAZZ_IE_MOUSE);
  99. break;
  100. case 36:
  101. loc_call(JAZZ_SERIAL1_IRQ, JAZZ_IE_SERIAL1);
  102. break;
  103. case 40:
  104. loc_call(JAZZ_SERIAL2_IRQ, JAZZ_IE_SERIAL2);
  105. break;
  106. }
  107. }
  108. asmlinkage void plat_irq_dispatch(void)
  109. {
  110. unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
  111. if (pending & IE_IRQ5)
  112. write_c0_compare(0);
  113. else if (pending & IE_IRQ4) {
  114. r4030_read_reg32(JAZZ_TIMER_REGISTER);
  115. do_IRQ(JAZZ_TIMER_IRQ);
  116. } else if (pending & IE_IRQ3)
  117. panic("Unimplemented ISA NMI handler");
  118. else if (pending & IE_IRQ2)
  119. do_IRQ(r4030_read_reg32(JAZZ_EISA_IRQ_ACK));
  120. else if (pending & IE_IRQ1) {
  121. ll_local_dev();
  122. } else if (unlikely(pending & IE_IRQ0))
  123. panic("Unimplemented local_dma handler");
  124. else if (pending & IE_SW1) {
  125. clear_c0_cause(IE_SW1);
  126. panic("Unimplemented sw1 handler");
  127. } else if (pending & IE_SW0) {
  128. clear_c0_cause(IE_SW0);
  129. panic("Unimplemented sw0 handler");
  130. }
  131. }