Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / sh / boards / renesas / rts7751r2d / irq.c
blob95717f4f1e2d024f6c4ec890c584c10df64996ab
1 /*
2 * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
4 * Copyright (C) 2000 Kazumoto Kojima
6 * Renesas Technology Sales RTS7751R2D Support.
8 * Modified for RTS7751R2D by
9 * Atom Create Engineering Co., Ltd. 2002.
12 #include <linux/config.h>
13 #include <linux/init.h>
14 #include <linux/irq.h>
15 #include <asm/io.h>
16 #include <asm/irq.h>
17 #include <asm/rts7751r2d/rts7751r2d.h>
19 #if defined(CONFIG_RTS7751R2D_REV11)
20 static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0};
21 #else
22 static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0};
23 #endif
25 extern int voyagergx_irq_demux(int irq);
26 extern void setup_voyagergx_irq(void);
28 static void enable_rts7751r2d_irq(unsigned int irq);
29 static void disable_rts7751r2d_irq(unsigned int irq);
31 /* shutdown is same as "disable" */
32 #define shutdown_rts7751r2d_irq disable_rts7751r2d_irq
34 static void ack_rts7751r2d_irq(unsigned int irq);
35 static void end_rts7751r2d_irq(unsigned int irq);
37 static unsigned int startup_rts7751r2d_irq(unsigned int irq)
39 enable_rts7751r2d_irq(irq);
40 return 0; /* never anything pending */
43 static void disable_rts7751r2d_irq(unsigned int irq)
45 unsigned long flags;
46 unsigned short val;
47 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
49 /* Set the priority in IPR to 0 */
50 local_irq_save(flags);
51 val = ctrl_inw(IRLCNTR1);
52 val &= mask;
53 ctrl_outw(val, IRLCNTR1);
54 local_irq_restore(flags);
57 static void enable_rts7751r2d_irq(unsigned int irq)
59 unsigned long flags;
60 unsigned short val;
61 unsigned short value = (0x0001 << mask_pos[irq]);
63 /* Set priority in IPR back to original value */
64 local_irq_save(flags);
65 val = ctrl_inw(IRLCNTR1);
66 val |= value;
67 ctrl_outw(val, IRLCNTR1);
68 local_irq_restore(flags);
71 int rts7751r2d_irq_demux(int irq)
73 int demux_irq;
75 demux_irq = voyagergx_irq_demux(irq);
76 return demux_irq;
79 static void ack_rts7751r2d_irq(unsigned int irq)
81 disable_rts7751r2d_irq(irq);
84 static void end_rts7751r2d_irq(unsigned int irq)
86 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
87 enable_rts7751r2d_irq(irq);
90 static struct hw_interrupt_type rts7751r2d_irq_type = {
91 "RTS7751R2D IRQ",
92 startup_rts7751r2d_irq,
93 shutdown_rts7751r2d_irq,
94 enable_rts7751r2d_irq,
95 disable_rts7751r2d_irq,
96 ack_rts7751r2d_irq,
97 end_rts7751r2d_irq,
100 static void make_rts7751r2d_irq(unsigned int irq)
102 disable_irq_nosync(irq);
103 irq_desc[irq].handler = &rts7751r2d_irq_type;
104 disable_rts7751r2d_irq(irq);
108 * Initialize IRQ setting
110 void __init init_rts7751r2d_IRQ(void)
112 int i;
114 /* IRL0=KEY Input
115 * IRL1=Ethernet
116 * IRL2=CF Card
117 * IRL3=CF Card Insert
118 * IRL4=PCMCIA
119 * IRL5=VOYAGER
120 * IRL6=RTC Alarm
121 * IRL7=RTC Timer
122 * IRL8=SD Card
123 * IRL9=PCI Slot #1
124 * IRL10=PCI Slot #2
125 * IRL11=Extention #0
126 * IRL12=Extention #1
127 * IRL13=Extention #2
128 * IRL14=Extention #3
131 for (i=0; i<15; i++)
132 make_rts7751r2d_irq(i);
134 setup_voyagergx_irq();