amiints.c 6.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * linux/arch/m68k/amiga/amiints.c -- Amiga Linux interrupt handling code
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive
 * for more details.
 *
 * 11/07/96: rewritten interrupt handling, irq lists are exists now only for
 *           this sources where it makes sense (VERTB/PORTS/EXTER) and you must
 *           be careful that dev_id for this sources is unique since this the
 *           only possibility to distinguish between different handlers for
 *           free_irq. irq lists also have different irq flags:
 *           - IRQ_FLG_FAST: handler is inserted at top of list (after other
 *                           fast handlers)
 *           - IRQ_FLG_SLOW: handler is inserted at bottom of list and before
 *                           they're executed irq level is set to the previous
 *                           one, but handlers don't need to be reentrant, if
 *                           reentrance occurred, slow handlers will be just
 *                           called again.
 *           The whole interrupt handling for CIAs is moved to cia.c
 *           /Roman Zippel
 *
 * 07/08/99: rewamp of the interrupt handling - we now have two types of
 *           interrupts, normal and fast handlers, fast handlers being
25
 *           marked with IRQF_DISABLED and runs with all other interrupts
L
Linus Torvalds 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38
 *           disabled. Normal interrupts disable their own source but
 *           run with all other interrupt sources enabled.
 *           PORTS and EXTER interrupts are always shared even if the
 *           drivers do not explicitly mark this when calling
 *           request_irq which they really should do.
 *           This is similar to the way interrupts are handled on all
 *           other architectures and makes a ton of sense besides
 *           having the advantage of making it easier to share
 *           drivers.
 *           /Jes
 */

#include <linux/init.h>
39
#include <linux/interrupt.h>
L
Linus Torvalds 已提交
40 41 42 43 44 45 46 47
#include <linux/errno.h>

#include <asm/irq.h>
#include <asm/traps.h>
#include <asm/amigahw.h>
#include <asm/amigaints.h>
#include <asm/amipcmcia.h>

48 49
static void amiga_enable_irq(unsigned int irq);
static void amiga_disable_irq(unsigned int irq);
A
Al Viro 已提交
50 51 52 53
static irqreturn_t ami_int1(int irq, void *dev_id);
static irqreturn_t ami_int3(int irq, void *dev_id);
static irqreturn_t ami_int4(int irq, void *dev_id);
static irqreturn_t ami_int5(int irq, void *dev_id);
54 55 56 57 58 59

static struct irq_controller amiga_irq_controller = {
	.name		= "amiga",
	.lock		= SPIN_LOCK_UNLOCKED,
	.enable		= amiga_enable_irq,
	.disable	= amiga_disable_irq,
L
Linus Torvalds 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
};

/*
 * void amiga_init_IRQ(void)
 *
 * Parameters:	None
 *
 * Returns:	Nothing
 *
 * This function should be called during kernel startup to initialize
 * the amiga IRQ handling routines.
 */

void __init amiga_init_IRQ(void)
{
75 76 77 78
	request_irq(IRQ_AUTO_1, ami_int1, 0, "int1", NULL);
	request_irq(IRQ_AUTO_3, ami_int3, 0, "int3", NULL);
	request_irq(IRQ_AUTO_4, ami_int4, 0, "int4", NULL);
	request_irq(IRQ_AUTO_5, ami_int5, 0, "int5", NULL);
L
Linus Torvalds 已提交
79

80
	m68k_setup_irq_controller(&amiga_irq_controller, IRQ_USER, AMI_STD_IRQS);
L
Linus Torvalds 已提交
81 82 83 84 85 86

	/* turn off PCMCIA interrupts */
	if (AMIGAHW_PRESENT(PCMCIA))
		gayle.inten = GAYLE_IRQ_IDE;

	/* turn off all interrupts and enable the master interrupt bit */
87 88 89
	amiga_custom.intena = 0x7fff;
	amiga_custom.intreq = 0x7fff;
	amiga_custom.intena = IF_SETCLR | IF_INTEN;
L
Linus Torvalds 已提交
90 91 92 93 94 95 96 97 98 99 100 101

	cia_init_IRQ(&ciaa_base);
	cia_init_IRQ(&ciab_base);
}

/*
 * Enable/disable a particular machine specific interrupt source.
 * Note that this may affect other interrupts in case of a shared interrupt.
 * This function should only be called for a _very_ short time to change some
 * internal data, that may not be changed by the interrupt at the same time.
 */

102
static void amiga_enable_irq(unsigned int irq)
L
Linus Torvalds 已提交
103
{
104
	amiga_custom.intena = IF_SETCLR | (1 << (irq - IRQ_USER));
L
Linus Torvalds 已提交
105 106
}

107
static void amiga_disable_irq(unsigned int irq)
L
Linus Torvalds 已提交
108
{
109
	amiga_custom.intena = 1 << (irq - IRQ_USER);
L
Linus Torvalds 已提交
110 111 112 113 114 115
}

/*
 * The builtin Amiga hardware interrupt handlers.
 */

A
Al Viro 已提交
116
static irqreturn_t ami_int1(int irq, void *dev_id)
L
Linus Torvalds 已提交
117
{
118
	unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
L
Linus Torvalds 已提交
119 120 121

	/* if serial transmit buffer empty, interrupt */
	if (ints & IF_TBE) {
122
		amiga_custom.intreq = IF_TBE;
A
Al Viro 已提交
123
		m68k_handle_int(IRQ_AMIGA_TBE);
L
Linus Torvalds 已提交
124 125 126 127
	}

	/* if floppy disk transfer complete, interrupt */
	if (ints & IF_DSKBLK) {
128
		amiga_custom.intreq = IF_DSKBLK;
A
Al Viro 已提交
129
		m68k_handle_int(IRQ_AMIGA_DSKBLK);
L
Linus Torvalds 已提交
130 131 132 133
	}

	/* if software interrupt set, interrupt */
	if (ints & IF_SOFT) {
134
		amiga_custom.intreq = IF_SOFT;
A
Al Viro 已提交
135
		m68k_handle_int(IRQ_AMIGA_SOFT);
L
Linus Torvalds 已提交
136 137 138 139
	}
	return IRQ_HANDLED;
}

A
Al Viro 已提交
140
static irqreturn_t ami_int3(int irq, void *dev_id)
L
Linus Torvalds 已提交
141
{
142
	unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
L
Linus Torvalds 已提交
143 144 145

	/* if a blitter interrupt */
	if (ints & IF_BLIT) {
146
		amiga_custom.intreq = IF_BLIT;
A
Al Viro 已提交
147
		m68k_handle_int(IRQ_AMIGA_BLIT);
L
Linus Torvalds 已提交
148 149 150 151
	}

	/* if a copper interrupt */
	if (ints & IF_COPER) {
152
		amiga_custom.intreq = IF_COPER;
A
Al Viro 已提交
153
		m68k_handle_int(IRQ_AMIGA_COPPER);
L
Linus Torvalds 已提交
154 155 156
	}

	/* if a vertical blank interrupt */
157 158
	if (ints & IF_VERTB) {
		amiga_custom.intreq = IF_VERTB;
A
Al Viro 已提交
159
		m68k_handle_int(IRQ_AMIGA_VERTB);
160
	}
L
Linus Torvalds 已提交
161 162 163
	return IRQ_HANDLED;
}

A
Al Viro 已提交
164
static irqreturn_t ami_int4(int irq, void *dev_id)
L
Linus Torvalds 已提交
165
{
166
	unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
L
Linus Torvalds 已提交
167 168 169

	/* if audio 0 interrupt */
	if (ints & IF_AUD0) {
170
		amiga_custom.intreq = IF_AUD0;
A
Al Viro 已提交
171
		m68k_handle_int(IRQ_AMIGA_AUD0);
L
Linus Torvalds 已提交
172 173 174 175
	}

	/* if audio 1 interrupt */
	if (ints & IF_AUD1) {
176
		amiga_custom.intreq = IF_AUD1;
A
Al Viro 已提交
177
		m68k_handle_int(IRQ_AMIGA_AUD1);
L
Linus Torvalds 已提交
178 179 180 181
	}

	/* if audio 2 interrupt */
	if (ints & IF_AUD2) {
182
		amiga_custom.intreq = IF_AUD2;
A
Al Viro 已提交
183
		m68k_handle_int(IRQ_AMIGA_AUD2);
L
Linus Torvalds 已提交
184 185 186 187
	}

	/* if audio 3 interrupt */
	if (ints & IF_AUD3) {
188
		amiga_custom.intreq = IF_AUD3;
A
Al Viro 已提交
189
		m68k_handle_int(IRQ_AMIGA_AUD3);
L
Linus Torvalds 已提交
190 191 192 193
	}
	return IRQ_HANDLED;
}

A
Al Viro 已提交
194
static irqreturn_t ami_int5(int irq, void *dev_id)
L
Linus Torvalds 已提交
195
{
196
	unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
L
Linus Torvalds 已提交
197 198 199 200

	/* if serial receive buffer full interrupt */
	if (ints & IF_RBF) {
		/* acknowledge of IF_RBF must be done by the serial interrupt */
A
Al Viro 已提交
201
		m68k_handle_int(IRQ_AMIGA_RBF);
L
Linus Torvalds 已提交
202 203 204 205
	}

	/* if a disk sync interrupt */
	if (ints & IF_DSKSYN) {
206
		amiga_custom.intreq = IF_DSKSYN;
A
Al Viro 已提交
207
		m68k_handle_int(IRQ_AMIGA_DSKSYN);
L
Linus Torvalds 已提交
208 209 210
	}
	return IRQ_HANDLED;
}