ints.c 4.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general 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.
 */

#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched.h>
12
#include <linux/interrupt.h>
L
Linus Torvalds 已提交
13 14 15 16 17 18 19 20 21 22
#include <linux/kernel_stat.h>
#include <linux/errno.h>
#include <linux/init.h>

#include <asm/setup.h>
#include <asm/system.h>
#include <asm/irq.h>
#include <asm/traps.h>
#include <asm/page.h>
#include <asm/machdep.h>
23
#include <asm/cacheflush.h>
A
Al Viro 已提交
24
#include <asm/irq_regs.h>
L
Linus Torvalds 已提交
25 26 27 28 29

#ifdef CONFIG_Q40
#include <asm/q40ints.h>
#endif

30 31 32 33 34
extern u32 auto_irqhandler_fixup[];
extern u32 user_irqhandler_fixup[];
extern u16 user_irqvec_fixup[];

static int m68k_first_user_vec;
35

36
static struct irq_chip auto_irq_chip = {
37
	.name		= "auto",
38 39
	.irq_startup	= m68k_irq_startup,
	.irq_shutdown	= m68k_irq_shutdown,
40
};
L
Linus Torvalds 已提交
41

42
static struct irq_chip user_irq_chip = {
43
	.name		= "user",
44 45
	.irq_startup	= m68k_irq_startup,
	.irq_shutdown	= m68k_irq_shutdown,
L
Linus Torvalds 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
};

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

void __init init_IRQ(void)
{
	int i;

63 64 65 66 67 68
	/* assembly irq entry code relies on this... */
	if (HARDIRQ_MASK != 0x00ff0000) {
		extern void hardirq_mask_is_broken(void);
		hardirq_mask_is_broken();
	}

69
	for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
G
Geert Uytterhoeven 已提交
70
		irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
L
Linus Torvalds 已提交
71

72 73 74 75 76 77 78 79
	mach_init_IRQ();
}

/**
 * m68k_setup_auto_interrupt
 * @handler: called from auto vector interrupts
 *
 * setup the handler to be called from auto vector interrupts instead of the
80
 * standard do_IRQ(), it will be called with irq numbers in the range
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
 * from IRQ_AUTO_1 - IRQ_AUTO_7.
 */
void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
{
	if (handler)
		*auto_irqhandler_fixup = (u32)handler;
	flush_icache();
}

/**
 * m68k_setup_user_interrupt
 * @vec: first user vector interrupt to handle
 * @cnt: number of active user vector interrupts
 * @handler: called from user vector interrupts
 *
 * setup user vector interrupts, this includes activating the specified range
 * of interrupts, only then these interrupts can be requested (note: this is
 * different from auto vector interrupts). An optional handler can be installed
99
 * to be called instead of the default do_IRQ(), it will be called
100 101 102 103 104 105 106
 * with irq numbers starting from IRQ_USER.
 */
void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt,
				      void (*handler)(unsigned int, struct pt_regs *))
{
	int i;

107
	BUG_ON(IRQ_USER + cnt > NR_IRQS);
108 109
	m68k_first_user_vec = vec;
	for (i = 0; i < cnt; i++)
110
		irq_set_chip(IRQ_USER + i, &user_irq_chip);
111 112 113 114 115 116
	*user_irqvec_fixup = vec - IRQ_USER;
	if (handler)
		*user_irqhandler_fixup = (u32)handler;
	flush_icache();
}

G
Geert Uytterhoeven 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
/**
 * m68k_setup_irq_controller
 * @chip: irq chip which controls specified irq
 * @handle: flow handler which handles specified irq
 * @irq: first irq to be managed by the controller
 * @cnt: number of irqs to be managed by the controller
 *
 * Change the controller for the specified range of irq, which will be used to
 * manage these irq. auto/user irq already have a default controller, which can
 * be changed as well, but the controller probably should use m68k_irq_startup/
 * m68k_irq_shutdown.
 */
void m68k_setup_irq_controller(struct irq_chip *chip,
			       irq_flow_handler_t handle, unsigned int irq,
			       unsigned int cnt)
{
	int i;

	for (i = 0; i < cnt; i++) {
		irq_set_chip(irq + i, chip);
		if (handle)
			irq_set_handler(irq + i, handle);
	}
}

142
unsigned int m68k_irq_startup_irq(unsigned int irq)
143 144 145
{
	if (irq <= IRQ_AUTO_7)
		vectors[VEC_SPUR + irq] = auto_inthandler;
146 147
	else
		vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
148 149 150
	return 0;
}

151
unsigned int m68k_irq_startup(struct irq_data *data)
152
{
153 154 155 156 157 158 159
	return m68k_irq_startup_irq(data->irq);
}

void m68k_irq_shutdown(struct irq_data *data)
{
	unsigned int irq = data->irq;

160 161
	if (irq <= IRQ_AUTO_7)
		vectors[VEC_SPUR + irq] = bad_inthandler;
162 163
	else
		vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
164 165 166
}


167
unsigned int irq_canonicalize(unsigned int irq)
L
Linus Torvalds 已提交
168
{
169 170 171 172 173
#ifdef CONFIG_Q40
	if (MACH_IS_Q40 && irq == 11)
		irq = 10;
#endif
	return irq;
L
Linus Torvalds 已提交
174 175
}

176
EXPORT_SYMBOL(irq_canonicalize);
L
Linus Torvalds 已提交
177

G
Geert Uytterhoeven 已提交
178 179 180 181 182 183

asmlinkage void handle_badint(struct pt_regs *regs)
{
	atomic_inc(&irq_err_count);
	pr_warn("unexpected interrupt from %u\n", regs->vector);
}