blob: 4d7da384eea03d5a1101859a5814c7dccce53a9e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general 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/module.h>
10#include <linux/types.h>
11#include <linux/sched.h>
Andrew Morton6168a702007-02-17 21:22:39 -080012#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/kernel_stat.h>
14#include <linux/errno.h>
15#include <linux/init.h>
16
17#include <asm/setup.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/irq.h>
19#include <asm/traps.h>
20#include <asm/page.h>
21#include <asm/machdep.h>
Roman Zippel68387c42006-06-25 05:47:01 -070022#include <asm/cacheflush.h>
Al Viro2850bc22006-10-07 14:16:45 +010023#include <asm/irq_regs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#ifdef CONFIG_Q40
26#include <asm/q40ints.h>
27#endif
28
Roman Zippel68387c42006-06-25 05:47:01 -070029extern u32 auto_irqhandler_fixup[];
Roman Zippel68387c42006-06-25 05:47:01 -070030extern u16 user_irqvec_fixup[];
31
Roman Zippel68387c42006-06-25 05:47:01 -070032static int m68k_first_user_vec;
Roman Zippelb5dc7842006-06-25 05:47:00 -070033
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020034static struct irq_chip auto_irq_chip = {
Roman Zippelb5dc7842006-06-25 05:47:00 -070035 .name = "auto",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020036 .irq_startup = m68k_irq_startup,
37 .irq_shutdown = m68k_irq_shutdown,
Roman Zippelb5dc7842006-06-25 05:47:00 -070038};
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020040static struct irq_chip user_irq_chip = {
Roman Zippel68387c42006-06-25 05:47:01 -070041 .name = "user",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020042 .irq_startup = m68k_irq_startup,
43 .irq_shutdown = m68k_irq_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046/*
47 * void init_IRQ(void)
48 *
49 * Parameters: None
50 *
51 * Returns: Nothing
52 *
53 * This function should be called during kernel startup to initialize
54 * the IRQ handling routines.
55 */
56
57void __init init_IRQ(void)
58{
59 int i;
60
Roman Zippel6d2f16a2006-06-23 02:04:59 -070061 /* assembly irq entry code relies on this... */
62 if (HARDIRQ_MASK != 0x00ff0000) {
63 extern void hardirq_mask_is_broken(void);
64 hardirq_mask_is_broken();
65 }
66
Roman Zippel68387c42006-06-25 05:47:01 -070067 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020068 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Roman Zippel68387c42006-06-25 05:47:01 -070070 mach_init_IRQ();
71}
72
73/**
74 * m68k_setup_auto_interrupt
75 * @handler: called from auto vector interrupts
76 *
77 * setup the handler to be called from auto vector interrupts instead of the
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020078 * standard do_IRQ(), it will be called with irq numbers in the range
Roman Zippel68387c42006-06-25 05:47:01 -070079 * from IRQ_AUTO_1 - IRQ_AUTO_7.
80 */
81void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
82{
83 if (handler)
84 *auto_irqhandler_fixup = (u32)handler;
85 flush_icache();
86}
87
88/**
89 * m68k_setup_user_interrupt
90 * @vec: first user vector interrupt to handle
91 * @cnt: number of active user vector interrupts
Roman Zippel68387c42006-06-25 05:47:01 -070092 *
93 * setup user vector interrupts, this includes activating the specified range
94 * of interrupts, only then these interrupts can be requested (note: this is
Geert Uytterhoevenf30a6482011-09-11 11:54:50 +020095 * different from auto vector interrupts).
Roman Zippel68387c42006-06-25 05:47:01 -070096 */
Geert Uytterhoevenf30a6482011-09-11 11:54:50 +020097void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt)
Roman Zippel68387c42006-06-25 05:47:01 -070098{
99 int i;
100
Geert Uytterhoeven27123cb2008-11-14 08:10:19 +0100101 BUG_ON(IRQ_USER + cnt > NR_IRQS);
Roman Zippel68387c42006-06-25 05:47:01 -0700102 m68k_first_user_vec = vec;
103 for (i = 0; i < cnt; i++)
Thomas Bogendoerfer378f7ca2013-06-03 12:53:01 +0200104 irq_set_chip_and_handler(i, &user_irq_chip, handle_simple_irq);
Roman Zippel68387c42006-06-25 05:47:01 -0700105 *user_irqvec_fixup = vec - IRQ_USER;
Roman Zippel68387c42006-06-25 05:47:01 -0700106 flush_icache();
107}
108
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200109/**
110 * m68k_setup_irq_controller
111 * @chip: irq chip which controls specified irq
112 * @handle: flow handler which handles specified irq
113 * @irq: first irq to be managed by the controller
114 * @cnt: number of irqs to be managed by the controller
115 *
116 * Change the controller for the specified range of irq, which will be used to
117 * manage these irq. auto/user irq already have a default controller, which can
118 * be changed as well, but the controller probably should use m68k_irq_startup/
119 * m68k_irq_shutdown.
120 */
121void m68k_setup_irq_controller(struct irq_chip *chip,
122 irq_flow_handler_t handle, unsigned int irq,
123 unsigned int cnt)
124{
125 int i;
126
127 for (i = 0; i < cnt; i++) {
128 irq_set_chip(irq + i, chip);
129 if (handle)
130 irq_set_handler(irq + i, handle);
131 }
132}
133
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200134unsigned int m68k_irq_startup_irq(unsigned int irq)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700135{
136 if (irq <= IRQ_AUTO_7)
137 vectors[VEC_SPUR + irq] = auto_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700138 else
139 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700140 return 0;
141}
142
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200143unsigned int m68k_irq_startup(struct irq_data *data)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700144{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200145 return m68k_irq_startup_irq(data->irq);
146}
147
148void m68k_irq_shutdown(struct irq_data *data)
149{
150 unsigned int irq = data->irq;
151
Roman Zippelb5dc7842006-06-25 05:47:00 -0700152 if (irq <= IRQ_AUTO_7)
153 vectors[VEC_SPUR + irq] = bad_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700154 else
155 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700156}
157
158
Roman Zippel68387c42006-06-25 05:47:01 -0700159unsigned int irq_canonicalize(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
Roman Zippel68387c42006-06-25 05:47:01 -0700161#ifdef CONFIG_Q40
162 if (MACH_IS_Q40 && irq == 11)
163 irq = 10;
164#endif
165 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
167
Roman Zippel68387c42006-06-25 05:47:01 -0700168EXPORT_SYMBOL(irq_canonicalize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200170
171asmlinkage void handle_badint(struct pt_regs *regs)
172{
173 atomic_inc(&irq_err_count);
174 pr_warn("unexpected interrupt from %u\n", regs->vector);
175}