1 /* $Id: irq_imask.c,v 1.1.2.1 2002/11/17 10:53:43 mrbrown Exp $
3 * linux/arch/sh/kernel/irq_imask.c
5 * Copyright (C) 1999, 2000 Niibe Yutaka
7 * Simple interrupt handling using IMASK of SR register.
11 /* NOTE: Will not work on level 15 */
14 #include <linux/ptrace.h>
15 #include <linux/errno.h>
16 #include <linux/kernel_stat.h>
17 #include <linux/signal.h>
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
20 #include <linux/init.h>
22 #include <asm/system.h>
24 #include <asm/bitops.h>
26 #include <linux/spinlock.h>
27 #include <linux/cache.h>
28 #include <linux/irq.h>
30 /* Bitmap of IRQ masked */
31 static unsigned long imask_mask
= 0x7fff;
32 static int interrupt_priority
= 0;
34 static void enable_imask_irq(unsigned int irq
);
35 static void disable_imask_irq(unsigned int irq
);
36 static void shutdown_imask_irq(unsigned int irq
);
37 static void mask_and_ack_imask(unsigned int);
38 static void end_imask_irq(unsigned int irq
);
40 #define IMASK_PRIORITY 15
42 static unsigned int startup_imask_irq(unsigned int irq
)
45 return 0; /* never anything pending */
48 static struct hw_interrupt_type imask_irq_type
= {
58 void static inline set_interrupt_registers(int ip
)
60 unsigned long __dummy
;
62 asm volatile("ldc %2, r6_bank\n\t"
66 "cmp/eq #0x3c, %0\n\t"
67 "bt/s 1f ! CLI-ed\n\t"
74 : "r" (~0xf0), "r" (ip
<< 4)
78 static void disable_imask_irq(unsigned int irq
)
80 clear_bit(irq
, &imask_mask
);
81 if (interrupt_priority
< IMASK_PRIORITY
- irq
)
82 interrupt_priority
= IMASK_PRIORITY
- irq
;
84 set_interrupt_registers(interrupt_priority
);
87 static void enable_imask_irq(unsigned int irq
)
89 set_bit(irq
, &imask_mask
);
90 interrupt_priority
= IMASK_PRIORITY
- ffz(imask_mask
);
92 set_interrupt_registers(interrupt_priority
);
95 static void mask_and_ack_imask(unsigned int irq
)
97 disable_imask_irq(irq
);
100 static void end_imask_irq(unsigned int irq
)
102 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
|IRQ_INPROGRESS
)))
103 enable_imask_irq(irq
);
106 static void shutdown_imask_irq(unsigned int irq
)
111 void make_imask_irq(unsigned int irq
)
113 disable_irq_nosync(irq
);
114 irq_desc
[irq
].handler
= &imask_irq_type
;