irq_pyxis.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * linux/arch/alpha/kernel/irq_pyxis.c
  3.  *
  4.  * Based on code written by David A Rusling (david.rusling@reo.mts.dec.com).
  5.  *
  6.  * IRQ Code common to all PYXIS core logic chips.
  7.  */
  8. #include <linux/init.h>
  9. #include <linux/sched.h>
  10. #include <linux/irq.h>
  11. #include <asm/io.h>
  12. #include <asm/core_cia.h>
  13. #include "proto.h"
  14. #include "irq_impl.h"
  15. /* Note mask bit is true for ENABLED irqs.  */
  16. static unsigned long cached_irq_mask;
  17. static inline void
  18. pyxis_update_irq_hw(unsigned long mask)
  19. {
  20. *(vulp)PYXIS_INT_MASK = mask;
  21. mb();
  22. *(vulp)PYXIS_INT_MASK;
  23. }
  24. static inline void
  25. pyxis_enable_irq(unsigned int irq)
  26. {
  27. pyxis_update_irq_hw(cached_irq_mask |= 1UL << (irq - 16));
  28. }
  29. static void
  30. pyxis_disable_irq(unsigned int irq)
  31. {
  32. pyxis_update_irq_hw(cached_irq_mask &= ~(1UL << (irq - 16)));
  33. }
  34. static unsigned int
  35. pyxis_startup_irq(unsigned int irq)
  36. {
  37. pyxis_enable_irq(irq);
  38. return 0;
  39. }
  40. static void
  41. pyxis_end_irq(unsigned int irq)
  42. {
  43. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  44. pyxis_enable_irq(irq);
  45. }
  46. static void
  47. pyxis_mask_and_ack_irq(unsigned int irq)
  48. {
  49. unsigned long bit = 1UL << (irq - 16);
  50. unsigned long mask = cached_irq_mask &= ~bit;
  51. /* Disable the interrupt.  */
  52. *(vulp)PYXIS_INT_MASK = mask;
  53. wmb();
  54. /* Ack PYXIS PCI interrupt.  */
  55. *(vulp)PYXIS_INT_REQ = bit;
  56. mb();
  57. /* Re-read to force both writes.  */
  58. *(vulp)PYXIS_INT_MASK;
  59. }
  60. static struct hw_interrupt_type pyxis_irq_type = {
  61. typename: "PYXIS",
  62. startup: pyxis_startup_irq,
  63. shutdown: pyxis_disable_irq,
  64. enable: pyxis_enable_irq,
  65. disable: pyxis_disable_irq,
  66. ack: pyxis_mask_and_ack_irq,
  67. end: pyxis_end_irq,
  68. };
  69. void 
  70. pyxis_device_interrupt(unsigned long vector, struct pt_regs *regs)
  71. {
  72. unsigned long pld;
  73. unsigned int i;
  74. /* Read the interrupt summary register of PYXIS */
  75. pld = *(vulp)PYXIS_INT_REQ;
  76. pld &= cached_irq_mask;
  77. /*
  78.  * Now for every possible bit set, work through them and call
  79.  * the appropriate interrupt handler.
  80.  */
  81. while (pld) {
  82. i = ffz(~pld);
  83. pld &= pld - 1; /* clear least bit set */
  84. if (i == 7)
  85. isa_device_interrupt(vector, regs);
  86. else
  87. handle_irq(16+i, regs);
  88. }
  89. }
  90. void __init
  91. init_pyxis_irqs(unsigned long ignore_mask)
  92. {
  93. long i;
  94. *(vulp)PYXIS_INT_MASK = 0; /* disable all */
  95. *(vulp)PYXIS_INT_REQ  = -1; /* flush all */
  96. mb();
  97. /* Send -INTA pulses to clear any pending interrupts ...*/
  98. *(vuip) CIA_IACK_SC;
  99. for (i = 16; i < 48; ++i) {
  100. if ((ignore_mask >> i) & 1)
  101. continue;
  102. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  103. irq_desc[i].handler = &pyxis_irq_type;
  104. }
  105. setup_irq(16+7, &isa_cascade_irqaction);
  106. }