irq.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 unsigned int startup_i8259_irq(unsigned int irq)
  30. {
  31. enable_8259A_irq(irq - I8259_IRQ_BASE);
  32. return 0;
  33. }
  34. static void shutdown_i8259_irq(unsigned int irq)
  35. {
  36. disable_8259A_irq(irq - I8259_IRQ_BASE);
  37. }
  38. static void enable_i8259_irq(unsigned int irq)
  39. {
  40. enable_8259A_irq(irq - I8259_IRQ_BASE);
  41. }
  42. static void disable_i8259_irq(unsigned int irq)
  43. {
  44. disable_8259A_irq(irq - I8259_IRQ_BASE);
  45. }
  46. static void ack_i8259_irq(unsigned int irq)
  47. {
  48. mask_and_ack_8259A(irq - I8259_IRQ_BASE);
  49. }
  50. static void end_i8259_irq(unsigned int irq)
  51. {
  52. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  53. enable_8259A_irq(irq - I8259_IRQ_BASE);
  54. }
  55. static struct hw_interrupt_type i8259_irq_type = {
  56. .typename = "XT-PIC",
  57. .startup = startup_i8259_irq,
  58. .shutdown = shutdown_i8259_irq,
  59. .enable = enable_i8259_irq,
  60. .disable = disable_i8259_irq,
  61. .ack = ack_i8259_irq,
  62. .end = end_i8259_irq,
  63. };
  64. static int i8259_get_irq_number(int irq)
  65. {
  66. unsigned long isr;
  67. isr = inb(0x20);
  68. irq = ffz(~isr);
  69. if (irq == 2) {
  70. isr = inb(0xa0);
  71. irq = 8 + ffz(~isr);
  72. }
  73. if (irq < 0 || irq > 15)
  74. return -EINVAL;
  75. return I8259_IRQ_BASE + irq;
  76. }
  77. static struct irqaction i8259_slave_cascade = {
  78. .handler = &no_action,
  79. .name = "cascade",
  80. };
  81. void __init rockhopper_init_irq(void)
  82. {
  83. int i;
  84. if(!vr4133_rockhopper) {
  85. printk(KERN_ERR "Not a Rockhopper Board \n");
  86. return;
  87. }
  88. for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
  89. irq_desc[i].handler = &i8259_irq_type;
  90. setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
  91. vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
  92. vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH);
  93. vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number);
  94. }