irq.c 3.5 KB

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