Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68k/amiga/amiints.c -- Amiga Linux interrupt handling code |
| 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. |
| 7 | * |
| 8 | * 11/07/96: rewritten interrupt handling, irq lists are exists now only for |
| 9 | * this sources where it makes sense (VERTB/PORTS/EXTER) and you must |
| 10 | * be careful that dev_id for this sources is unique since this the |
| 11 | * only possibility to distinguish between different handlers for |
| 12 | * free_irq. irq lists also have different irq flags: |
| 13 | * - IRQ_FLG_FAST: handler is inserted at top of list (after other |
| 14 | * fast handlers) |
| 15 | * - IRQ_FLG_SLOW: handler is inserted at bottom of list and before |
| 16 | * they're executed irq level is set to the previous |
| 17 | * one, but handlers don't need to be reentrant, if |
| 18 | * reentrance occurred, slow handlers will be just |
| 19 | * called again. |
| 20 | * The whole interrupt handling for CIAs is moved to cia.c |
| 21 | * /Roman Zippel |
| 22 | * |
| 23 | * 07/08/99: rewamp of the interrupt handling - we now have two types of |
| 24 | * interrupts, normal and fast handlers, fast handlers being |
Thomas Gleixner | b0b9fdc | 2006-07-01 19:29:19 -0700 | [diff] [blame] | 25 | * marked with IRQF_DISABLED and runs with all other interrupts |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | * disabled. Normal interrupts disable their own source but |
| 27 | * run with all other interrupt sources enabled. |
| 28 | * PORTS and EXTER interrupts are always shared even if the |
| 29 | * drivers do not explicitly mark this when calling |
| 30 | * request_irq which they really should do. |
| 31 | * This is similar to the way interrupts are handled on all |
| 32 | * other architectures and makes a ton of sense besides |
| 33 | * having the advantage of making it easier to share |
| 34 | * drivers. |
| 35 | * /Jes |
| 36 | */ |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <linux/init.h> |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 39 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/errno.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/irq.h> |
| 43 | #include <asm/traps.h> |
| 44 | #include <asm/amigahw.h> |
| 45 | #include <asm/amigaints.h> |
| 46 | #include <asm/amipcmcia.h> |
| 47 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 48 | static void amiga_irq_enable(struct irq_data *data); |
| 49 | static void amiga_irq_disable(struct irq_data *data); |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 50 | static irqreturn_t ami_int1(int irq, void *dev_id); |
| 51 | static irqreturn_t ami_int3(int irq, void *dev_id); |
| 52 | static irqreturn_t ami_int4(int irq, void *dev_id); |
| 53 | static irqreturn_t ami_int5(int irq, void *dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 55 | static struct irq_chip amiga_irq_chip = { |
Roman Zippel | 74be8d0 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 56 | .name = "amiga", |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 57 | .irq_enable = amiga_irq_enable, |
| 58 | .irq_disable = amiga_irq_disable, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * void amiga_init_IRQ(void) |
| 63 | * |
| 64 | * Parameters: None |
| 65 | * |
| 66 | * Returns: Nothing |
| 67 | * |
| 68 | * This function should be called during kernel startup to initialize |
| 69 | * the amiga IRQ handling routines. |
| 70 | */ |
| 71 | |
| 72 | void __init amiga_init_IRQ(void) |
| 73 | { |
Geert Uytterhoeven | 66acd25 | 2008-12-30 14:00:34 +0100 | [diff] [blame] | 74 | if (request_irq(IRQ_AUTO_1, ami_int1, 0, "int1", NULL)) |
| 75 | pr_err("Couldn't register int%d\n", 1); |
| 76 | if (request_irq(IRQ_AUTO_3, ami_int3, 0, "int3", NULL)) |
| 77 | pr_err("Couldn't register int%d\n", 3); |
| 78 | if (request_irq(IRQ_AUTO_4, ami_int4, 0, "int4", NULL)) |
| 79 | pr_err("Couldn't register int%d\n", 4); |
| 80 | if (request_irq(IRQ_AUTO_5, ami_int5, 0, "int5", NULL)) |
| 81 | pr_err("Couldn't register int%d\n", 5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 83 | m68k_setup_irq_chip(&amiga_irq_chip, IRQ_USER, AMI_STD_IRQS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /* turn off PCMCIA interrupts */ |
| 86 | if (AMIGAHW_PRESENT(PCMCIA)) |
| 87 | gayle.inten = GAYLE_IRQ_IDE; |
| 88 | |
| 89 | /* turn off all interrupts and enable the master interrupt bit */ |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 90 | amiga_custom.intena = 0x7fff; |
| 91 | amiga_custom.intreq = 0x7fff; |
| 92 | amiga_custom.intena = IF_SETCLR | IF_INTEN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | cia_init_IRQ(&ciaa_base); |
| 95 | cia_init_IRQ(&ciab_base); |
| 96 | } |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | /* |
| 99 | * Enable/disable a particular machine specific interrupt source. |
| 100 | * Note that this may affect other interrupts in case of a shared interrupt. |
| 101 | * This function should only be called for a _very_ short time to change some |
| 102 | * 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] | 103 | */ |
| 104 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 105 | static void amiga_irq_enable(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | { |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 107 | amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 110 | static void amiga_irq_disable(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
Geert Uytterhoeven | e8abf5e | 2011-04-17 22:53:04 +0200 | [diff] [blame^] | 112 | amiga_custom.intena = 1 << (data->irq - IRQ_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* |
| 116 | * The builtin Amiga hardware interrupt handlers. |
| 117 | */ |
| 118 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 119 | static irqreturn_t ami_int1(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 121 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | /* if serial transmit buffer empty, interrupt */ |
| 124 | if (ints & IF_TBE) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 125 | amiga_custom.intreq = IF_TBE; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 126 | m68k_handle_int(IRQ_AMIGA_TBE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /* if floppy disk transfer complete, interrupt */ |
| 130 | if (ints & IF_DSKBLK) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 131 | amiga_custom.intreq = IF_DSKBLK; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 132 | m68k_handle_int(IRQ_AMIGA_DSKBLK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /* if software interrupt set, interrupt */ |
| 136 | if (ints & IF_SOFT) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 137 | amiga_custom.intreq = IF_SOFT; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 138 | m68k_handle_int(IRQ_AMIGA_SOFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | return IRQ_HANDLED; |
| 141 | } |
| 142 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 143 | static irqreturn_t ami_int3(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 145 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | /* if a blitter interrupt */ |
| 148 | if (ints & IF_BLIT) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 149 | amiga_custom.intreq = IF_BLIT; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 150 | m68k_handle_int(IRQ_AMIGA_BLIT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /* if a copper interrupt */ |
| 154 | if (ints & IF_COPER) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 155 | amiga_custom.intreq = IF_COPER; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 156 | m68k_handle_int(IRQ_AMIGA_COPPER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /* if a vertical blank interrupt */ |
Roman Zippel | 74be8d0 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 160 | if (ints & IF_VERTB) { |
| 161 | amiga_custom.intreq = IF_VERTB; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 162 | m68k_handle_int(IRQ_AMIGA_VERTB); |
Roman Zippel | 74be8d0 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | return IRQ_HANDLED; |
| 165 | } |
| 166 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 167 | static irqreturn_t ami_int4(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 169 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | /* if audio 0 interrupt */ |
| 172 | if (ints & IF_AUD0) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 173 | amiga_custom.intreq = IF_AUD0; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 174 | m68k_handle_int(IRQ_AMIGA_AUD0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* if audio 1 interrupt */ |
| 178 | if (ints & IF_AUD1) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 179 | amiga_custom.intreq = IF_AUD1; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 180 | m68k_handle_int(IRQ_AMIGA_AUD1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /* if audio 2 interrupt */ |
| 184 | if (ints & IF_AUD2) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 185 | amiga_custom.intreq = IF_AUD2; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 186 | m68k_handle_int(IRQ_AMIGA_AUD2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* if audio 3 interrupt */ |
| 190 | if (ints & IF_AUD3) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 191 | amiga_custom.intreq = IF_AUD3; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 192 | m68k_handle_int(IRQ_AMIGA_AUD3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | } |
| 194 | return IRQ_HANDLED; |
| 195 | } |
| 196 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 197 | static irqreturn_t ami_int5(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 199 | unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
| 201 | /* if serial receive buffer full interrupt */ |
| 202 | if (ints & IF_RBF) { |
| 203 | /* acknowledge of IF_RBF must be done by the serial interrupt */ |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 204 | m68k_handle_int(IRQ_AMIGA_RBF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | /* if a disk sync interrupt */ |
| 208 | if (ints & IF_DSKSYN) { |
Al Viro | b4290a2 | 2006-01-12 01:06:12 -0800 | [diff] [blame] | 209 | amiga_custom.intreq = IF_DSKSYN; |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 210 | m68k_handle_int(IRQ_AMIGA_DSKSYN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | return IRQ_HANDLED; |
| 213 | } |