irq.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/irq_cpu.h>
  14. #include <asm/i8259.h>
  15. #include <asm/io.h>
  16. #include <asm/jazz.h>
  17. #include <asm/pgtable.h>
  18. static DEFINE_SPINLOCK(r4030_lock);
  19. static void enable_r4030_irq(unsigned int irq)
  20. {
  21. unsigned int mask = 1 << (irq - JAZZ_IRQ_START);
  22. unsigned long flags;
  23. spin_lock_irqsave(&r4030_lock, flags);
  24. mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  25. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
  26. spin_unlock_irqrestore(&r4030_lock, flags);
  27. }
  28. void disable_r4030_irq(unsigned int irq)
  29. {
  30. unsigned int mask = ~(1 << (irq - JAZZ_IRQ_START));
  31. unsigned long flags;
  32. spin_lock_irqsave(&r4030_lock, flags);
  33. mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  34. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
  35. spin_unlock_irqrestore(&r4030_lock, flags);
  36. }
  37. static struct irq_chip r4030_irq_type = {
  38. .name = "R4030",
  39. .ack = disable_r4030_irq,
  40. .mask = disable_r4030_irq,
  41. .mask_ack = disable_r4030_irq,
  42. .unmask = enable_r4030_irq,
  43. };
  44. void __init init_r4030_ints(void)
  45. {
  46. int i;
  47. for (i = JAZZ_IRQ_START; i <= JAZZ_IRQ_END; i++)
  48. set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
  49. r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
  50. r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
  51. r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */
  52. }
  53. /*
  54. * On systems with i8259-style interrupt controllers we assume for
  55. * driver compatibility reasons interrupts 0 - 15 to be the i8259
  56. * interrupts even if the hardware uses a different interrupt numbering.
  57. */
  58. void __init arch_init_irq(void)
  59. {
  60. /*
  61. * this is a hack to get back the still needed wired mapping
  62. * killed by init_mm()
  63. */
  64. /* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */
  65. add_wired_entry(0x02000017, 0x03c00017, 0xe0000000, PM_64K);
  66. /* Map 0xe2000000 -> 0x0:900005C0, 0xe3010000 -> 0x0:910005C0 */
  67. add_wired_entry(0x02400017, 0x02440017, 0xe2000000, PM_16M);
  68. /* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */
  69. add_wired_entry(0x01800017, 0x01000017, 0xe4000000, PM_4M);
  70. init_i8259_irqs(); /* Integrated i8259 */
  71. mips_cpu_irq_init();
  72. init_r4030_ints();
  73. change_c0_status(ST0_IM, IE_IRQ2 | IE_IRQ1);
  74. }
  75. asmlinkage void plat_irq_dispatch(void)
  76. {
  77. unsigned int pending = read_c0_cause() & read_c0_status();
  78. unsigned int irq;
  79. if (pending & IE_IRQ4) {
  80. r4030_read_reg32(JAZZ_TIMER_REGISTER);
  81. do_IRQ(JAZZ_TIMER_IRQ);
  82. } else if (pending & IE_IRQ2)
  83. do_IRQ(r4030_read_reg32(JAZZ_EISA_IRQ_ACK));
  84. else if (pending & IE_IRQ1) {
  85. irq = *(volatile u8 *)JAZZ_IO_IRQ_SOURCE >> 2;
  86. if (likely(irq > 0))
  87. do_IRQ(irq + JAZZ_IRQ_START - 1);
  88. else
  89. panic("Unimplemented loc_no_irq handler");
  90. }
  91. }