irq.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 void end_i8259_irq(unsigned int irq)
  42. {
  43. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  44. enable_8259A_irq(irq - I8259_IRQ_BASE);
  45. }
  46. static struct irq_chip i8259_irq_type = {
  47. .typename = "XT-PIC",
  48. .ack = ack_i8259_irq,
  49. .mask = disable_i8259_irq,
  50. .mask_ack = ack_i8259_irq,
  51. .unmask = enable_i8259_irq,
  52. .end = end_i8259_irq,
  53. };
  54. static int i8259_get_irq_number(int irq)
  55. {
  56. unsigned long isr;
  57. isr = inb(0x20);
  58. irq = ffz(~isr);
  59. if (irq == 2) {
  60. isr = inb(0xa0);
  61. irq = 8 + ffz(~isr);
  62. }
  63. if (irq < 0 || irq > 15)
  64. return -EINVAL;
  65. return I8259_IRQ_BASE + irq;
  66. }
  67. static struct irqaction i8259_slave_cascade = {
  68. .handler = &no_action,
  69. .name = "cascade",
  70. };
  71. void __init rockhopper_init_irq(void)
  72. {
  73. int i;
  74. if(!vr4133_rockhopper) {
  75. printk(KERN_ERR "Not a Rockhopper Board \n");
  76. return;
  77. }
  78. for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
  79. set_irq_chip(i, &i8259_irq_type);
  80. setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
  81. vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
  82. vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH);
  83. vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number);
  84. }