blob: c3da5342f495b2be440d357c761b34ebb07dc3f5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Geert Uytterhoeven92b1bd52011-05-31 11:11:01 +02002 * Amiga Linux interrupt handling code
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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 Torvalds1da177e2005-04-16 15:20:36 -07007 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/init.h>
Roman Zippelb5dc7842006-06-25 05:47:00 -070010#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/errno.h>
Geert Uytterhoeven978ef7e2011-05-31 22:08:28 +020012#ifdef CONFIG_GENERIC_HARDIRQS
13#include <linux/irq.h>
14#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#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 Torvalds1da177e2005-04-16 15:20:36 -070022
Linus Torvalds1da177e2005-04-16 15:20:36 -070023/*
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 Torvalds1da177e2005-04-16 15:20:36 -070028 */
29
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020030static void amiga_irq_enable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020032 amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER));
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}
34
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020035static void amiga_irq_disable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020037 amiga_custom.intena = 1 << (data->irq - IRQ_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
Geert Uytterhoeven92b1bd52011-05-31 11:11:01 +020040static 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 Torvalds1da177e2005-04-16 15:20:36 -070047/*
48 * The builtin Amiga hardware interrupt handlers.
49 */
50
Al Viro2850bc22006-10-07 14:16:45 +010051static irqreturn_t ami_int1(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
Al Virob4290a22006-01-12 01:06:12 -080053 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 /* if serial transmit buffer empty, interrupt */
56 if (ints & IF_TBE) {
Al Virob4290a22006-01-12 01:06:12 -080057 amiga_custom.intreq = IF_TBE;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020058 generic_handle_irq(IRQ_AMIGA_TBE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 }
60
61 /* if floppy disk transfer complete, interrupt */
62 if (ints & IF_DSKBLK) {
Al Virob4290a22006-01-12 01:06:12 -080063 amiga_custom.intreq = IF_DSKBLK;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020064 generic_handle_irq(IRQ_AMIGA_DSKBLK);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 }
66
67 /* if software interrupt set, interrupt */
68 if (ints & IF_SOFT) {
Al Virob4290a22006-01-12 01:06:12 -080069 amiga_custom.intreq = IF_SOFT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020070 generic_handle_irq(IRQ_AMIGA_SOFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 }
72 return IRQ_HANDLED;
73}
74
Al Viro2850bc22006-10-07 14:16:45 +010075static irqreturn_t ami_int3(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Al Virob4290a22006-01-12 01:06:12 -080077 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 /* if a blitter interrupt */
80 if (ints & IF_BLIT) {
Al Virob4290a22006-01-12 01:06:12 -080081 amiga_custom.intreq = IF_BLIT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020082 generic_handle_irq(IRQ_AMIGA_BLIT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 }
84
85 /* if a copper interrupt */
86 if (ints & IF_COPER) {
Al Virob4290a22006-01-12 01:06:12 -080087 amiga_custom.intreq = IF_COPER;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020088 generic_handle_irq(IRQ_AMIGA_COPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90
91 /* if a vertical blank interrupt */
Roman Zippel74be8d02006-06-25 05:47:01 -070092 if (ints & IF_VERTB) {
93 amiga_custom.intreq = IF_VERTB;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020094 generic_handle_irq(IRQ_AMIGA_VERTB);
Roman Zippel74be8d02006-06-25 05:47:01 -070095 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 return IRQ_HANDLED;
97}
98
Al Viro2850bc22006-10-07 14:16:45 +010099static irqreturn_t ami_int4(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Al Virob4290a22006-01-12 01:06:12 -0800101 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103 /* if audio 0 interrupt */
104 if (ints & IF_AUD0) {
Al Virob4290a22006-01-12 01:06:12 -0800105 amiga_custom.intreq = IF_AUD0;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200106 generic_handle_irq(IRQ_AMIGA_AUD0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 }
108
109 /* if audio 1 interrupt */
110 if (ints & IF_AUD1) {
Al Virob4290a22006-01-12 01:06:12 -0800111 amiga_custom.intreq = IF_AUD1;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200112 generic_handle_irq(IRQ_AMIGA_AUD1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
114
115 /* if audio 2 interrupt */
116 if (ints & IF_AUD2) {
Al Virob4290a22006-01-12 01:06:12 -0800117 amiga_custom.intreq = IF_AUD2;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200118 generic_handle_irq(IRQ_AMIGA_AUD2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 }
120
121 /* if audio 3 interrupt */
122 if (ints & IF_AUD3) {
Al Virob4290a22006-01-12 01:06:12 -0800123 amiga_custom.intreq = IF_AUD3;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200124 generic_handle_irq(IRQ_AMIGA_AUD3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 }
126 return IRQ_HANDLED;
127}
128
Al Viro2850bc22006-10-07 14:16:45 +0100129static irqreturn_t ami_int5(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130{
Al Virob4290a22006-01-12 01:06:12 -0800131 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
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 Uytterhoeven1425df82011-07-01 20:39:19 +0200136 generic_handle_irq(IRQ_AMIGA_RBF);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 }
138
139 /* if a disk sync interrupt */
140 if (ints & IF_DSKSYN) {
Al Virob4290a22006-01-12 01:06:12 -0800141 amiga_custom.intreq = IF_DSKSYN;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200142 generic_handle_irq(IRQ_AMIGA_DSKSYN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 }
144 return IRQ_HANDLED;
145}
Geert Uytterhoeven92b1bd52011-05-31 11:11:01 +0200146
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
159void __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}