irq_pyxis.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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(struct irq_data *d)
  26. {
  27. pyxis_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16));
  28. }
  29. static void
  30. pyxis_disable_irq(struct irq_data *d)
  31. {
  32. pyxis_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16)));
  33. }
  34. static void
  35. pyxis_mask_and_ack_irq(struct irq_data *d)
  36. {
  37. unsigned long bit = 1UL << (d->irq - 16);
  38. unsigned long mask = cached_irq_mask &= ~bit;
  39. /* Disable the interrupt. */
  40. *(vulp)PYXIS_INT_MASK = mask;
  41. wmb();
  42. /* Ack PYXIS PCI interrupt. */
  43. *(vulp)PYXIS_INT_REQ = bit;
  44. mb();
  45. /* Re-read to force both writes. */
  46. *(vulp)PYXIS_INT_MASK;
  47. }
  48. static struct irq_chip pyxis_irq_type = {
  49. .name = "PYXIS",
  50. .irq_mask_ack = pyxis_mask_and_ack_irq,
  51. .irq_mask = pyxis_disable_irq,
  52. .irq_unmask = pyxis_enable_irq,
  53. };
  54. void
  55. pyxis_device_interrupt(unsigned long vector)
  56. {
  57. unsigned long pld;
  58. unsigned int i;
  59. /* Read the interrupt summary register of PYXIS */
  60. pld = *(vulp)PYXIS_INT_REQ;
  61. pld &= cached_irq_mask;
  62. /*
  63. * Now for every possible bit set, work through them and call
  64. * the appropriate interrupt handler.
  65. */
  66. while (pld) {
  67. i = ffz(~pld);
  68. pld &= pld - 1; /* clear least bit set */
  69. if (i == 7)
  70. isa_device_interrupt(vector);
  71. else
  72. handle_irq(16+i);
  73. }
  74. }
  75. void __init
  76. init_pyxis_irqs(unsigned long ignore_mask)
  77. {
  78. long i;
  79. *(vulp)PYXIS_INT_MASK = 0; /* disable all */
  80. *(vulp)PYXIS_INT_REQ = -1; /* flush all */
  81. mb();
  82. /* Send -INTA pulses to clear any pending interrupts ...*/
  83. *(vuip) CIA_IACK_SC;
  84. for (i = 16; i < 48; ++i) {
  85. if ((ignore_mask >> i) & 1)
  86. continue;
  87. irq_set_chip_and_handler(i, &pyxis_irq_type, handle_level_irq);
  88. irq_set_status_flags(i, IRQ_LEVEL);
  89. }
  90. setup_irq(16+7, &isa_cascade_irqaction);
  91. }