2 * linux/arch/h8300/kernel/irq.c
4 * Copyright 2007 Yoshinori Sato <ysato@users.sourceforge.jp>
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/kernel_stat.h>
12 #include <linux/seq_file.h>
13 #include <linux/init.h>
14 #include <linux/random.h>
15 #include <linux/bootmem.h>
16 #include <linux/irq.h>
17 #include <linux/interrupt.h>
19 #include <asm/system.h>
20 #include <asm/traps.h>
22 #include <asm/setup.h>
23 #include <asm/errno.h>
27 extern unsigned long *interrupt_redirect_table
;
28 extern const int h8300_saved_vectors
[];
29 extern const h8300_vector h8300_trap_table
[];
30 int h8300_enable_irq_pin(unsigned int irq
);
31 void h8300_disable_irq_pin(unsigned int irq
);
33 #define CPU_VECTOR ((unsigned long *)0x000000)
34 #define ADDR_MASK (0xffffff)
36 static inline int is_ext_irq(unsigned int irq
)
38 return (irq
>= EXT_IRQ0
&& irq
<= (EXT_IRQ0
+ EXT_IRQS
));
41 static void h8300_enable_irq(unsigned int irq
)
44 IER_REGS
|= 1 << (irq
- EXT_IRQ0
);
47 static void h8300_disable_irq(unsigned int irq
)
50 IER_REGS
&= ~(1 << (irq
- EXT_IRQ0
));
53 static void h8300_end_irq(unsigned int irq
)
57 static unsigned int h8300_startup_irq(unsigned int irq
)
60 return h8300_enable_irq_pin(irq
);
65 static void h8300_shutdown_irq(unsigned int irq
)
68 h8300_disable_irq_pin(irq
);
72 * h8300 interrupt controller implementation
74 struct irq_chip h8300irq_chip
= {
76 .startup
= h8300_startup_irq
,
77 .shutdown
= h8300_shutdown_irq
,
78 .enable
= h8300_enable_irq
,
79 .disable
= h8300_disable_irq
,
84 void ack_bad_irq(unsigned int irq
)
86 printk("unexpected IRQ trap at vector %02x\n", irq
);
89 #if defined(CONFIG_RAMKERNEL)
90 static unsigned long __init
*get_vector_address(void)
92 unsigned long *rom_vector
= CPU_VECTOR
;
93 unsigned long base
,tmp
;
96 base
= rom_vector
[EXT_IRQ0
] & ADDR_MASK
;
98 /* check romvector format */
99 for (vec_no
= EXT_IRQ1
; vec_no
<= EXT_IRQ0
+EXT_IRQS
; vec_no
++) {
100 if ((base
+(vec_no
- EXT_IRQ0
)*4) != (rom_vector
[vec_no
] & ADDR_MASK
))
104 /* ramvector base address */
107 /* writerble check */
108 tmp
= ~(*(volatile unsigned long *)base
);
109 (*(volatile unsigned long *)base
) = tmp
;
110 if ((*(volatile unsigned long *)base
) != tmp
)
112 return (unsigned long *)base
;
115 static void __init
setup_vector(void)
118 unsigned long *ramvec
,*ramvec_p
;
119 const h8300_vector
*trap_entry
;
120 const int *saved_vector
;
122 ramvec
= get_vector_address();
124 panic("interrupt vector serup failed.");
126 printk(KERN_INFO
"virtual vector at 0x%08lx\n",(unsigned long)ramvec
);
128 /* create redirect table */
130 trap_entry
= h8300_trap_table
;
131 saved_vector
= h8300_saved_vectors
;
132 for ( i
= 0; i
< NR_IRQS
; i
++) {
133 if (i
== *saved_vector
) {
137 if ( i
< NR_TRAPS
) {
139 *ramvec_p
= VECTOR(*trap_entry
);
143 *ramvec_p
++ = REDIRECT(interrupt_entry
);
146 interrupt_redirect_table
= ramvec
;
149 for (i
= 0; i
< NR_IRQS
; i
++) {
151 printk(KERN_DEBUG
"\n%p: ",ramvec_p
);
152 printk(KERN_DEBUG
"%p ",*ramvec_p
);
155 printk(KERN_DEBUG
"\n");
159 #define setup_vector() do { } while(0)
162 void __init
init_IRQ(void)
168 for (c
= 0; c
< NR_IRQS
; c
++) {
169 irq_desc
[c
].status
= IRQ_DISABLED
;
170 irq_desc
[c
].action
= NULL
;
171 irq_desc
[c
].depth
= 1;
172 irq_desc
[c
].chip
= &h8300irq_chip
;
176 asmlinkage
void do_IRQ(int irq
)
183 #if defined(CONFIG_PROC_FS)
184 int show_interrupts(struct seq_file
*p
, void *v
)
186 int i
= *(loff_t
*) v
;
187 struct irqaction
* action
;
191 seq_puts(p
, " CPU0");
194 spin_lock_irqsave(&irq_desc
[i
].lock
, flags
);
195 action
= irq_desc
[i
].action
;
198 seq_printf(p
, "%3d: ",i
);
199 seq_printf(p
, "%10u ", kstat_irqs(i
));
200 seq_printf(p
, " %14s", irq_desc
[i
].chip
->name
);
201 seq_printf(p
, "-%-8s", irq_desc
[i
].name
);
202 seq_printf(p
, " %s", action
->name
);
204 for (action
=action
->next
; action
; action
= action
->next
)
205 seq_printf(p
, ", %s", action
->name
);
208 spin_unlock_irqrestore(&irq_desc
[i
].lock
, flags
);