ioasic-irq.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * DEC I/O ASIC interrupts.
  3. *
  4. * Copyright (c) 2002, 2003, 2013 Maciej W. Rozycki
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/irq.h>
  13. #include <linux/types.h>
  14. #include <asm/dec/ioasic.h>
  15. #include <asm/dec/ioasic_addrs.h>
  16. #include <asm/dec/ioasic_ints.h>
  17. static int ioasic_irq_base;
  18. static void unmask_ioasic_irq(struct irq_data *d)
  19. {
  20. u32 simr;
  21. simr = ioasic_read(IO_REG_SIMR);
  22. simr |= (1 << (d->irq - ioasic_irq_base));
  23. ioasic_write(IO_REG_SIMR, simr);
  24. }
  25. static void mask_ioasic_irq(struct irq_data *d)
  26. {
  27. u32 simr;
  28. simr = ioasic_read(IO_REG_SIMR);
  29. simr &= ~(1 << (d->irq - ioasic_irq_base));
  30. ioasic_write(IO_REG_SIMR, simr);
  31. }
  32. static void ack_ioasic_irq(struct irq_data *d)
  33. {
  34. mask_ioasic_irq(d);
  35. fast_iob();
  36. }
  37. static struct irq_chip ioasic_irq_type = {
  38. .name = "IO-ASIC",
  39. .irq_ack = ack_ioasic_irq,
  40. .irq_mask = mask_ioasic_irq,
  41. .irq_mask_ack = ack_ioasic_irq,
  42. .irq_unmask = unmask_ioasic_irq,
  43. };
  44. static void clear_ioasic_dma_irq(struct irq_data *d)
  45. {
  46. u32 sir;
  47. sir = ~(1 << (d->irq - ioasic_irq_base));
  48. ioasic_write(IO_REG_SIR, sir);
  49. fast_iob();
  50. }
  51. static struct irq_chip ioasic_dma_irq_type = {
  52. .name = "IO-ASIC-DMA",
  53. .irq_ack = clear_ioasic_dma_irq,
  54. .irq_mask = mask_ioasic_irq,
  55. .irq_unmask = unmask_ioasic_irq,
  56. .irq_eoi = clear_ioasic_dma_irq,
  57. };
  58. /*
  59. * I/O ASIC implements two kinds of DMA interrupts, informational and
  60. * error interrupts.
  61. *
  62. * The formers do not stop DMA and should be cleared as soon as possible
  63. * so that if they retrigger before the handler has completed, usually as
  64. * a side effect of actions taken by the handler, then they are reissued.
  65. * These use the `handle_edge_irq' handler that clears the request right
  66. * away.
  67. *
  68. * The latters stop DMA and do not resume it until the interrupt has been
  69. * cleared. This cannot be done until after a corrective action has been
  70. * taken and this also means they will not retrigger. Therefore they use
  71. * the `handle_fasteoi_irq' handler that only clears the request on the
  72. * way out. Because MIPS processor interrupt inputs, one of which the I/O
  73. * ASIC is cascaded to, are level-triggered it is recommended that error
  74. * DMA interrupt action handlers are registered with the IRQF_ONESHOT flag
  75. * set so that they are run with the interrupt line masked.
  76. *
  77. * This mask has `1' bits in the positions of informational interrupts.
  78. */
  79. #define IO_IRQ_DMA_INFO \
  80. (IO_IRQ_MASK(IO_INR_SCC0A_RXDMA) | \
  81. IO_IRQ_MASK(IO_INR_SCC1A_RXDMA) | \
  82. IO_IRQ_MASK(IO_INR_ISDN_TXDMA) | \
  83. IO_IRQ_MASK(IO_INR_ISDN_RXDMA) | \
  84. IO_IRQ_MASK(IO_INR_ASC_DMA))
  85. void __init init_ioasic_irqs(int base)
  86. {
  87. int i;
  88. /* Mask interrupts. */
  89. ioasic_write(IO_REG_SIMR, 0);
  90. fast_iob();
  91. for (i = base; i < base + IO_INR_DMA; i++)
  92. irq_set_chip_and_handler(i, &ioasic_irq_type,
  93. handle_level_irq);
  94. for (; i < base + IO_IRQ_LINES; i++)
  95. irq_set_chip_and_handler(i, &ioasic_dma_irq_type,
  96. 1 << (i - base) & IO_IRQ_DMA_INFO ?
  97. handle_edge_irq : handle_fasteoi_irq);
  98. ioasic_irq_base = base;
  99. }