blob: e5f3033499e72cb597daf9081f2db79d63c2478e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 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
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020019static void amiga_irq_enable(struct irq_data *data);
20static void amiga_irq_disable(struct irq_data *data);
Al Viro2850bc22006-10-07 14:16:45 +010021static irqreturn_t ami_int1(int irq, void *dev_id);
22static irqreturn_t ami_int3(int irq, void *dev_id);
23static irqreturn_t ami_int4(int irq, void *dev_id);
24static irqreturn_t ami_int5(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020026static struct irq_chip amiga_irq_chip = {
Roman Zippel74be8d02006-06-25 05:47:01 -070027 .name = "amiga",
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020028 .irq_enable = amiga_irq_enable,
29 .irq_disable = amiga_irq_disable,
Linus Torvalds1da177e2005-04-16 15:20:36 -070030};
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
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
43void __init amiga_init_IRQ(void)
44{
Geert Uytterhoeven66acd252008-12-30 14:00:34 +010045 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 Torvalds1da177e2005-04-16 15:20:36 -070053
Geert Uytterhoevenedb34722011-06-01 11:15:21 +020054 m68k_setup_irq_controller(&amiga_irq_chip, handle_simple_irq, IRQ_USER,
55 AMI_STD_IRQS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
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 Virob4290a22006-01-12 01:06:12 -080062 amiga_custom.intena = 0x7fff;
63 amiga_custom.intreq = 0x7fff;
64 amiga_custom.intena = IF_SETCLR | IF_INTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66 cia_init_IRQ(&ciaa_base);
67 cia_init_IRQ(&ciab_base);
68}
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070/*
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 Torvalds1da177e2005-04-16 15:20:36 -070075 */
76
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020077static void amiga_irq_enable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020079 amiga_custom.intena = IF_SETCLR | (1 << (data->irq - IRQ_USER));
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
81
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020082static void amiga_irq_disable(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +020084 amiga_custom.intena = 1 << (data->irq - IRQ_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
86
87/*
88 * The builtin Amiga hardware interrupt handlers.
89 */
90
Al Viro2850bc22006-10-07 14:16:45 +010091static irqreturn_t ami_int1(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
Al Virob4290a22006-01-12 01:06:12 -080093 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 /* if serial transmit buffer empty, interrupt */
96 if (ints & IF_TBE) {
Al Virob4290a22006-01-12 01:06:12 -080097 amiga_custom.intreq = IF_TBE;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020098 generic_handle_irq(IRQ_AMIGA_TBE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 }
100
101 /* if floppy disk transfer complete, interrupt */
102 if (ints & IF_DSKBLK) {
Al Virob4290a22006-01-12 01:06:12 -0800103 amiga_custom.intreq = IF_DSKBLK;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200104 generic_handle_irq(IRQ_AMIGA_DSKBLK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 }
106
107 /* if software interrupt set, interrupt */
108 if (ints & IF_SOFT) {
Al Virob4290a22006-01-12 01:06:12 -0800109 amiga_custom.intreq = IF_SOFT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200110 generic_handle_irq(IRQ_AMIGA_SOFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 }
112 return IRQ_HANDLED;
113}
114
Al Viro2850bc22006-10-07 14:16:45 +0100115static irqreturn_t ami_int3(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Al Virob4290a22006-01-12 01:06:12 -0800117 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119 /* if a blitter interrupt */
120 if (ints & IF_BLIT) {
Al Virob4290a22006-01-12 01:06:12 -0800121 amiga_custom.intreq = IF_BLIT;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200122 generic_handle_irq(IRQ_AMIGA_BLIT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 }
124
125 /* if a copper interrupt */
126 if (ints & IF_COPER) {
Al Virob4290a22006-01-12 01:06:12 -0800127 amiga_custom.intreq = IF_COPER;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200128 generic_handle_irq(IRQ_AMIGA_COPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 }
130
131 /* if a vertical blank interrupt */
Roman Zippel74be8d02006-06-25 05:47:01 -0700132 if (ints & IF_VERTB) {
133 amiga_custom.intreq = IF_VERTB;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200134 generic_handle_irq(IRQ_AMIGA_VERTB);
Roman Zippel74be8d02006-06-25 05:47:01 -0700135 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 return IRQ_HANDLED;
137}
138
Al Viro2850bc22006-10-07 14:16:45 +0100139static irqreturn_t ami_int4(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Al Virob4290a22006-01-12 01:06:12 -0800141 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143 /* if audio 0 interrupt */
144 if (ints & IF_AUD0) {
Al Virob4290a22006-01-12 01:06:12 -0800145 amiga_custom.intreq = IF_AUD0;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200146 generic_handle_irq(IRQ_AMIGA_AUD0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
148
149 /* if audio 1 interrupt */
150 if (ints & IF_AUD1) {
Al Virob4290a22006-01-12 01:06:12 -0800151 amiga_custom.intreq = IF_AUD1;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200152 generic_handle_irq(IRQ_AMIGA_AUD1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 }
154
155 /* if audio 2 interrupt */
156 if (ints & IF_AUD2) {
Al Virob4290a22006-01-12 01:06:12 -0800157 amiga_custom.intreq = IF_AUD2;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200158 generic_handle_irq(IRQ_AMIGA_AUD2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 }
160
161 /* if audio 3 interrupt */
162 if (ints & IF_AUD3) {
Al Virob4290a22006-01-12 01:06:12 -0800163 amiga_custom.intreq = IF_AUD3;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200164 generic_handle_irq(IRQ_AMIGA_AUD3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 }
166 return IRQ_HANDLED;
167}
168
Al Viro2850bc22006-10-07 14:16:45 +0100169static irqreturn_t ami_int5(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
Al Virob4290a22006-01-12 01:06:12 -0800171 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
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 Uytterhoeven1425df82011-07-01 20:39:19 +0200176 generic_handle_irq(IRQ_AMIGA_RBF);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 }
178
179 /* if a disk sync interrupt */
180 if (ints & IF_DSKSYN) {
Al Virob4290a22006-01-12 01:06:12 -0800181 amiga_custom.intreq = IF_DSKSYN;
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200182 generic_handle_irq(IRQ_AMIGA_DSKSYN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 }
184 return IRQ_HANDLED;
185}