Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Geert Uytterhoeven | 92b1bd5 | 2011-05-31 11:11:01 +0200 | [diff] [blame] | 2 | * Amiga Linux interrupt handling code |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file COPYING in the main directory of this archive |
| 6 | * for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/init.h> |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 10 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/errno.h> |
Geert Uytterhoeven | 978ef7e | 2011-05-31 22:08:28 +0200 | [diff] [blame^] | 12 | #ifdef CONFIG_GENERIC_HARDIRQS |
| 13 | #include <linux/irq.h> |
| 14 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/irq.h> |
| 17 | #include <asm/traps.h> |
| 18 | #include <asm/amigahw.h> |
| 19 | #include <asm/amigaints.h> |
| 20 | #include <asm/amipcmcia.h> |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Enable/disable a particular machine specific interrupt source. |
| 25 | * Note that this may affect other interrupts in case of a shared interrupt. |
| 26 | * This function should only be called for a _very_ short time to change some |
| 27 | * internal data, that may not be changed by the interrupt at the same time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | */ |
| 29 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 30 | static void amiga_irq_enable(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 32 | amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 35 | static void amiga_irq_disable(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame] | 37 | amiga_custom.intena = 1 << (data->irq - IRQ_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Geert Uytterhoeven | 92b1bd5 | 2011-05-31 11:11:01 +0200 | [diff] [blame] | 40 | static struct irq_chip amiga_irq_chip = { |
| 41 | .name = "amiga", |
| 42 | .irq_enable = amiga_irq_enable, |
| 43 | .irq_disable = amiga_irq_disable, |
| 44 | }; |
| 45 | |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* |
| 48 | * The builtin Amiga hardware interrupt handlers. |
| 49 | */ |
| 50 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 51 | static irqreturn_t ami_int1(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 53 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* if serial transmit buffer empty, interrupt */ |
| 56 | if (ints & IF_TBE) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 57 | amiga_custom.intreq = IF_TBE; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 58 | generic_handle_irq(IRQ_AMIGA_TBE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /* if floppy disk transfer complete, interrupt */ |
| 62 | if (ints & IF_DSKBLK) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 63 | amiga_custom.intreq = IF_DSKBLK; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 64 | generic_handle_irq(IRQ_AMIGA_DSKBLK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | /* if software interrupt set, interrupt */ |
| 68 | if (ints & IF_SOFT) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 69 | amiga_custom.intreq = IF_SOFT; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 70 | generic_handle_irq(IRQ_AMIGA_SOFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | return IRQ_HANDLED; |
| 73 | } |
| 74 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 75 | static irqreturn_t ami_int3(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 77 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | /* if a blitter interrupt */ |
| 80 | if (ints & IF_BLIT) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 81 | amiga_custom.intreq = IF_BLIT; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 82 | generic_handle_irq(IRQ_AMIGA_BLIT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* if a copper interrupt */ |
| 86 | if (ints & IF_COPER) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 87 | amiga_custom.intreq = IF_COPER; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 88 | generic_handle_irq(IRQ_AMIGA_COPPER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /* if a vertical blank interrupt */ |
Roman Zippel | 74be8d0 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 92 | if (ints & IF_VERTB) { |
| 93 | amiga_custom.intreq = IF_VERTB; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 94 | generic_handle_irq(IRQ_AMIGA_VERTB); |
Roman Zippel | 74be8d0 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 95 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return IRQ_HANDLED; |
| 97 | } |
| 98 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 99 | static irqreturn_t ami_int4(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 101 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | /* if audio 0 interrupt */ |
| 104 | if (ints & IF_AUD0) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 105 | amiga_custom.intreq = IF_AUD0; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 106 | generic_handle_irq(IRQ_AMIGA_AUD0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* if audio 1 interrupt */ |
| 110 | if (ints & IF_AUD1) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 111 | amiga_custom.intreq = IF_AUD1; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 112 | generic_handle_irq(IRQ_AMIGA_AUD1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* if audio 2 interrupt */ |
| 116 | if (ints & IF_AUD2) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 117 | amiga_custom.intreq = IF_AUD2; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 118 | generic_handle_irq(IRQ_AMIGA_AUD2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /* if audio 3 interrupt */ |
| 122 | if (ints & IF_AUD3) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 123 | amiga_custom.intreq = IF_AUD3; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 124 | generic_handle_irq(IRQ_AMIGA_AUD3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | } |
| 126 | return IRQ_HANDLED; |
| 127 | } |
| 128 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 129 | static irqreturn_t ami_int5(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 131 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | /* if serial receive buffer full interrupt */ |
| 134 | if (ints & IF_RBF) { |
| 135 | /* acknowledge of IF_RBF must be done by the serial interrupt */ |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 136 | generic_handle_irq(IRQ_AMIGA_RBF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /* if a disk sync interrupt */ |
| 140 | if (ints & IF_DSKSYN) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 141 | amiga_custom.intreq = IF_DSKSYN; |
Geert Uytterhoeven | 1425df8 | 2011-07-01 20:39:19 +0200 | [diff] [blame] | 142 | generic_handle_irq(IRQ_AMIGA_DSKSYN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } |
| 144 | return IRQ_HANDLED; |
| 145 | } |
Geert Uytterhoeven | 92b1bd5 | 2011-05-31 11:11:01 +0200 | [diff] [blame] | 146 | |
| 147 | |
| 148 | /* |
| 149 | * void amiga_init_IRQ(void) |
| 150 | * |
| 151 | * Parameters: None |
| 152 | * |
| 153 | * Returns: Nothing |
| 154 | * |
| 155 | * This function should be called during kernel startup to initialize |
| 156 | * the amiga IRQ handling routines. |
| 157 | */ |
| 158 | |
| 159 | void __init amiga_init_IRQ(void) |
| 160 | { |
| 161 | if (request_irq(IRQ_AUTO_1, ami_int1, 0, "int1", NULL)) |
| 162 | pr_err("Couldn't register int%d\n", 1); |
| 163 | if (request_irq(IRQ_AUTO_3, ami_int3, 0, "int3", NULL)) |
| 164 | pr_err("Couldn't register int%d\n", 3); |
| 165 | if (request_irq(IRQ_AUTO_4, ami_int4, 0, "int4", NULL)) |
| 166 | pr_err("Couldn't register int%d\n", 4); |
| 167 | if (request_irq(IRQ_AUTO_5, ami_int5, 0, "int5", NULL)) |
| 168 | pr_err("Couldn't register int%d\n", 5); |
| 169 | |
| 170 | m68k_setup_irq_controller(&amiga_irq_chip, handle_simple_irq, IRQ_USER, |
| 171 | AMI_STD_IRQS); |
| 172 | |
| 173 | /* turn off PCMCIA interrupts */ |
| 174 | if (AMIGAHW_PRESENT(PCMCIA)) |
| 175 | gayle.inten = GAYLE_IRQ_IDE; |
| 176 | |
| 177 | /* turn off all interrupts and enable the master interrupt bit */ |
| 178 | amiga_custom.intena = 0x7fff; |
| 179 | amiga_custom.intreq = 0x7fff; |
| 180 | amiga_custom.intena = IF_SETCLR | IF_INTEN; |
| 181 | |
| 182 | cia_init_IRQ(&ciaa_base); |
| 183 | cia_init_IRQ(&ciab_base); |
| 184 | } |