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

h8300: IRQ handling update

- add missing file and declare.
- remove unused file and macros.
- some cleanup.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Yoshinori Sato and committed by
Linus Torvalds
5cc265a5 4223cc34

+94 -327
+2 -2
arch/h8300/kernel/irq.c
··· 26 26 27 27 extern unsigned long *interrupt_redirect_table; 28 28 extern const int h8300_saved_vectors[]; 29 - extern const unsigned long h8300_trap_table[]; 29 + extern const h8300_vector h8300_trap_table[]; 30 30 int h8300_enable_irq_pin(unsigned int irq); 31 31 void h8300_disable_irq_pin(unsigned int irq); 32 32 ··· 116 116 { 117 117 int i; 118 118 unsigned long *ramvec,*ramvec_p; 119 - const unsigned long *trap_entry; 119 + const h8300_vector *trap_entry; 120 120 const int *saved_vector; 121 121 122 122 ramvec = get_vector_address();
+1 -1
arch/h8300/platform/h8300h/Makefile
··· 4 4 # Reuse any files we can from the H8/300H 5 5 # 6 6 7 - obj-y := irq_pin.o ptrace_h8300h.o 7 + obj-y := irq.o ptrace_h8300h.o
+82
arch/h8300/platform/h8300h/irq.c
··· 1 + /* 2 + * Interrupt handling H8/300H depend. 3 + * Yoshinori Sato <ysato@users.sourceforge.jp> 4 + * 5 + */ 6 + 7 + #include <linux/init.h> 8 + #include <linux/errno.h> 9 + 10 + #include <asm/ptrace.h> 11 + #include <asm/traps.h> 12 + #include <asm/irq.h> 13 + #include <asm/io.h> 14 + #include <asm/gpio.h> 15 + #include <asm/regs306x.h> 16 + 17 + const int __initdata h8300_saved_vectors[] = { 18 + #if defined(CONFIG_GDB_DEBUG) 19 + TRAP3_VEC, /* TRAPA #3 is GDB breakpoint */ 20 + #endif 21 + -1, 22 + }; 23 + 24 + const h8300_vector __initdata h8300_trap_table[] = { 25 + 0, 0, 0, 0, 0, 0, 0, 0, 26 + system_call, 27 + 0, 28 + 0, 29 + trace_break, 30 + }; 31 + 32 + int h8300_enable_irq_pin(unsigned int irq) 33 + { 34 + int bitmask; 35 + if (irq < EXT_IRQ0 || irq > EXT_IRQ5) 36 + return 0; 37 + 38 + /* initialize IRQ pin */ 39 + bitmask = 1 << (irq - EXT_IRQ0); 40 + switch(irq) { 41 + case EXT_IRQ0: 42 + case EXT_IRQ1: 43 + case EXT_IRQ2: 44 + case EXT_IRQ3: 45 + if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0) 46 + return -EBUSY; 47 + H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT); 48 + break; 49 + case EXT_IRQ4: 50 + case EXT_IRQ5: 51 + if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0) 52 + return -EBUSY; 53 + H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT); 54 + break; 55 + } 56 + 57 + return 0; 58 + } 59 + 60 + void h8300_disable_irq_pin(unsigned int irq) 61 + { 62 + int bitmask; 63 + if (irq < EXT_IRQ0 || irq > EXT_IRQ5) 64 + return; 65 + 66 + /* disable interrupt & release IRQ pin */ 67 + bitmask = 1 << (irq - EXT_IRQ0); 68 + switch(irq) { 69 + case EXT_IRQ0: 70 + case EXT_IRQ1: 71 + case EXT_IRQ2: 72 + case EXT_IRQ3: 73 + *(volatile unsigned char *)IER &= ~bitmask; 74 + H8300_GPIO_FREE(H8300_GPIO_P8, bitmask); 75 + break ; 76 + case EXT_IRQ4: 77 + case EXT_IRQ5: 78 + *(volatile unsigned char *)IER &= ~bitmask; 79 + H8300_GPIO_FREE(H8300_GPIO_P9, bitmask); 80 + break; 81 + } 82 + }
-304
arch/h8300/platform/h8s/ints.c
··· 1 - /* 2 - * linux/arch/h8300/platform/h8s/ints.c 3 - * 4 - * Yoshinori Sato <ysato@users.sourceforge.jp> 5 - * 6 - * Based on linux/arch/$(ARCH)/platform/$(PLATFORM)/ints.c 7 - * 8 - * This file is subject to the terms and conditions of the GNU General Public 9 - * License. See the file COPYING in the main directory of this archive 10 - * for more details. 11 - * 12 - * Copyright 1996 Roman Zippel 13 - * Copyright 1999 D. Jeff Dionne <jeff@rt-control.com> 14 - */ 15 - 16 - #include <linux/module.h> 17 - #include <linux/types.h> 18 - #include <linux/kernel.h> 19 - #include <linux/sched.h> 20 - #include <linux/kernel_stat.h> 21 - #include <linux/seq_file.h> 22 - #include <linux/init.h> 23 - #include <linux/interrupt.h> 24 - #include <linux/bootmem.h> 25 - #include <linux/random.h> 26 - #include <linux/hardirq.h> 27 - 28 - #include <asm/system.h> 29 - #include <asm/irq.h> 30 - #include <asm/traps.h> 31 - #include <asm/io.h> 32 - #include <asm/setup.h> 33 - #include <asm/gpio.h> 34 - #include <asm/regs267x.h> 35 - #include <asm/errno.h> 36 - 37 - /* 38 - * This structure has only 4 elements for speed reasons 39 - */ 40 - typedef struct irq_handler { 41 - irqreturn_t (*handler)(int, void *, struct pt_regs *); 42 - int flags; 43 - int count; 44 - void *dev_id; 45 - const char *devname; 46 - } irq_handler_t; 47 - 48 - static irq_handler_t *irq_list[NR_IRQS]; 49 - 50 - /* IRQ pin assignment */ 51 - struct irq_pins { 52 - unsigned char port_no; 53 - unsigned char bit_no; 54 - }; 55 - /* ISTR = 0 */ 56 - static const struct irq_pins irq_assign_table0[16]={ 57 - {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1}, 58 - {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3}, 59 - {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5}, 60 - {H8300_GPIO_P5,H8300_GPIO_B6},{H8300_GPIO_P5,H8300_GPIO_B7}, 61 - {H8300_GPIO_P6,H8300_GPIO_B0},{H8300_GPIO_P6,H8300_GPIO_B1}, 62 - {H8300_GPIO_P6,H8300_GPIO_B2},{H8300_GPIO_P6,H8300_GPIO_B3}, 63 - {H8300_GPIO_P6,H8300_GPIO_B4},{H8300_GPIO_P6,H8300_GPIO_B5}, 64 - {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, 65 - }; 66 - /* ISTR = 1 */ 67 - static const struct irq_pins irq_assign_table1[16]={ 68 - {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1}, 69 - {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3}, 70 - {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5}, 71 - {H8300_GPIO_PH,H8300_GPIO_B2},{H8300_GPIO_PH,H8300_GPIO_B3}, 72 - {H8300_GPIO_P2,H8300_GPIO_B0},{H8300_GPIO_P2,H8300_GPIO_B1}, 73 - {H8300_GPIO_P2,H8300_GPIO_B2},{H8300_GPIO_P2,H8300_GPIO_B3}, 74 - {H8300_GPIO_P2,H8300_GPIO_B4},{H8300_GPIO_P2,H8300_GPIO_B5}, 75 - {H8300_GPIO_P2,H8300_GPIO_B6},{H8300_GPIO_P2,H8300_GPIO_B7}, 76 - }; 77 - 78 - static short use_kmalloc = 0; 79 - 80 - extern unsigned long *interrupt_redirect_table; 81 - 82 - #define CPU_VECTOR ((unsigned long *)0x000000) 83 - #define ADDR_MASK (0xffffff) 84 - 85 - static inline unsigned long *get_vector_address(void) 86 - { 87 - volatile unsigned long *rom_vector = CPU_VECTOR; 88 - unsigned long base,tmp; 89 - int vec_no; 90 - 91 - base = rom_vector[EXT_IRQ0] & ADDR_MASK; 92 - 93 - /* check romvector format */ 94 - for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ15; vec_no++) { 95 - if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK)) 96 - return NULL; 97 - } 98 - 99 - /* ramvector base address */ 100 - base -= EXT_IRQ0*4; 101 - 102 - /* writerble check */ 103 - tmp = ~(*(unsigned long *)base); 104 - (*(unsigned long *)base) = tmp; 105 - if ((*(unsigned long *)base) != tmp) 106 - return NULL; 107 - return (unsigned long *)base; 108 - } 109 - 110 - void __init init_IRQ(void) 111 - { 112 - #if defined(CONFIG_RAMKERNEL) 113 - int i; 114 - unsigned long *ramvec,*ramvec_p; 115 - unsigned long break_vec; 116 - 117 - ramvec = get_vector_address(); 118 - if (ramvec == NULL) 119 - panic("interrupt vector serup failed."); 120 - else 121 - printk("virtual vector at 0x%08lx\n",(unsigned long)ramvec); 122 - 123 - #if defined(CONFIG_GDB_DEBUG) 124 - /* save original break vector */ 125 - break_vec = ramvec[TRAP3_VEC]; 126 - #else 127 - break_vec = VECTOR(trace_break); 128 - #endif 129 - 130 - /* create redirect table */ 131 - for (ramvec_p = ramvec, i = 0; i < NR_IRQS; i++) 132 - *ramvec_p++ = REDIRECT(interrupt_entry); 133 - 134 - /* set special vector */ 135 - ramvec[TRAP0_VEC] = VECTOR(system_call); 136 - ramvec[TRAP3_VEC] = break_vec; 137 - interrupt_redirect_table = ramvec; 138 - #ifdef DUMP_VECTOR 139 - ramvec_p = ramvec; 140 - for (i = 0; i < NR_IRQS; i++) { 141 - if ((i % 8) == 0) 142 - printk("\n%p: ",ramvec_p); 143 - printk("%p ",*ramvec_p); 144 - ramvec_p++; 145 - } 146 - printk("\n"); 147 - #endif 148 - #endif 149 - } 150 - 151 - int request_irq(unsigned int irq, 152 - irqreturn_t (*handler)(int, void *, struct pt_regs *), 153 - unsigned long flags, const char *devname, void *dev_id) 154 - { 155 - unsigned short ptn = 1 << (irq - EXT_IRQ0); 156 - irq_handler_t *irq_handle; 157 - if (irq < 0 || irq >= NR_IRQS) { 158 - printk("Incorrect IRQ %d from %s\n", irq, devname); 159 - return -EINVAL; 160 - } 161 - if (irq_list[irq]) 162 - return -EBUSY; /* already used */ 163 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) { 164 - /* initialize IRQ pin */ 165 - unsigned int port_no,bit_no; 166 - if (*(volatile unsigned short *)ITSR & ptn) { 167 - port_no = irq_assign_table1[irq - EXT_IRQ0].port_no; 168 - bit_no = irq_assign_table1[irq - EXT_IRQ0].bit_no; 169 - } else { 170 - port_no = irq_assign_table0[irq - EXT_IRQ0].port_no; 171 - bit_no = irq_assign_table0[irq - EXT_IRQ0].bit_no; 172 - } 173 - if (H8300_GPIO_RESERVE(port_no, bit_no) == 0) 174 - return -EBUSY; /* pin already use */ 175 - H8300_GPIO_DDR(port_no, bit_no, H8300_GPIO_INPUT); 176 - *(volatile unsigned short *)ISR &= ~ptn; /* ISR clear */ 177 - } 178 - 179 - if (use_kmalloc) 180 - irq_handle = kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); 181 - else { 182 - /* use bootmem allocator */ 183 - irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t)); 184 - irq_handle = (irq_handler_t *)((unsigned long)irq_handle | 0x80000000); 185 - } 186 - 187 - if (irq_handle == NULL) 188 - return -ENOMEM; 189 - 190 - irq_handle->handler = handler; 191 - irq_handle->flags = flags; 192 - irq_handle->count = 0; 193 - irq_handle->dev_id = dev_id; 194 - irq_handle->devname = devname; 195 - irq_list[irq] = irq_handle; 196 - if (irq_handle->flags & IRQF_SAMPLE_RANDOM) 197 - rand_initialize_irq(irq); 198 - 199 - /* enable interrupt */ 200 - /* compatible i386 */ 201 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) 202 - *(volatile unsigned short *)IER |= ptn; 203 - return 0; 204 - } 205 - 206 - EXPORT_SYMBOL(request_irq); 207 - 208 - void free_irq(unsigned int irq, void *dev_id) 209 - { 210 - if (irq >= NR_IRQS) 211 - return; 212 - if (irq_list[irq]->dev_id != dev_id) 213 - printk("%s: Removing probably wrong IRQ %d from %s\n", 214 - __FUNCTION__, irq, irq_list[irq]->devname); 215 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) { 216 - /* disable interrupt & release IRQ pin */ 217 - unsigned short port_no,bit_no; 218 - *(volatile unsigned short *)ISR &= ~(1 << (irq - EXT_IRQ0)); 219 - *(volatile unsigned short *)IER |= 1 << (irq - EXT_IRQ0); 220 - if (*(volatile unsigned short *)ITSR & (1 << (irq - EXT_IRQ0))) { 221 - port_no = irq_assign_table1[irq - EXT_IRQ0].port_no; 222 - bit_no = irq_assign_table1[irq - EXT_IRQ0].bit_no; 223 - } else { 224 - port_no = irq_assign_table0[irq - EXT_IRQ0].port_no; 225 - bit_no = irq_assign_table0[irq - EXT_IRQ0].bit_no; 226 - } 227 - H8300_GPIO_FREE(port_no, bit_no); 228 - } 229 - if (((unsigned long)irq_list[irq] & 0x80000000) == 0) { 230 - kfree(irq_list[irq]); 231 - irq_list[irq] = NULL; 232 - } 233 - } 234 - 235 - EXPORT_SYMBOL(free_irq); 236 - 237 - unsigned long probe_irq_on (void) 238 - { 239 - return 0; 240 - } 241 - 242 - EXPORT_SYMBOL(probe_irq_on); 243 - 244 - int probe_irq_off (unsigned long irqs) 245 - { 246 - return 0; 247 - } 248 - 249 - EXPORT_SYMBOL(probe_irq_off); 250 - 251 - void enable_irq(unsigned int irq) 252 - { 253 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) 254 - *(volatile unsigned short *)IER |= 1 << (irq - EXT_IRQ0); 255 - } 256 - 257 - void disable_irq(unsigned int irq) 258 - { 259 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) 260 - *(volatile unsigned short *)IER &= ~(1 << (irq - EXT_IRQ0)); 261 - } 262 - 263 - asmlinkage void process_int(unsigned long vec, struct pt_regs *fp) 264 - { 265 - irq_enter(); 266 - /* ISR clear */ 267 - /* compatible i386 */ 268 - if (vec >= EXT_IRQ0 && vec <= EXT_IRQ15) 269 - *(volatile unsigned short *)ISR &= ~(1 << (vec - EXT_IRQ0)); 270 - if (vec < NR_IRQS) { 271 - if (irq_list[vec]) { 272 - irq_list[vec]->handler(vec, irq_list[vec]->dev_id, fp); 273 - irq_list[vec]->count++; 274 - if (irq_list[vec]->flags & IRQF_SAMPLE_RANDOM) 275 - add_interrupt_randomness(vec); 276 - } 277 - } else { 278 - BUG(); 279 - } 280 - irq_exit(); 281 - } 282 - 283 - int show_interrupts(struct seq_file *p, void *v) 284 - { 285 - int i = *(loff_t *) v; 286 - 287 - if ((i < NR_IRQS) && (irq_list[i] !=NULL)) { 288 - seq_printf(p, "%3d: %10u ",i,irq_list[i]->count); 289 - seq_printf(p, "%s\n", irq_list[i]->devname); 290 - } 291 - 292 - return 0; 293 - } 294 - 295 - void init_irq_proc(void) 296 - { 297 - } 298 - 299 - static int __init enable_kmalloc(void) 300 - { 301 - use_kmalloc = 1; 302 - return 0; 303 - } 304 - core_initcall(enable_kmalloc);
+4 -4
arch/h8300/platform/h8s/ints_h8s.c arch/h8300/platform/h8s/irq.c
··· 27 27 }; 28 28 29 29 /* trap entry table */ 30 - const unsigned long __initdata h8300_trap_table[NR_TRAPS]={ 30 + const H8300_VECTOR __initdata h8300_trap_table[] = { 31 31 0,0,0,0,0, 32 - (unsigned long)trace_break, /* TRACE */ 32 + trace_break, /* TRACE */ 33 33 0,0, 34 - (unsigned long)system_call, /* TRAPA #0 */ 34 + system_call, /* TRAPA #0 */ 35 35 0,0,0,0,0,0,0 36 36 }; 37 37 ··· 50 50 {H8300_GPIO_P6,H8300_GPIO_B2},{H8300_GPIO_P6,H8300_GPIO_B3}, 51 51 {H8300_GPIO_P6,H8300_GPIO_B4},{H8300_GPIO_P6,H8300_GPIO_B5}, 52 52 {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, 53 - }; 53 + }; 54 54 /* ISTR = 1 */ 55 55 static const struct irq_pins irq_assign_table1[16]={ 56 56 {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1},
+2
include/asm-h8300/hardirq.h
··· 12 12 13 13 #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 14 14 15 + extern void ack_bad_irq(unsigned int irq); 16 + 15 17 #define HARDIRQ_BITS 8 16 18 17 19 /*
+3 -16
include/asm-h8300/irq.h
··· 3 3 4 4 #include <asm/ptrace.h> 5 5 6 - #if defined(__H8300H__) 6 + #if defined(CONFIG_CPU_H8300H) 7 7 #define NR_IRQS 64 8 8 #define EXT_IRQ0 12 9 9 #define EXT_IRQ1 13 ··· 14 14 #define EXT_IRQ6 18 15 15 #define EXT_IRQ7 19 16 16 #define EXT_IRQS 5 17 - 18 - #include <asm/regs306x.h> 19 - #define h8300_clear_isr(irq) \ 20 - do { \ 21 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5) \ 22 - *(volatile unsigned char *)ISR &= ~(1 << (irq - EXT_IRQ0)); \ 23 - } while(0) 24 - 25 17 #define IER_REGS *(volatile unsigned char *)IER 26 18 #endif 27 19 #if defined(CONFIG_CPU_H8S) ··· 36 44 #define EXT_IRQ15 31 37 45 #define EXT_IRQS 15 38 46 39 - #include <asm/regs267x.h> 40 - #define h8300_clear_isr(irq) \ 41 - do { \ 42 - if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) \ 43 - *(volatile unsigned short *)ISR &= ~(1 << (irq - EXT_IRQ0)); \ 44 - } while(0) 45 - 46 47 #define IER_REGS *(volatile unsigned short *)IER 47 48 #endif 48 49 ··· 43 58 { 44 59 return irq; 45 60 } 61 + 62 + typedef void (*h8300_vector)(void); 46 63 47 64 #endif /* _H8300_IRQ_H_ */