irq_pyxis.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/irq_pyxis.c
  4. *
  5. * Based on code written by David A Rusling ([email protected]).
  6. *
  7. * IRQ Code common to all PYXIS core logic chips.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/sched.h>
  11. #include <linux/irq.h>
  12. #include <asm/io.h>
  13. #include <asm/core_cia.h>
  14. #include "proto.h"
  15. #include "irq_impl.h"
  16. /* Note mask bit is true for ENABLED irqs. */
  17. static unsigned long cached_irq_mask;
  18. static inline void
  19. pyxis_update_irq_hw(unsigned long mask)
  20. {
  21. *(vulp)PYXIS_INT_MASK = mask;
  22. mb();
  23. *(vulp)PYXIS_INT_MASK;
  24. }
  25. static inline void
  26. pyxis_enable_irq(struct irq_data *d)
  27. {
  28. pyxis_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16));
  29. }
  30. static void
  31. pyxis_disable_irq(struct irq_data *d)
  32. {
  33. pyxis_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16)));
  34. }
  35. static void
  36. pyxis_mask_and_ack_irq(struct irq_data *d)
  37. {
  38. unsigned long bit = 1UL << (d->irq - 16);
  39. unsigned long mask = cached_irq_mask &= ~bit;
  40. /* Disable the interrupt. */
  41. *(vulp)PYXIS_INT_MASK = mask;
  42. wmb();
  43. /* Ack PYXIS PCI interrupt. */
  44. *(vulp)PYXIS_INT_REQ = bit;
  45. mb();
  46. /* Re-read to force both writes. */
  47. *(vulp)PYXIS_INT_MASK;
  48. }
  49. static struct irq_chip pyxis_irq_type = {
  50. .name = "PYXIS",
  51. .irq_mask_ack = pyxis_mask_and_ack_irq,
  52. .irq_mask = pyxis_disable_irq,
  53. .irq_unmask = pyxis_enable_irq,
  54. };
  55. void
  56. pyxis_device_interrupt(unsigned long vector)
  57. {
  58. unsigned long pld;
  59. unsigned int i;
  60. /* Read the interrupt summary register of PYXIS */
  61. pld = *(vulp)PYXIS_INT_REQ;
  62. pld &= cached_irq_mask;
  63. /*
  64. * Now for every possible bit set, work through them and call
  65. * the appropriate interrupt handler.
  66. */
  67. while (pld) {
  68. i = ffz(~pld);
  69. pld &= pld - 1; /* clear least bit set */
  70. if (i == 7)
  71. isa_device_interrupt(vector);
  72. else
  73. handle_irq(16+i);
  74. }
  75. }
  76. void __init
  77. init_pyxis_irqs(unsigned long ignore_mask)
  78. {
  79. long i;
  80. *(vulp)PYXIS_INT_MASK = 0; /* disable all */
  81. *(vulp)PYXIS_INT_REQ = -1; /* flush all */
  82. mb();
  83. /* Send -INTA pulses to clear any pending interrupts ...*/
  84. *(vuip) CIA_IACK_SC;
  85. for (i = 16; i < 48; ++i) {
  86. if ((ignore_mask >> i) & 1)
  87. continue;
  88. irq_set_chip_and_handler(i, &pyxis_irq_type, handle_level_irq);
  89. irq_set_status_flags(i, IRQ_LEVEL);
  90. }
  91. if (request_irq(16 + 7, no_action, 0, "isa-cascade", NULL))
  92. pr_err("Failed to register isa-cascade interrupt\n");
  93. }