Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] m68k: convert sun3 irq code

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Roman Zippel and committed by
Linus Torvalds
ebba61d5 77dda339

+35 -216
-8
arch/m68k/sun3/config.c
··· 36 36 char sun3_reserved_pmeg[SUN3_PMEGS_NUM]; 37 37 38 38 extern unsigned long sun3_gettimeoffset(void); 39 - extern int show_sun3_interrupts (struct seq_file *, void *); 40 39 extern void sun3_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *)); 41 40 extern void sun3_get_model (char* model); 42 41 extern void idprom_init (void); ··· 146 147 147 148 mach_sched_init = sun3_sched_init; 148 149 mach_init_IRQ = sun3_init_IRQ; 149 - mach_default_handler = &sun3_default_handler; 150 - mach_request_irq = sun3_request_irq; 151 - mach_free_irq = sun3_free_irq; 152 - enable_irq = sun3_enable_irq; 153 - disable_irq = sun3_disable_irq; 154 - mach_process_int = sun3_process_int; 155 - mach_get_irq_list = show_sun3_interrupts; 156 150 mach_reset = sun3_reboot; 157 151 mach_gettimeoffset = sun3_gettimeoffset; 158 152 mach_get_model = sun3_get_model;
+30 -184
arch/m68k/sun3/sun3ints.c
··· 19 19 #include <linux/seq_file.h> 20 20 21 21 extern void sun3_leds (unsigned char); 22 - static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp); 23 22 24 23 void sun3_disable_interrupts(void) 25 24 { ··· 39 40 40 41 volatile unsigned char* sun3_intreg; 41 42 42 - void sun3_insert_irq(irq_node_t **list, irq_node_t *node) 43 - { 44 - } 45 - 46 - void sun3_delete_irq(irq_node_t **list, void *dev_id) 47 - { 48 - } 49 - 50 43 void sun3_enable_irq(unsigned int irq) 51 44 { 52 - *sun3_intreg |= (1<<irq); 45 + *sun3_intreg |= (1 << irq); 53 46 } 54 47 55 48 void sun3_disable_irq(unsigned int irq) 56 49 { 57 - *sun3_intreg &= ~(1<<irq); 58 - } 59 - 60 - inline void sun3_do_irq(int irq, struct pt_regs *fp) 61 - { 62 - kstat_cpu(0).irqs[SYS_IRQS + irq]++; 63 - *sun3_intreg &= ~(1<<irq); 64 - *sun3_intreg |= (1<<irq); 50 + *sun3_intreg &= ~(1 << irq); 65 51 } 66 52 67 53 static irqreturn_t sun3_int7(int irq, void *dev_id, struct pt_regs *fp) 68 54 { 69 - sun3_do_irq(irq,fp); 70 - if(!(kstat_cpu(0).irqs[SYS_IRQS + irq] % 2000)) 71 - sun3_leds(led_pattern[(kstat_cpu(0).irqs[SYS_IRQS+irq]%16000) 72 - /2000]); 55 + *sun3_intreg |= (1 << irq); 56 + if (!(kstat_cpu(0).irqs[irq] % 2000)) 57 + sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 16000) / 2000]); 73 58 return IRQ_HANDLED; 74 59 } 75 60 76 61 static irqreturn_t sun3_int5(int irq, void *dev_id, struct pt_regs *fp) 77 62 { 78 - kstat_cpu(0).irqs[SYS_IRQS + irq]++; 79 63 #ifdef CONFIG_SUN3 80 64 intersil_clear(); 81 65 #endif 82 - *sun3_intreg &= ~(1<<irq); 83 - *sun3_intreg |= (1<<irq); 66 + *sun3_intreg |= (1 << irq); 84 67 #ifdef CONFIG_SUN3 85 68 intersil_clear(); 86 69 #endif ··· 70 89 #ifndef CONFIG_SMP 71 90 update_process_times(user_mode(fp)); 72 91 #endif 73 - if(!(kstat_cpu(0).irqs[SYS_IRQS + irq] % 20)) 74 - sun3_leds(led_pattern[(kstat_cpu(0).irqs[SYS_IRQS+irq]%160) 75 - /20]); 76 - return IRQ_HANDLED; 77 - } 78 - 79 - /* handle requested ints, excepting 5 and 7, which always do the same 80 - thing */ 81 - irqreturn_t (*sun3_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = { 82 - [0] = sun3_inthandle, 83 - [1] = sun3_inthandle, 84 - [2] = sun3_inthandle, 85 - [3] = sun3_inthandle, 86 - [4] = sun3_inthandle, 87 - [5] = sun3_int5, 88 - [6] = sun3_inthandle, 89 - [7] = sun3_int7 90 - }; 91 - 92 - static const char *dev_names[SYS_IRQS] = { 93 - [5] = "timer", 94 - [7] = "int7 handler" 95 - }; 96 - static void *dev_ids[SYS_IRQS]; 97 - static irqreturn_t (*sun3_inthandler[SYS_IRQS])(int, void *, struct pt_regs *) = { 98 - [5] = sun3_int5, 99 - [7] = sun3_int7 100 - }; 101 - static irqreturn_t (*sun3_vechandler[SUN3_INT_VECS])(int, void *, struct pt_regs *); 102 - static void *vec_ids[SUN3_INT_VECS]; 103 - static const char *vec_names[SUN3_INT_VECS]; 104 - static int vec_ints[SUN3_INT_VECS]; 105 - 106 - 107 - int show_sun3_interrupts(struct seq_file *p, void *v) 108 - { 109 - int i; 110 - 111 - for(i = 0; i < (SUN3_INT_VECS-1); i++) { 112 - if(sun3_vechandler[i] != NULL) { 113 - seq_printf(p, "vec %3d: %10u %s\n", i+64, 114 - vec_ints[i], 115 - (vec_names[i]) ? vec_names[i] : 116 - "sun3_vechandler"); 117 - } 118 - } 119 - 120 - return 0; 121 - } 122 - 123 - static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp) 124 - { 125 - if(sun3_inthandler[irq] == NULL) 126 - panic ("bad interrupt %d received (id %p)\n",irq, dev_id); 127 - 128 - kstat_cpu(0).irqs[SYS_IRQS + irq]++; 129 - *sun3_intreg &= ~(1<<irq); 130 - 131 - sun3_inthandler[irq](irq, dev_ids[irq], fp); 92 + if (!(kstat_cpu(0).irqs[irq] % 20)) 93 + sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]); 132 94 return IRQ_HANDLED; 133 95 } 134 96 ··· 81 157 return IRQ_HANDLED; 82 158 } 83 159 160 + static void sun3_inthandle(unsigned int irq, struct pt_regs *fp) 161 + { 162 + *sun3_intreg &= ~(1 << irq); 163 + 164 + m68k_handle_int(irq, fp); 165 + } 166 + 167 + static struct irq_controller sun3_irq_controller = { 168 + .name = "sun3", 169 + .lock = SPIN_LOCK_UNLOCKED, 170 + .startup = m68k_irq_startup, 171 + .shutdown = m68k_irq_shutdown, 172 + .enable = sun3_enable_irq, 173 + .disable = sun3_disable_irq, 174 + }; 175 + 84 176 void sun3_init_IRQ(void) 85 177 { 86 - int i; 87 - 88 178 *sun3_intreg = 1; 89 179 90 - for(i = 0; i < SYS_IRQS; i++) 91 - { 92 - if(dev_names[i]) 93 - cpu_request_irq(i, sun3_default_handler[i], 0, 94 - dev_names[i], NULL); 95 - } 180 + m68k_setup_auto_interrupt(sun3_inthandle); 181 + m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7); 182 + m68k_setup_user_interrupt(VEC_USER, 192, NULL); 96 183 97 - for(i = 0; i < 192; i++) 98 - sun3_vechandler[i] = NULL; 99 - 100 - sun3_vechandler[191] = sun3_vec255; 101 - } 102 - 103 - int sun3_request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), 104 - unsigned long flags, const char *devname, void *dev_id) 105 - { 106 - 107 - if(irq < SYS_IRQS) { 108 - if(sun3_inthandler[irq] != NULL) { 109 - printk("sun3_request_irq: request for irq %d -- already taken!\n", irq); 110 - return 1; 111 - } 112 - 113 - sun3_inthandler[irq] = handler; 114 - dev_ids[irq] = dev_id; 115 - dev_names[irq] = devname; 116 - 117 - /* setting devname would be nice */ 118 - cpu_request_irq(irq, sun3_default_handler[irq], 0, devname, 119 - NULL); 120 - 121 - return 0; 122 - } else { 123 - if((irq >= 64) && (irq <= 255)) { 124 - int vec; 125 - 126 - vec = irq - 64; 127 - if(sun3_vechandler[vec] != NULL) { 128 - printk("sun3_request_irq: request for vec %d -- already taken!\n", irq); 129 - return 1; 130 - } 131 - 132 - sun3_vechandler[vec] = handler; 133 - vec_ids[vec] = dev_id; 134 - vec_names[vec] = devname; 135 - vec_ints[vec] = 0; 136 - 137 - return 0; 138 - } 139 - } 140 - 141 - printk("sun3_request_irq: invalid irq %d\n", irq); 142 - return 1; 143 - 144 - } 145 - 146 - void sun3_free_irq(unsigned int irq, void *dev_id) 147 - { 148 - 149 - if(irq < SYS_IRQS) { 150 - if(sun3_inthandler[irq] == NULL) 151 - panic("sun3_free_int: attempt to free unused irq %d\n", irq); 152 - if(dev_ids[irq] != dev_id) 153 - panic("sun3_free_int: incorrect dev_id for irq %d\n", irq); 154 - 155 - sun3_inthandler[irq] = NULL; 156 - return; 157 - } else if((irq >= 64) && (irq <= 255)) { 158 - int vec; 159 - 160 - vec = irq - 64; 161 - if(sun3_vechandler[vec] == NULL) 162 - panic("sun3_free_int: attempt to free unused vector %d\n", irq); 163 - if(vec_ids[irq] != dev_id) 164 - panic("sun3_free_int: incorrect dev_id for vec %d\n", irq); 165 - 166 - sun3_vechandler[vec] = NULL; 167 - return; 168 - } else { 169 - panic("sun3_free_irq: invalid irq %d\n", irq); 170 - } 171 - } 172 - 173 - irqreturn_t sun3_process_int(int irq, struct pt_regs *regs) 174 - { 175 - 176 - if((irq >= 64) && (irq <= 255)) { 177 - int vec; 178 - 179 - vec = irq - 64; 180 - if(sun3_vechandler[vec] == NULL) 181 - panic ("bad interrupt vector %d received\n",irq); 182 - 183 - vec_ints[vec]++; 184 - return sun3_vechandler[vec](irq, vec_ids[vec], regs); 185 - } else { 186 - panic("sun3_process_int: unable to handle interrupt vector %d\n", 187 - irq); 188 - } 184 + request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL); 185 + request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL); 186 + request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL); 189 187 }
-7
arch/m68k/sun3x/config.c
··· 52 52 53 53 sun3x_prom_init(); 54 54 55 - mach_get_irq_list = show_sun3_interrupts; 56 55 mach_max_dma_address = 0xffffffff; /* we can DMA anywhere, whee */ 57 56 58 - mach_default_handler = &sun3_default_handler; 59 57 mach_sched_init = sun3x_sched_init; 60 58 mach_init_IRQ = sun3_init_IRQ; 61 - enable_irq = sun3_enable_irq; 62 - disable_irq = sun3_disable_irq; 63 - mach_request_irq = sun3_request_irq; 64 - mach_free_irq = sun3_free_irq; 65 - mach_process_int = sun3_process_int; 66 59 67 60 mach_gettimeoffset = sun3x_gettimeoffset; 68 61 mach_reset = sun3x_reboot;
+5 -17
include/asm-m68k/sun3ints.h
··· 12 12 #define SUN3INTS_H 13 13 14 14 #include <linux/types.h> 15 - #include <linux/kernel.h> 16 - #include <linux/sched.h> 17 - #include <linux/kernel_stat.h> 18 15 #include <linux/interrupt.h> 19 - #include <linux/seq_file.h> 20 - #include <asm/segment.h> 21 16 #include <asm/intersil.h> 22 17 #include <asm/oplib.h> 18 + #include <asm/traps.h> 23 19 24 20 #define SUN3_INT_VECS 192 25 21 26 22 void sun3_enable_irq(unsigned int irq); 27 23 void sun3_disable_irq(unsigned int irq); 28 - int sun3_request_irq(unsigned int irq, 29 - irqreturn_t (*handler)(int, void *, struct pt_regs *), 30 - unsigned long flags, const char *devname, void *dev_id 31 - ); 32 24 extern void sun3_init_IRQ (void); 33 - extern irqreturn_t (*sun3_default_handler[]) (int, void *, struct pt_regs *); 34 - extern void sun3_free_irq (unsigned int irq, void *dev_id); 35 25 extern void sun3_enable_interrupts (void); 36 26 extern void sun3_disable_interrupts (void); 37 - extern int show_sun3_interrupts(struct seq_file *, void *); 38 - extern irqreturn_t sun3_process_int(int, struct pt_regs *); 39 27 extern volatile unsigned char* sun3_intreg; 40 28 41 29 /* master list of VME vectors -- don't fuck with this */ 42 - #define SUN3_VEC_FLOPPY 0x40 43 - #define SUN3_VEC_VMESCSI0 0x40 44 - #define SUN3_VEC_VMESCSI1 0x41 45 - #define SUN3_VEC_CG 0xA8 30 + #define SUN3_VEC_FLOPPY (IRQ_USER+0) 31 + #define SUN3_VEC_VMESCSI0 (IRQ_USER+0) 32 + #define SUN3_VEC_VMESCSI1 (IRQ_USER+1) 33 + #define SUN3_VEC_CG (IRQ_USER+104) 46 34 47 35 48 36 #endif /* SUN3INTS_H */