blob: e04d973ce5aa24cd832771b417b0b5ce23f14ac4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * DEC I/O ASIC interrupts.
3 *
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +01004 * Copyright (c) 2002, 2003, 2013 Maciej W. Rozycki
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
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
12#include <linux/init.h>
13#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/types.h>
15
16#include <asm/dec/ioasic.h>
17#include <asm/dec/ioasic_addrs.h>
18#include <asm/dec/ioasic_ints.h>
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020static int ioasic_irq_base;
21
Thomas Gleixner009c2002011-03-23 21:08:51 +000022static void unmask_ioasic_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
24 u32 simr;
25
26 simr = ioasic_read(IO_REG_SIMR);
Thomas Gleixner009c2002011-03-23 21:08:51 +000027 simr |= (1 << (d->irq - ioasic_irq_base));
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 ioasic_write(IO_REG_SIMR, simr);
29}
30
Thomas Gleixner009c2002011-03-23 21:08:51 +000031static void mask_ioasic_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
33 u32 simr;
34
35 simr = ioasic_read(IO_REG_SIMR);
Thomas Gleixner009c2002011-03-23 21:08:51 +000036 simr &= ~(1 << (d->irq - ioasic_irq_base));
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 ioasic_write(IO_REG_SIMR, simr);
38}
39
Thomas Gleixner009c2002011-03-23 21:08:51 +000040static void ack_ioasic_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041{
Thomas Gleixner009c2002011-03-23 21:08:51 +000042 mask_ioasic_irq(d);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 fast_iob();
44}
45
Ralf Baechle94dee172006-07-02 14:41:42 +010046static struct irq_chip ioasic_irq_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090047 .name = "IO-ASIC",
Thomas Gleixner009c2002011-03-23 21:08:51 +000048 .irq_ack = ack_ioasic_irq,
49 .irq_mask = mask_ioasic_irq,
50 .irq_mask_ack = ack_ioasic_irq,
51 .irq_unmask = unmask_ioasic_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070052};
53
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010054static void clear_ioasic_dma_irq(struct irq_data *d)
Maciej W. Rozycki5359b932013-09-12 12:14:31 +010055{
56 u32 sir;
57
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010058 sir = ~(1 << (d->irq - ioasic_irq_base));
Maciej W. Rozycki5359b932013-09-12 12:14:31 +010059 ioasic_write(IO_REG_SIR, sir);
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010060 fast_iob();
Maciej W. Rozycki5359b932013-09-12 12:14:31 +010061}
62
Ralf Baechle94dee172006-07-02 14:41:42 +010063static struct irq_chip ioasic_dma_irq_type = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +090064 .name = "IO-ASIC-DMA",
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010065 .irq_ack = clear_ioasic_dma_irq,
Thomas Gleixner009c2002011-03-23 21:08:51 +000066 .irq_mask = mask_ioasic_irq,
Thomas Gleixner009c2002011-03-23 21:08:51 +000067 .irq_unmask = unmask_ioasic_irq,
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010068 .irq_eoi = clear_ioasic_dma_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070069};
70
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +010071/*
72 * I/O ASIC implements two kinds of DMA interrupts, informational and
73 * error interrupts.
74 *
75 * The formers do not stop DMA and should be cleared as soon as possible
76 * so that if they retrigger before the handler has completed, usually as
77 * a side effect of actions taken by the handler, then they are reissued.
78 * These use the `handle_edge_irq' handler that clears the request right
79 * away.
80 *
81 * The latters stop DMA and do not resume it until the interrupt has been
82 * cleared. This cannot be done until after a corrective action has been
83 * taken and this also means they will not retrigger. Therefore they use
84 * the `handle_fasteoi_irq' handler that only clears the request on the
85 * way out. Because MIPS processor interrupt inputs, one of which the I/O
86 * ASIC is cascaded to, are level-triggered it is recommended that error
87 * DMA interrupt action handlers are registered with the IRQF_ONESHOT flag
88 * set so that they are run with the interrupt line masked.
89 *
90 * This mask has `1' bits in the positions of informational interrupts.
91 */
92#define IO_IRQ_DMA_INFO \
93 (IO_IRQ_MASK(IO_INR_SCC0A_RXDMA) | \
94 IO_IRQ_MASK(IO_INR_SCC1A_RXDMA) | \
95 IO_IRQ_MASK(IO_INR_ISDN_TXDMA) | \
96 IO_IRQ_MASK(IO_INR_ISDN_RXDMA) | \
97 IO_IRQ_MASK(IO_INR_ASC_DMA))
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099void __init init_ioasic_irqs(int base)
100{
101 int i;
102
103 /* Mask interrupts. */
104 ioasic_write(IO_REG_SIMR, 0);
105 fast_iob();
106
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900107 for (i = base; i < base + IO_INR_DMA; i++)
Thomas Gleixnere4ec7982011-03-27 15:19:28 +0200108 irq_set_chip_and_handler(i, &ioasic_irq_type,
Atsushi Nemoto14178362006-11-14 01:13:18 +0900109 handle_level_irq);
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900110 for (; i < base + IO_IRQ_LINES; i++)
Maciej W. Rozycki0fabe102013-09-22 21:55:19 +0100111 irq_set_chip_and_handler(i, &ioasic_dma_irq_type,
112 1 << (i - base) & IO_IRQ_DMA_INFO ?
113 handle_edge_irq : handle_fasteoi_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115 ioasic_irq_base = base;
116}