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