irq.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/init.h>
  3. #include <linux/list.h>
  4. #include <linux/io.h>
  5. #include <asm/mach/irq.h>
  6. #include <asm/hardware/iomd.h>
  7. #include <asm/irq.h>
  8. #include <asm/fiq.h>
  9. static void iomd_ack_irq_a(struct irq_data *d)
  10. {
  11. unsigned int val, mask;
  12. mask = 1 << d->irq;
  13. val = iomd_readb(IOMD_IRQMASKA);
  14. iomd_writeb(val & ~mask, IOMD_IRQMASKA);
  15. iomd_writeb(mask, IOMD_IRQCLRA);
  16. }
  17. static void iomd_mask_irq_a(struct irq_data *d)
  18. {
  19. unsigned int val, mask;
  20. mask = 1 << d->irq;
  21. val = iomd_readb(IOMD_IRQMASKA);
  22. iomd_writeb(val & ~mask, IOMD_IRQMASKA);
  23. }
  24. static void iomd_unmask_irq_a(struct irq_data *d)
  25. {
  26. unsigned int val, mask;
  27. mask = 1 << d->irq;
  28. val = iomd_readb(IOMD_IRQMASKA);
  29. iomd_writeb(val | mask, IOMD_IRQMASKA);
  30. }
  31. static struct irq_chip iomd_a_chip = {
  32. .irq_ack = iomd_ack_irq_a,
  33. .irq_mask = iomd_mask_irq_a,
  34. .irq_unmask = iomd_unmask_irq_a,
  35. };
  36. static void iomd_mask_irq_b(struct irq_data *d)
  37. {
  38. unsigned int val, mask;
  39. mask = 1 << (d->irq & 7);
  40. val = iomd_readb(IOMD_IRQMASKB);
  41. iomd_writeb(val & ~mask, IOMD_IRQMASKB);
  42. }
  43. static void iomd_unmask_irq_b(struct irq_data *d)
  44. {
  45. unsigned int val, mask;
  46. mask = 1 << (d->irq & 7);
  47. val = iomd_readb(IOMD_IRQMASKB);
  48. iomd_writeb(val | mask, IOMD_IRQMASKB);
  49. }
  50. static struct irq_chip iomd_b_chip = {
  51. .irq_ack = iomd_mask_irq_b,
  52. .irq_mask = iomd_mask_irq_b,
  53. .irq_unmask = iomd_unmask_irq_b,
  54. };
  55. static void iomd_mask_irq_dma(struct irq_data *d)
  56. {
  57. unsigned int val, mask;
  58. mask = 1 << (d->irq & 7);
  59. val = iomd_readb(IOMD_DMAMASK);
  60. iomd_writeb(val & ~mask, IOMD_DMAMASK);
  61. }
  62. static void iomd_unmask_irq_dma(struct irq_data *d)
  63. {
  64. unsigned int val, mask;
  65. mask = 1 << (d->irq & 7);
  66. val = iomd_readb(IOMD_DMAMASK);
  67. iomd_writeb(val | mask, IOMD_DMAMASK);
  68. }
  69. static struct irq_chip iomd_dma_chip = {
  70. .irq_ack = iomd_mask_irq_dma,
  71. .irq_mask = iomd_mask_irq_dma,
  72. .irq_unmask = iomd_unmask_irq_dma,
  73. };
  74. static void iomd_mask_irq_fiq(struct irq_data *d)
  75. {
  76. unsigned int val, mask;
  77. mask = 1 << (d->irq & 7);
  78. val = iomd_readb(IOMD_FIQMASK);
  79. iomd_writeb(val & ~mask, IOMD_FIQMASK);
  80. }
  81. static void iomd_unmask_irq_fiq(struct irq_data *d)
  82. {
  83. unsigned int val, mask;
  84. mask = 1 << (d->irq & 7);
  85. val = iomd_readb(IOMD_FIQMASK);
  86. iomd_writeb(val | mask, IOMD_FIQMASK);
  87. }
  88. static struct irq_chip iomd_fiq_chip = {
  89. .irq_ack = iomd_mask_irq_fiq,
  90. .irq_mask = iomd_mask_irq_fiq,
  91. .irq_unmask = iomd_unmask_irq_fiq,
  92. };
  93. extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
  94. void __init rpc_init_irq(void)
  95. {
  96. unsigned int irq, clr, set;
  97. iomd_writeb(0, IOMD_IRQMASKA);
  98. iomd_writeb(0, IOMD_IRQMASKB);
  99. iomd_writeb(0, IOMD_FIQMASK);
  100. iomd_writeb(0, IOMD_DMAMASK);
  101. set_fiq_handler(&rpc_default_fiq_start,
  102. &rpc_default_fiq_end - &rpc_default_fiq_start);
  103. for (irq = 0; irq < NR_IRQS; irq++) {
  104. clr = IRQ_NOREQUEST;
  105. set = 0;
  106. if (irq <= 6 || (irq >= 9 && irq <= 15))
  107. clr |= IRQ_NOPROBE;
  108. if (irq == 21 || (irq >= 16 && irq <= 19) ||
  109. irq == IRQ_KEYBOARDTX)
  110. set |= IRQ_NOAUTOEN;
  111. switch (irq) {
  112. case 0 ... 7:
  113. irq_set_chip_and_handler(irq, &iomd_a_chip,
  114. handle_level_irq);
  115. irq_modify_status(irq, clr, set);
  116. break;
  117. case 8 ... 15:
  118. irq_set_chip_and_handler(irq, &iomd_b_chip,
  119. handle_level_irq);
  120. irq_modify_status(irq, clr, set);
  121. break;
  122. case 16 ... 21:
  123. irq_set_chip_and_handler(irq, &iomd_dma_chip,
  124. handle_level_irq);
  125. irq_modify_status(irq, clr, set);
  126. break;
  127. case 64 ... 71:
  128. irq_set_chip(irq, &iomd_fiq_chip);
  129. irq_modify_status(irq, clr, set);
  130. break;
  131. }
  132. }
  133. init_FIQ(FIQ_START);
  134. }