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