Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * DEC I/O ASIC interrupts. |
| 3 | * |
| 4 | * Copyright (c) 2002, 2003 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 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #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 | |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | static int ioasic_irq_base; |
| 22 | |
| 23 | |
| 24 | static inline void unmask_ioasic_irq(unsigned int irq) |
| 25 | { |
| 26 | u32 simr; |
| 27 | |
| 28 | simr = ioasic_read(IO_REG_SIMR); |
| 29 | simr |= (1 << (irq - ioasic_irq_base)); |
| 30 | ioasic_write(IO_REG_SIMR, simr); |
| 31 | } |
| 32 | |
| 33 | static inline void mask_ioasic_irq(unsigned int irq) |
| 34 | { |
| 35 | u32 simr; |
| 36 | |
| 37 | simr = ioasic_read(IO_REG_SIMR); |
| 38 | simr &= ~(1 << (irq - ioasic_irq_base)); |
| 39 | ioasic_write(IO_REG_SIMR, simr); |
| 40 | } |
| 41 | |
| 42 | static inline void clear_ioasic_irq(unsigned int irq) |
| 43 | { |
| 44 | u32 sir; |
| 45 | |
| 46 | sir = ~(1 << (irq - ioasic_irq_base)); |
| 47 | ioasic_write(IO_REG_SIR, sir); |
| 48 | } |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | static inline void ack_ioasic_irq(unsigned int irq) |
| 51 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | mask_ioasic_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | fast_iob(); |
| 54 | } |
| 55 | |
| 56 | static inline void end_ioasic_irq(unsigned int irq) |
| 57 | { |
| 58 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 59 | unmask_ioasic_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 62 | static struct irq_chip ioasic_irq_type = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 63 | .name = "IO-ASIC", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | .ack = ack_ioasic_irq, |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 65 | .mask = mask_ioasic_irq, |
| 66 | .mask_ack = ack_ioasic_irq, |
| 67 | .unmask = unmask_ioasic_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 71 | #define unmask_ioasic_dma_irq unmask_ioasic_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 73 | #define mask_ioasic_dma_irq mask_ioasic_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | #define ack_ioasic_dma_irq ack_ioasic_irq |
| 76 | |
| 77 | static inline void end_ioasic_dma_irq(unsigned int irq) |
| 78 | { |
| 79 | clear_ioasic_irq(irq); |
| 80 | fast_iob(); |
| 81 | end_ioasic_irq(irq); |
| 82 | } |
| 83 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 84 | static struct irq_chip ioasic_dma_irq_type = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 85 | .name = "IO-ASIC-DMA", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | .ack = ack_ioasic_dma_irq, |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 87 | .mask = mask_ioasic_dma_irq, |
| 88 | .mask_ack = ack_ioasic_dma_irq, |
| 89 | .unmask = unmask_ioasic_dma_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | .end = end_ioasic_dma_irq, |
| 91 | }; |
| 92 | |
| 93 | |
| 94 | void __init init_ioasic_irqs(int base) |
| 95 | { |
| 96 | int i; |
| 97 | |
| 98 | /* Mask interrupts. */ |
| 99 | ioasic_write(IO_REG_SIMR, 0); |
| 100 | fast_iob(); |
| 101 | |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 102 | for (i = base; i < base + IO_INR_DMA; i++) |
Atsushi Nemoto | 1417836 | 2006-11-14 01:13:18 +0900 | [diff] [blame] | 103 | set_irq_chip_and_handler(i, &ioasic_irq_type, |
| 104 | handle_level_irq); |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 105 | for (; i < base + IO_IRQ_LINES; i++) |
Atsushi Nemoto | 25ba2f5 | 2006-12-02 00:08:03 +0900 | [diff] [blame] | 106 | set_irq_chip(i, &ioasic_dma_irq_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | ioasic_irq_base = base; |
| 109 | } |