blob: c8f9eac121a17762d1365acf7aa7bd85e8d40c68 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#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 Torvalds1da177e2005-04-16 15:20:36 -070019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020/*
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 Torvalds1da177e2005-04-16 15:20:36 -070025 */
26
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020027static void amiga_irq_enable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020029 amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER));
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020032static void amiga_irq_disable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020034 amiga_custom.intena = 1 << (data->irq - IRQ_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
36
Geert Uytterhoeven92b1bd52011-05-31 11:11:01 +020037static 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 Torvalds1da177e2005-04-16 15:20:36 -070044/*
45 * The builtin Amiga hardware interrupt handlers.
46 */
47
Al Viro2850bc22006-10-07 14:16:45 +010048static irqreturn_t ami_int1(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Al Virob4290a22006-01-12 01:06:12 -080050 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 /* if serial transmit buffer empty, interrupt */
53 if (ints & IF_TBE) {
Al Virob4290a22006-01-12 01:06:12 -080054 amiga_custom.intreq = IF_TBE;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020055 generic_handle_irq(IRQ_AMIGA_TBE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 }
57
58 /* if floppy disk transfer complete, interrupt */
59 if (ints & IF_DSKBLK) {
Al Virob4290a22006-01-12 01:06:12 -080060 amiga_custom.intreq = IF_DSKBLK;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020061 generic_handle_irq(IRQ_AMIGA_DSKBLK);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 }
63
64 /* if software interrupt set, interrupt */
65 if (ints & IF_SOFT) {
Al Virob4290a22006-01-12 01:06:12 -080066 amiga_custom.intreq = IF_SOFT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020067 generic_handle_irq(IRQ_AMIGA_SOFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 }
69 return IRQ_HANDLED;
70}
71
Al Viro2850bc22006-10-07 14:16:45 +010072static irqreturn_t ami_int3(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
Al Virob4290a22006-01-12 01:06:12 -080074 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76 /* if a blitter interrupt */
77 if (ints & IF_BLIT) {
Al Virob4290a22006-01-12 01:06:12 -080078 amiga_custom.intreq = IF_BLIT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020079 generic_handle_irq(IRQ_AMIGA_BLIT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 }
81
82 /* if a copper interrupt */
83 if (ints & IF_COPER) {
Al Virob4290a22006-01-12 01:06:12 -080084 amiga_custom.intreq = IF_COPER;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020085 generic_handle_irq(IRQ_AMIGA_COPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 }
87
88 /* if a vertical blank interrupt */
Roman Zippel74be8d02006-06-25 05:47:01 -070089 if (ints & IF_VERTB) {
90 amiga_custom.intreq = IF_VERTB;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020091 generic_handle_irq(IRQ_AMIGA_VERTB);
Roman Zippel74be8d02006-06-25 05:47:01 -070092 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 return IRQ_HANDLED;
94}
95
Al Viro2850bc22006-10-07 14:16:45 +010096static irqreturn_t ami_int4(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Al Virob4290a22006-01-12 01:06:12 -080098 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 /* if audio 0 interrupt */
101 if (ints & IF_AUD0) {
Al Virob4290a22006-01-12 01:06:12 -0800102 amiga_custom.intreq = IF_AUD0;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200103 generic_handle_irq(IRQ_AMIGA_AUD0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105
106 /* if audio 1 interrupt */
107 if (ints & IF_AUD1) {
Al Virob4290a22006-01-12 01:06:12 -0800108 amiga_custom.intreq = IF_AUD1;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200109 generic_handle_irq(IRQ_AMIGA_AUD1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 }
111
112 /* if audio 2 interrupt */
113 if (ints & IF_AUD2) {
Al Virob4290a22006-01-12 01:06:12 -0800114 amiga_custom.intreq = IF_AUD2;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200115 generic_handle_irq(IRQ_AMIGA_AUD2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 }
117
118 /* if audio 3 interrupt */
119 if (ints & IF_AUD3) {
Al Virob4290a22006-01-12 01:06:12 -0800120 amiga_custom.intreq = IF_AUD3;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200121 generic_handle_irq(IRQ_AMIGA_AUD3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 }
123 return IRQ_HANDLED;
124}
125
Al Viro2850bc22006-10-07 14:16:45 +0100126static irqreturn_t ami_int5(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
Al Virob4290a22006-01-12 01:06:12 -0800128 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
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 Uytterhoeven1425df82011-07-01 20:39:19 +0200133 generic_handle_irq(IRQ_AMIGA_RBF);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 }
135
136 /* if a disk sync interrupt */
137 if (ints & IF_DSKSYN) {
Al Virob4290a22006-01-12 01:06:12 -0800138 amiga_custom.intreq = IF_DSKSYN;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200139 generic_handle_irq(IRQ_AMIGA_DSKSYN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 }
141 return IRQ_HANDLED;
142}
Geert Uytterhoeven92b1bd52011-05-31 11:11:01 +0200143
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
156void __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}