i8259.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. extern spinlock_t i8259A_lock;
  20. extern void init_i8259_irqs(void);
  21. /*
  22. * Do the traditional i8259 interrupt polling thing. This is for the few
  23. * cases where no better interrupt acknowledge method is available and we
  24. * absolutely must touch the i8259.
  25. */
  26. static inline int i8259_irq(void)
  27. {
  28. int irq;
  29. spin_lock(&i8259A_lock);
  30. /* Perform an interrupt acknowledge cycle on controller 1. */
  31. outb(0x0C, 0x20); /* prepare for poll */
  32. irq = inb(0x20) & 7;
  33. if (irq == 2) {
  34. /*
  35. * Interrupt is cascaded so perform interrupt
  36. * acknowledge on controller 2.
  37. */
  38. outb(0x0C, 0xA0); /* prepare for poll */
  39. irq = (inb(0xA0) & 7) + 8;
  40. }
  41. if (unlikely(irq == 7)) {
  42. /*
  43. * This may be a spurious interrupt.
  44. *
  45. * Read the interrupt status register (ISR). If the most
  46. * significant bit is not set then there is no valid
  47. * interrupt.
  48. */
  49. outb(0x0B, 0x20); /* ISR register */
  50. if(~inb(0x20) & 0x80)
  51. irq = -1;
  52. }
  53. spin_unlock(&i8259A_lock);
  54. return irq;
  55. }
  56. #endif /* _ASM_I8259_H */