sh: Add support for Solution Engine 7206 and 7619 boards.
[deliverable/linux.git] / arch / sh / boards / se / 7206 / irq.c
1 /*
2 * linux/arch/sh/boards/se/7206/irq.c
3 *
4 * Copyright (C) 2005,2006 Yoshinori Sato
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 */
9
10 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/irq.h>
13 #include <asm/irq.h>
14 #include <asm/io.h>
15 #include <asm/se7206.h>
16
17 #define INTSTS0 0x31800000
18 #define INTSTS1 0x31800002
19 #define INTMSK0 0x31800004
20 #define INTMSK1 0x31800006
21 #define INTSEL 0x31800008
22
23 /* shutdown is same as "disable" */
24 #define shutdown_se7206_irq disable_se7206_irq
25
26 static void disable_se7206_irq(unsigned int irq)
27 {
28 unsigned short val;
29 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
30 unsigned short msk0,msk1;
31
32 /* Set the priority in IPR to 0 */
33 val = ctrl_inw(INTC_IPR01);
34 val &= mask;
35 ctrl_outw(val, INTC_IPR01);
36 /* FPGA mask set */
37 msk0 = ctrl_inw(INTMSK0);
38 msk1 = ctrl_inw(INTMSK1);
39
40 switch (irq) {
41 case IRQ0_IRQ:
42 msk0 |= 0x0010;
43 break;
44 case IRQ1_IRQ:
45 msk0 |= 0x000f;
46 break;
47 case IRQ2_IRQ:
48 msk0 |= 0x0f00;
49 msk1 |= 0x00ff;
50 break;
51 }
52 ctrl_outw(msk0, INTMSK0);
53 ctrl_outw(msk1, INTMSK1);
54 }
55
56 static void enable_se7206_irq(unsigned int irq)
57 {
58 unsigned short val;
59 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
60 unsigned short msk0,msk1;
61
62 /* Set priority in IPR back to original value */
63 val = ctrl_inw(INTC_IPR01);
64 val |= value;
65 ctrl_outw(val, INTC_IPR01);
66
67 /* FPGA mask reset */
68 msk0 = ctrl_inw(INTMSK0);
69 msk1 = ctrl_inw(INTMSK1);
70
71 switch (irq) {
72 case IRQ0_IRQ:
73 msk0 &= ~0x0010;
74 break;
75 case IRQ1_IRQ:
76 msk0 &= ~0x000f;
77 break;
78 case IRQ2_IRQ:
79 msk0 &= ~0x0f00;
80 msk1 &= ~0x00ff;
81 break;
82 }
83 ctrl_outw(msk0, INTMSK0);
84 ctrl_outw(msk1, INTMSK1);
85 }
86
87 static unsigned int startup_se7206_irq(unsigned int irq)
88 {
89 enable_se7206_irq(irq);
90 return 0; /* never anything pending */
91 }
92
93 static void ack_se7206_irq(unsigned int irq)
94 {
95 disable_se7206_irq(irq);
96 }
97
98 static void end_se7206_irq(unsigned int irq)
99 {
100 unsigned short sts0,sts1;
101
102 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
103 enable_se7206_irq(irq);
104 /* FPGA isr clear */
105 sts0 = ctrl_inw(INTSTS0);
106 sts1 = ctrl_inw(INTSTS1);
107
108 switch (irq) {
109 case IRQ0_IRQ:
110 sts0 &= ~0x0010;
111 break;
112 case IRQ1_IRQ:
113 sts0 &= ~0x000f;
114 break;
115 case IRQ2_IRQ:
116 sts0 &= ~0x0f00;
117 sts1 &= ~0x00ff;
118 break;
119 }
120 ctrl_outw(sts0, INTSTS0);
121 ctrl_outw(sts1, INTSTS1);
122 }
123
124 static struct hw_interrupt_type se7206_irq_type = {
125 .typename = "SE7206 FPGA-IRQ",
126 .startup = startup_se7206_irq,
127 .shutdown = shutdown_se7206_irq,
128 .enable = enable_se7206_irq,
129 .disable = disable_se7206_irq,
130 .ack = ack_se7206_irq,
131 .end = end_se7206_irq,
132 };
133
134 static void make_se7206_irq(unsigned int irq)
135 {
136 disable_irq_nosync(irq);
137 irq_desc[irq].handler = &se7206_irq_type;
138 disable_se7206_irq(irq);
139 }
140
141 /*
142 * Initialize IRQ setting
143 */
144 void __init init_se7206_IRQ(void)
145 {
146 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
147 make_se7206_irq(IRQ1_IRQ); /* ATA */
148 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
149 ctrl_outw(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */
150
151 /* FPGA System register setup*/
152 ctrl_outw(0x0000,INTSTS0); /* Clear INTSTS0 */
153 ctrl_outw(0x0000,INTSTS1); /* Clear INTSTS1 */
154 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
155 ctrl_outw(0x0001,INTSEL);
156 }
157
158 int se7206_irq_demux(int irq)
159 {
160 return irq;
161 }
This page took 0.063463 seconds and 5 git commands to generate.