Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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. |
| 7 | * |
| 8 | * 07/03/96: Timer initialization, and thus mach_sched_init(), |
| 9 | * removed from request_irq() and moved to init_time(). |
| 10 | * We should therefore consider renaming our add_isr() and |
| 11 | * remove_isr() to request_irq() and free_irq() |
| 12 | * respectively, so they are compliant with the other |
| 13 | * architectures. /Jes |
| 14 | * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls. |
| 15 | * Removed irq list support, if any machine needs an irq server |
| 16 | * it must implement this itself (as it's already done), instead |
| 17 | * only default handler are used with mach_default_handler. |
| 18 | * request_irq got some flags different from other architectures: |
| 19 | * - IRQ_FLG_REPLACE : Replace an existing handler (the default one |
| 20 | * can be replaced without this flag) |
| 21 | * - IRQ_FLG_LOCK : handler can't be replaced |
| 22 | * There are other machine depending flags, see there |
| 23 | * If you want to replace a default handler you should know what |
| 24 | * you're doing, since it might handle different other irq sources |
| 25 | * which must be served /Roman Zippel |
| 26 | */ |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/module.h> |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/sched.h> |
Andrew Morton | 6168a70 | 2007-02-17 21:22:39 -0800 | [diff] [blame] | 31 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/kernel_stat.h> |
| 33 | #include <linux/errno.h> |
| 34 | #include <linux/init.h> |
| 35 | |
| 36 | #include <asm/setup.h> |
| 37 | #include <asm/system.h> |
| 38 | #include <asm/irq.h> |
| 39 | #include <asm/traps.h> |
| 40 | #include <asm/page.h> |
| 41 | #include <asm/machdep.h> |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 42 | #include <asm/cacheflush.h> |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 43 | #include <asm/irq_regs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #ifdef CONFIG_Q40 |
| 46 | #include <asm/q40ints.h> |
| 47 | #endif |
| 48 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 49 | extern u32 auto_irqhandler_fixup[]; |
| 50 | extern u32 user_irqhandler_fixup[]; |
| 51 | extern u16 user_irqvec_fixup[]; |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* table for system interrupt handlers */ |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 54 | static struct irq_data *irq_list[NR_IRQS]; |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 55 | static struct irq_chip *irq_chip[NR_IRQS]; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 56 | static int irq_depth[NR_IRQS]; |
| 57 | |
| 58 | static int m68k_first_user_vec; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 59 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 60 | static struct irq_chip auto_irq_chip = { |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 61 | .name = "auto", |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 62 | .irq_startup = m68k_irq_startup, |
| 63 | .irq_shutdown = m68k_irq_shutdown, |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 64 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 66 | static struct irq_chip user_irq_chip = { |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 67 | .name = "user", |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 68 | .irq_startup = m68k_irq_startup, |
| 69 | .irq_shutdown = m68k_irq_shutdown, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #define NUM_IRQ_NODES 100 |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 73 | static struct irq_data nodes[NUM_IRQ_NODES]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | /* |
| 76 | * void init_IRQ(void) |
| 77 | * |
| 78 | * Parameters: None |
| 79 | * |
| 80 | * Returns: Nothing |
| 81 | * |
| 82 | * This function should be called during kernel startup to initialize |
| 83 | * the IRQ handling routines. |
| 84 | */ |
| 85 | |
| 86 | void __init init_IRQ(void) |
| 87 | { |
| 88 | int i; |
| 89 | |
Roman Zippel | 6d2f16a | 2006-06-23 02:04:59 -0700 | [diff] [blame] | 90 | /* assembly irq entry code relies on this... */ |
| 91 | if (HARDIRQ_MASK != 0x00ff0000) { |
| 92 | extern void hardirq_mask_is_broken(void); |
| 93 | hardirq_mask_is_broken(); |
| 94 | } |
| 95 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 96 | for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 97 | irq_chip[i] = &auto_irq_chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 99 | mach_init_IRQ(); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * m68k_setup_auto_interrupt |
| 104 | * @handler: called from auto vector interrupts |
| 105 | * |
| 106 | * setup the handler to be called from auto vector interrupts instead of the |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 107 | * standard __m68k_handle_int(), it will be called with irq numbers in the range |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 108 | * from IRQ_AUTO_1 - IRQ_AUTO_7. |
| 109 | */ |
| 110 | void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *)) |
| 111 | { |
| 112 | if (handler) |
| 113 | *auto_irqhandler_fixup = (u32)handler; |
| 114 | flush_icache(); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * m68k_setup_user_interrupt |
| 119 | * @vec: first user vector interrupt to handle |
| 120 | * @cnt: number of active user vector interrupts |
| 121 | * @handler: called from user vector interrupts |
| 122 | * |
| 123 | * setup user vector interrupts, this includes activating the specified range |
| 124 | * of interrupts, only then these interrupts can be requested (note: this is |
| 125 | * different from auto vector interrupts). An optional handler can be installed |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 126 | * to be called instead of the default __m68k_handle_int(), it will be called |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 127 | * with irq numbers starting from IRQ_USER. |
| 128 | */ |
| 129 | void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt, |
| 130 | void (*handler)(unsigned int, struct pt_regs *)) |
| 131 | { |
| 132 | int i; |
| 133 | |
Geert Uytterhoeven | 27123cb | 2008-11-14 08:10:19 +0100 | [diff] [blame] | 134 | BUG_ON(IRQ_USER + cnt > NR_IRQS); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 135 | m68k_first_user_vec = vec; |
| 136 | for (i = 0; i < cnt; i++) |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 137 | irq_chip[IRQ_USER + i] = &user_irq_chip; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 138 | *user_irqvec_fixup = vec - IRQ_USER; |
| 139 | if (handler) |
| 140 | *user_irqhandler_fixup = (u32)handler; |
| 141 | flush_icache(); |
| 142 | } |
| 143 | |
| 144 | /** |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 145 | * m68k_setup_irq_chip |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 146 | * @contr: irq controller which controls specified irq |
| 147 | * @irq: first irq to be managed by the controller |
| 148 | * |
| 149 | * Change the controller for the specified range of irq, which will be used to |
| 150 | * manage these irq. auto/user irq already have a default controller, which can |
| 151 | * be changed as well, but the controller probably should use m68k_irq_startup/ |
| 152 | * m68k_irq_shutdown. |
| 153 | */ |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 154 | void m68k_setup_irq_chip(struct irq_chip *contr, unsigned int irq, |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 155 | unsigned int cnt) |
| 156 | { |
| 157 | int i; |
| 158 | |
| 159 | for (i = 0; i < cnt; i++) |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 160 | irq_chip[irq + i] = contr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 163 | struct irq_data *new_irq_node(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | { |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 165 | struct irq_data *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | short i; |
| 167 | |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 168 | for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) { |
| 169 | if (!node->handler) { |
| 170 | memset(node, 0, sizeof(*node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | return node; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | printk ("new_irq_node: out of nodes\n"); |
| 176 | return NULL; |
| 177 | } |
| 178 | |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 179 | int setup_irq(unsigned int irq, struct irq_data *node) |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 180 | { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 181 | struct irq_chip *contr; |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 182 | struct irq_data **prev; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 183 | unsigned long flags; |
| 184 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 185 | if (irq >= NR_IRQS || !(contr = irq_chip[irq])) { |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 186 | printk("%s: Incorrect IRQ %d from %s\n", |
Harvey Harrison | f85e7cd | 2008-04-28 02:13:49 -0700 | [diff] [blame] | 187 | __func__, irq, node->devname); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 188 | return -ENXIO; |
| 189 | } |
| 190 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 191 | local_irq_save(flags); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 192 | |
| 193 | prev = irq_list + irq; |
| 194 | if (*prev) { |
| 195 | /* Can't share interrupts unless both agree to */ |
Thomas Gleixner | b0b9fdc | 2006-07-01 19:29:19 -0700 | [diff] [blame] | 196 | if (!((*prev)->flags & node->flags & IRQF_SHARED)) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 197 | local_irq_restore(flags); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 198 | return -EBUSY; |
| 199 | } |
| 200 | while (*prev) |
| 201 | prev = &(*prev)->next; |
| 202 | } |
| 203 | |
| 204 | if (!irq_list[irq]) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 205 | if (contr->irq_startup) |
| 206 | contr->irq_startup(irq); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 207 | else |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 208 | contr->irq_enable(irq); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 209 | } |
| 210 | node->next = NULL; |
| 211 | *prev = node; |
| 212 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 213 | local_irq_restore(flags); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 218 | int request_irq(unsigned int irq, |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 219 | irq_handler_t handler, |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 220 | unsigned long flags, const char *devname, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | { |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 222 | struct irq_data *node; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 223 | int res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 225 | node = new_irq_node(); |
| 226 | if (!node) |
| 227 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 229 | node->irq = irq; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 230 | node->handler = handler; |
| 231 | node->flags = flags; |
| 232 | node->dev_id = dev_id; |
| 233 | node->devname = devname; |
| 234 | |
| 235 | res = setup_irq(irq, node); |
| 236 | if (res) |
| 237 | node->handler = NULL; |
| 238 | |
| 239 | return res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 242 | EXPORT_SYMBOL(request_irq); |
| 243 | |
| 244 | void free_irq(unsigned int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 246 | struct irq_chip *contr; |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 247 | struct irq_data **p, *node; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 248 | unsigned long flags; |
| 249 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 250 | if (irq >= NR_IRQS || !(contr = irq_chip[irq])) { |
Harvey Harrison | f85e7cd | 2008-04-28 02:13:49 -0700 | [diff] [blame] | 251 | printk("%s: Incorrect IRQ %d\n", __func__, irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | return; |
| 253 | } |
| 254 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 255 | local_irq_save(flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 257 | p = irq_list + irq; |
| 258 | while ((node = *p)) { |
| 259 | if (node->dev_id == dev_id) |
| 260 | break; |
| 261 | p = &node->next; |
| 262 | } |
| 263 | |
| 264 | if (node) { |
| 265 | *p = node->next; |
| 266 | node->handler = NULL; |
| 267 | } else |
| 268 | printk("%s: Removing probably wrong IRQ %d\n", |
Harvey Harrison | f85e7cd | 2008-04-28 02:13:49 -0700 | [diff] [blame] | 269 | __func__, irq); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 270 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 271 | if (!irq_list[irq]) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 272 | if (contr->irq_shutdown) |
| 273 | contr->irq_shutdown(irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 274 | else |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 275 | contr->irq_disable(irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 276 | } |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 277 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 278 | local_irq_restore(flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 281 | EXPORT_SYMBOL(free_irq); |
| 282 | |
| 283 | void enable_irq(unsigned int irq) |
| 284 | { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 285 | struct irq_chip *contr; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 286 | unsigned long flags; |
| 287 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 288 | if (irq >= NR_IRQS || !(contr = irq_chip[irq])) { |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 289 | printk("%s: Incorrect IRQ %d\n", |
Harvey Harrison | f85e7cd | 2008-04-28 02:13:49 -0700 | [diff] [blame] | 290 | __func__, irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 291 | return; |
| 292 | } |
| 293 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 294 | local_irq_save(flags); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 295 | if (irq_depth[irq]) { |
| 296 | if (!--irq_depth[irq]) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 297 | if (contr->irq_enable) |
| 298 | contr->irq_enable(irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 299 | } |
| 300 | } else |
| 301 | WARN_ON(1); |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 302 | local_irq_restore(flags); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | EXPORT_SYMBOL(enable_irq); |
| 306 | |
| 307 | void disable_irq(unsigned int irq) |
| 308 | { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 309 | struct irq_chip *contr; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 310 | unsigned long flags; |
| 311 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 312 | if (irq >= NR_IRQS || !(contr = irq_chip[irq])) { |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 313 | printk("%s: Incorrect IRQ %d\n", |
Harvey Harrison | f85e7cd | 2008-04-28 02:13:49 -0700 | [diff] [blame] | 314 | __func__, irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 315 | return; |
| 316 | } |
| 317 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 318 | local_irq_save(flags); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 319 | if (!irq_depth[irq]++) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 320 | if (contr->irq_disable) |
| 321 | contr->irq_disable(irq); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 322 | } |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 323 | local_irq_restore(flags); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | EXPORT_SYMBOL(disable_irq); |
| 327 | |
Al Viro | e9ed7e7 | 2007-07-21 23:29:12 +0100 | [diff] [blame] | 328 | void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq"))); |
| 329 | |
| 330 | EXPORT_SYMBOL(disable_irq_nosync); |
| 331 | |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 332 | unsigned int m68k_irq_startup(unsigned int irq) |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 333 | { |
| 334 | if (irq <= IRQ_AUTO_7) |
| 335 | vectors[VEC_SPUR + irq] = auto_inthandler; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 336 | else |
| 337 | vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | void m68k_irq_shutdown(unsigned int irq) |
| 342 | { |
| 343 | if (irq <= IRQ_AUTO_7) |
| 344 | vectors[VEC_SPUR + irq] = bad_inthandler; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 345 | else |
| 346 | vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* |
| 351 | * Do we need these probe functions on the m68k? |
| 352 | * |
| 353 | * ... may be useful with ISA devices |
| 354 | */ |
| 355 | unsigned long probe_irq_on (void) |
| 356 | { |
| 357 | #ifdef CONFIG_Q40 |
| 358 | if (MACH_IS_Q40) |
| 359 | return q40_probe_irq_on(); |
| 360 | #endif |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | EXPORT_SYMBOL(probe_irq_on); |
| 365 | |
| 366 | int probe_irq_off (unsigned long irqs) |
| 367 | { |
| 368 | #ifdef CONFIG_Q40 |
| 369 | if (MACH_IS_Q40) |
| 370 | return q40_probe_irq_off(irqs); |
| 371 | #endif |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | EXPORT_SYMBOL(probe_irq_off); |
| 376 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 377 | unsigned int irq_canonicalize(unsigned int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | { |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 379 | #ifdef CONFIG_Q40 |
| 380 | if (MACH_IS_Q40 && irq == 11) |
| 381 | irq = 10; |
| 382 | #endif |
| 383 | return irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 386 | EXPORT_SYMBOL(irq_canonicalize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 388 | asmlinkage void m68k_handle_int(unsigned int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | { |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 390 | struct irq_data *node; |
Roman Zippel | 92445eaa | 2006-06-25 05:46:58 -0700 | [diff] [blame] | 391 | kstat_cpu(0).irqs[irq]++; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 392 | node = irq_list[irq]; |
| 393 | do { |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 394 | node->handler(irq, node->dev_id); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 395 | node = node->next; |
| 396 | } while (node); |
Roman Zippel | 92445eaa | 2006-06-25 05:46:58 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Al Viro | 2850bc2 | 2006-10-07 14:16:45 +0100 | [diff] [blame] | 399 | asmlinkage void __m68k_handle_int(unsigned int irq, struct pt_regs *regs) |
| 400 | { |
| 401 | struct pt_regs *old_regs; |
| 402 | old_regs = set_irq_regs(regs); |
| 403 | m68k_handle_int(irq); |
| 404 | set_irq_regs(old_regs); |
| 405 | } |
| 406 | |
Roman Zippel | 92445eaa | 2006-06-25 05:46:58 -0700 | [diff] [blame] | 407 | asmlinkage void handle_badint(struct pt_regs *regs) |
| 408 | { |
| 409 | kstat_cpu(0).irqs[0]++; |
| 410 | printk("unexpected interrupt from %u\n", regs->vector); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | int show_interrupts(struct seq_file *p, void *v) |
| 414 | { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 415 | struct irq_chip *contr; |
Geert Uytterhoeven | 6549d53 | 2011-04-17 21:59:23 +0200 | [diff] [blame^] | 416 | struct irq_data *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | int i = *(loff_t *) v; |
| 418 | |
| 419 | /* autovector interrupts */ |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 420 | if (irq_list[i]) { |
Geert Uytterhoeven | c288bf2 | 2011-04-13 22:31:28 +0200 | [diff] [blame] | 421 | contr = irq_chip[i]; |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 422 | node = irq_list[i]; |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 423 | seq_printf(p, "%-8s %3u: %10u %s", contr->name, i, kstat_cpu(0).irqs[i], node->devname); |
Roman Zippel | b5dc784 | 2006-06-25 05:47:00 -0700 | [diff] [blame] | 424 | while ((node = node->next)) |
| 425 | seq_printf(p, ", %s", node->devname); |
| 426 | seq_puts(p, "\n"); |
Roman Zippel | 68387c4 | 2006-06-25 05:47:01 -0700 | [diff] [blame] | 427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | return 0; |
| 429 | } |
| 430 | |
Geert Uytterhoeven | da9870e | 2008-10-13 21:59:01 +0200 | [diff] [blame] | 431 | #ifdef CONFIG_PROC_FS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | void init_irq_proc(void) |
| 433 | { |
| 434 | /* Insert /proc/irq driver here */ |
| 435 | } |
Geert Uytterhoeven | da9870e | 2008-10-13 21:59:01 +0200 | [diff] [blame] | 436 | #endif |