1 /* 1 /* 2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k 2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code 3 * 3 * 4 * This file is subject to the terms and condi 4 * This file is subject to the terms and conditions of the GNU General Public 5 * License. See the file COPYING in the main 5 * License. See the file COPYING in the main directory of this archive 6 * for more details. 6 * for more details. 7 */ 7 */ 8 8 9 #include <linux/module.h> 9 #include <linux/module.h> 10 #include <linux/types.h> 10 #include <linux/types.h> 11 #include <linux/sched.h> 11 #include <linux/sched.h> 12 #include <linux/interrupt.h> 12 #include <linux/interrupt.h> 13 #include <linux/errno.h> 13 #include <linux/errno.h> 14 #include <linux/init.h> 14 #include <linux/init.h> 15 #include <linux/irq.h> 15 #include <linux/irq.h> 16 16 17 #include <asm/setup.h> 17 #include <asm/setup.h> 18 #include <asm/irq.h> 18 #include <asm/irq.h> 19 #include <asm/traps.h> 19 #include <asm/traps.h> 20 #include <asm/page.h> 20 #include <asm/page.h> 21 #include <asm/machdep.h> 21 #include <asm/machdep.h> 22 #include <asm/cacheflush.h> 22 #include <asm/cacheflush.h> 23 #include <asm/irq_regs.h> 23 #include <asm/irq_regs.h> 24 24 25 #ifdef CONFIG_Q40 25 #ifdef CONFIG_Q40 26 #include <asm/q40ints.h> 26 #include <asm/q40ints.h> 27 #endif 27 #endif 28 28 29 #include "ints.h" << 30 << 31 extern u32 auto_irqhandler_fixup[]; 29 extern u32 auto_irqhandler_fixup[]; 32 extern u16 user_irqvec_fixup[]; 30 extern u16 user_irqvec_fixup[]; 33 31 34 static int m68k_first_user_vec; 32 static int m68k_first_user_vec; 35 33 36 static struct irq_chip auto_irq_chip = { 34 static struct irq_chip auto_irq_chip = { 37 .name = "auto", 35 .name = "auto", 38 .irq_startup = m68k_irq_startup, 36 .irq_startup = m68k_irq_startup, 39 .irq_shutdown = m68k_irq_shutdown, 37 .irq_shutdown = m68k_irq_shutdown, 40 }; 38 }; 41 39 42 static struct irq_chip user_irq_chip = { 40 static struct irq_chip user_irq_chip = { 43 .name = "user", 41 .name = "user", 44 .irq_startup = m68k_irq_startup, 42 .irq_startup = m68k_irq_startup, 45 .irq_shutdown = m68k_irq_shutdown, 43 .irq_shutdown = m68k_irq_shutdown, 46 }; 44 }; 47 45 48 /* 46 /* 49 * void init_IRQ(void) 47 * void init_IRQ(void) 50 * 48 * 51 * Parameters: None 49 * Parameters: None 52 * 50 * 53 * Returns: Nothing 51 * Returns: Nothing 54 * 52 * 55 * This function should be called during kerne 53 * This function should be called during kernel startup to initialize 56 * the IRQ handling routines. 54 * the IRQ handling routines. 57 */ 55 */ 58 56 59 void __init init_IRQ(void) 57 void __init init_IRQ(void) 60 { 58 { 61 int i; 59 int i; 62 60 63 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; 61 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) 64 irq_set_chip_and_handler(i, &a 62 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq); 65 63 66 mach_init_IRQ(); 64 mach_init_IRQ(); 67 } 65 } 68 66 69 /** 67 /** 70 * m68k_setup_auto_interrupt 68 * m68k_setup_auto_interrupt 71 * @handler: called from auto vector interrupt 69 * @handler: called from auto vector interrupts 72 * 70 * 73 * setup the handler to be called from auto ve 71 * setup the handler to be called from auto vector interrupts instead of the 74 * standard do_IRQ(), it will be called with i 72 * standard do_IRQ(), it will be called with irq numbers in the range 75 * from IRQ_AUTO_1 - IRQ_AUTO_7. 73 * from IRQ_AUTO_1 - IRQ_AUTO_7. 76 */ 74 */ 77 void __init m68k_setup_auto_interrupt(void (*h 75 void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *)) 78 { 76 { 79 if (handler) 77 if (handler) 80 *auto_irqhandler_fixup = (u32) 78 *auto_irqhandler_fixup = (u32)handler; 81 flush_icache(); 79 flush_icache(); 82 } 80 } 83 81 84 /** 82 /** 85 * m68k_setup_user_interrupt 83 * m68k_setup_user_interrupt 86 * @vec: first user vector interrupt to handle 84 * @vec: first user vector interrupt to handle 87 * @cnt: number of active user vector interrup 85 * @cnt: number of active user vector interrupts 88 * 86 * 89 * setup user vector interrupts, this includes 87 * setup user vector interrupts, this includes activating the specified range 90 * of interrupts, only then these interrupts c 88 * of interrupts, only then these interrupts can be requested (note: this is 91 * different from auto vector interrupts). 89 * different from auto vector interrupts). 92 */ 90 */ 93 void __init m68k_setup_user_interrupt(unsigned 91 void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt) 94 { 92 { 95 int i; 93 int i; 96 94 97 BUG_ON(IRQ_USER + cnt > NR_IRQS); 95 BUG_ON(IRQ_USER + cnt > NR_IRQS); 98 m68k_first_user_vec = vec; 96 m68k_first_user_vec = vec; 99 for (i = 0; i < cnt; i++) 97 for (i = 0; i < cnt; i++) 100 irq_set_chip_and_handler(i, &u 98 irq_set_chip_and_handler(i, &user_irq_chip, handle_simple_irq); 101 *user_irqvec_fixup = vec - IRQ_USER; 99 *user_irqvec_fixup = vec - IRQ_USER; 102 flush_icache(); 100 flush_icache(); 103 } 101 } 104 102 105 /** 103 /** 106 * m68k_setup_irq_controller 104 * m68k_setup_irq_controller 107 * @chip: irq chip which controls specified ir 105 * @chip: irq chip which controls specified irq 108 * @handle: flow handler which handles specifi 106 * @handle: flow handler which handles specified irq 109 * @irq: first irq to be managed by the contro 107 * @irq: first irq to be managed by the controller 110 * @cnt: number of irqs to be managed by the c 108 * @cnt: number of irqs to be managed by the controller 111 * 109 * 112 * Change the controller for the specified ran 110 * Change the controller for the specified range of irq, which will be used to 113 * manage these irq. auto/user irq already hav 111 * manage these irq. auto/user irq already have a default controller, which can 114 * be changed as well, but the controller prob 112 * be changed as well, but the controller probably should use m68k_irq_startup/ 115 * m68k_irq_shutdown. 113 * m68k_irq_shutdown. 116 */ 114 */ 117 void m68k_setup_irq_controller(struct irq_chip 115 void m68k_setup_irq_controller(struct irq_chip *chip, 118 irq_flow_handle 116 irq_flow_handler_t handle, unsigned int irq, 119 unsigned int cn 117 unsigned int cnt) 120 { 118 { 121 int i; 119 int i; 122 120 123 for (i = 0; i < cnt; i++) { 121 for (i = 0; i < cnt; i++) { 124 irq_set_chip(irq + i, chip); 122 irq_set_chip(irq + i, chip); 125 if (handle) 123 if (handle) 126 irq_set_handler(irq + 124 irq_set_handler(irq + i, handle); 127 } 125 } 128 } 126 } 129 127 130 unsigned int m68k_irq_startup_irq(unsigned int 128 unsigned int m68k_irq_startup_irq(unsigned int irq) 131 { 129 { 132 if (irq <= IRQ_AUTO_7) 130 if (irq <= IRQ_AUTO_7) 133 vectors[VEC_SPUR + irq] = auto 131 vectors[VEC_SPUR + irq] = auto_inthandler; 134 else 132 else 135 vectors[m68k_first_user_vec + 133 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler; 136 return 0; 134 return 0; 137 } 135 } 138 136 139 unsigned int m68k_irq_startup(struct irq_data 137 unsigned int m68k_irq_startup(struct irq_data *data) 140 { 138 { 141 return m68k_irq_startup_irq(data->irq) 139 return m68k_irq_startup_irq(data->irq); 142 } 140 } 143 141 144 void m68k_irq_shutdown(struct irq_data *data) 142 void m68k_irq_shutdown(struct irq_data *data) 145 { 143 { 146 unsigned int irq = data->irq; 144 unsigned int irq = data->irq; 147 145 148 if (irq <= IRQ_AUTO_7) 146 if (irq <= IRQ_AUTO_7) 149 vectors[VEC_SPUR + irq] = bad_ 147 vectors[VEC_SPUR + irq] = bad_inthandler; 150 else 148 else 151 vectors[m68k_first_user_vec + 149 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler; 152 } 150 } 153 151 154 152 155 unsigned int irq_canonicalize(unsigned int irq 153 unsigned int irq_canonicalize(unsigned int irq) 156 { 154 { 157 #ifdef CONFIG_Q40 155 #ifdef CONFIG_Q40 158 if (MACH_IS_Q40 && irq == 11) 156 if (MACH_IS_Q40 && irq == 11) 159 irq = 10; 157 irq = 10; 160 #endif 158 #endif 161 return irq; 159 return irq; 162 } 160 } 163 161 164 EXPORT_SYMBOL(irq_canonicalize); 162 EXPORT_SYMBOL(irq_canonicalize); 165 163 166 164 167 asmlinkage void handle_badint(struct pt_regs * 165 asmlinkage void handle_badint(struct pt_regs *regs) 168 { 166 { 169 atomic_inc(&irq_err_count); 167 atomic_inc(&irq_err_count); 170 pr_warn("unexpected interrupt from %u\ 168 pr_warn("unexpected interrupt from %u\n", regs->vector); 171 } 169 } 172 170
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.