i8259.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * include/asm-mips/i8259.h
  3. *
  4. * i8259A interrupt definitions.
  5. *
  6. * Copyright (C) 2003 Maciej W. Rozycki
  7. * Copyright (C) 2003 Ralf Baechle <ralf@linux-mips.org>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #ifndef _ASM_I8259_H
  15. #define _ASM_I8259_H
  16. #include <linux/compiler.h>
  17. #include <linux/spinlock.h>
  18. #include <asm/io.h>
  19. #include <irq.h>
  20. /* i8259A PIC registers */
  21. #define PIC_MASTER_CMD 0x20
  22. #define PIC_MASTER_IMR 0x21
  23. #define PIC_MASTER_ISR PIC_MASTER_CMD
  24. #define PIC_MASTER_POLL PIC_MASTER_ISR
  25. #define PIC_MASTER_OCW3 PIC_MASTER_ISR
  26. #define PIC_SLAVE_CMD 0xa0
  27. #define PIC_SLAVE_IMR 0xa1
  28. /* i8259A PIC related value */
  29. #define PIC_CASCADE_IR 2
  30. #define MASTER_ICW4_DEFAULT 0x01
  31. #define SLAVE_ICW4_DEFAULT 0x01
  32. #define PIC_ICW4_AEOI 2
  33. extern raw_spinlock_t i8259A_lock;
  34. extern int i8259A_irq_pending(unsigned int irq);
  35. extern void make_8259A_irq(unsigned int irq);
  36. extern void init_i8259_irqs(void);
  37. /*
  38. * Do the traditional i8259 interrupt polling thing. This is for the few
  39. * cases where no better interrupt acknowledge method is available and we
  40. * absolutely must touch the i8259.
  41. */
  42. static inline int i8259_irq(void)
  43. {
  44. int irq;
  45. raw_spin_lock(&i8259A_lock);
  46. /* Perform an interrupt acknowledge cycle on controller 1. */
  47. outb(0x0C, PIC_MASTER_CMD); /* prepare for poll */
  48. irq = inb(PIC_MASTER_CMD) & 7;
  49. if (irq == PIC_CASCADE_IR) {
  50. /*
  51. * Interrupt is cascaded so perform interrupt
  52. * acknowledge on controller 2.
  53. */
  54. outb(0x0C, PIC_SLAVE_CMD); /* prepare for poll */
  55. irq = (inb(PIC_SLAVE_CMD) & 7) + 8;
  56. }
  57. if (unlikely(irq == 7)) {
  58. /*
  59. * This may be a spurious interrupt.
  60. *
  61. * Read the interrupt status register (ISR). If the most
  62. * significant bit is not set then there is no valid
  63. * interrupt.
  64. */
  65. outb(0x0B, PIC_MASTER_ISR); /* ISR register */
  66. if(~inb(PIC_MASTER_ISR) & 0x80)
  67. irq = -1;
  68. }
  69. raw_spin_unlock(&i8259A_lock);
  70. return likely(irq >= 0) ? irq + I8259A_IRQ_BASE : irq;
  71. }
  72. #endif /* _ASM_I8259_H */