irq.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * arch/mips/vr41xx/nec-cmbvr4133/irq.c
  3. *
  4. * Interrupt routines for the NEC CMB-VR4133 board.
  5. *
  6. * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
  7. * Alex Sapkov <asapkov@ru.mvista.com>
  8. *
  9. * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
  10. * the terms of the GNU General Public License version 2. This program
  11. * is licensed "as is" without any warranty of any kind, whether express
  12. * or implied.
  13. *
  14. * Support for NEC-CMBVR4133 in 2.6
  15. * Manish Lachwani (mlachwani@mvista.com)
  16. */
  17. #include <linux/bitops.h>
  18. #include <linux/errno.h>
  19. #include <linux/init.h>
  20. #include <linux/ioport.h>
  21. #include <linux/interrupt.h>
  22. #include <asm/io.h>
  23. #include <asm/vr41xx/cmbvr4133.h>
  24. extern void enable_8259A_irq(unsigned int irq);
  25. extern void disable_8259A_irq(unsigned int irq);
  26. extern void mask_and_ack_8259A(unsigned int irq);
  27. extern void init_8259A(int hoge);
  28. extern int vr4133_rockhopper;
  29. static void enable_i8259_irq(unsigned int irq)
  30. {
  31. enable_8259A_irq(irq - I8259_IRQ_BASE);
  32. }
  33. static void disable_i8259_irq(unsigned int irq)
  34. {
  35. disable_8259A_irq(irq - I8259_IRQ_BASE);
  36. }
  37. static void ack_i8259_irq(unsigned int irq)
  38. {
  39. mask_and_ack_8259A(irq - I8259_IRQ_BASE);
  40. }
  41. static struct irq_chip i8259_irq_type = {
  42. .typename = "XT-PIC",
  43. .ack = ack_i8259_irq,
  44. .mask = disable_i8259_irq,
  45. .mask_ack = ack_i8259_irq,
  46. .unmask = enable_i8259_irq,
  47. };
  48. static int i8259_get_irq_number(int irq)
  49. {
  50. unsigned long isr;
  51. isr = inb(0x20);
  52. irq = ffz(~isr);
  53. if (irq == 2) {
  54. isr = inb(0xa0);
  55. irq = 8 + ffz(~isr);
  56. }
  57. if (irq < 0 || irq > 15)
  58. return -EINVAL;
  59. return I8259_IRQ_BASE + irq;
  60. }
  61. static struct irqaction i8259_slave_cascade = {
  62. .handler = &no_action,
  63. .name = "cascade",
  64. };
  65. void __init rockhopper_init_irq(void)
  66. {
  67. int i;
  68. if(!vr4133_rockhopper) {
  69. printk(KERN_ERR "Not a Rockhopper Board \n");
  70. return;
  71. }
  72. for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
  73. set_irq_chip_and_handler(i, &i8259_irq_type, handle_level_irq);
  74. setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
  75. vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
  76. vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH);
  77. vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number);
  78. }