2 * linux/arch/m32r/platforms/usrv/setup.c
4 * Setup routines for MITSUBISHI uServer
6 * Copyright (c) 2001, 2002, 2003 Hiroyuki Kondo, Hirokazu Takata,
10 #include <linux/irq.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
17 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
19 icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
21 static void disable_mappi_irq(unsigned int irq)
23 unsigned long port, data;
26 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
30 static void enable_mappi_irq(unsigned int irq)
32 unsigned long port, data;
35 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
39 static void mask_mappi(struct irq_data *data)
41 disable_mappi_irq(data->irq);
44 static void unmask_mappi(struct irq_data *data)
46 enable_mappi_irq(data->irq);
49 static void shutdown_mappi(struct irq_data *data)
53 port = irq2port(data->irq);
54 outl(M32R_ICUCR_ILEVEL7, port);
57 static struct irq_chip mappi_irq_type =
60 .irq_shutdown = shutdown_mappi,
61 .irq_mask = mask_mappi,
62 .irq_unmask = unmask_mappi,
66 * Interrupt Control Unit of PLD on M32700UT (Level 2)
68 #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
69 #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
70 (((x) - 1) * sizeof(unsigned short)))
73 unsigned short icucr; /* ICU Control Register */
76 static pld_icu_data_t pld_icu_data[M32700UT_NUM_PLD_IRQ];
78 static void disable_m32700ut_pld_irq(unsigned int irq)
80 unsigned long port, data;
83 pldirq = irq2pldirq(irq);
84 port = pldirq2port(pldirq);
85 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
89 static void enable_m32700ut_pld_irq(unsigned int irq)
91 unsigned long port, data;
94 pldirq = irq2pldirq(irq);
95 port = pldirq2port(pldirq);
96 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
100 static void mask_m32700ut_pld(struct irq_data *data)
102 disable_m32700ut_pld_irq(data->irq);
105 static void unmask_m32700ut_pld(struct irq_data *data)
107 enable_m32700ut_pld_irq(data->irq);
108 enable_mappi_irq(M32R_IRQ_INT1);
111 static void shutdown_m32700ut_pld(struct irq_data *data)
116 pldirq = irq2pldirq(data->irq);
117 port = pldirq2port(pldirq);
118 outw(PLD_ICUCR_ILEVEL7, port);
121 static struct irq_chip m32700ut_pld_irq_type =
123 .name = "USRV-PLD-IRQ",
124 .irq_shutdown = shutdown_m32700ut_pld,
125 .irq_mask = mask_m32700ut_pld,
126 .irq_unmask = unmask_m32700ut_pld,
129 void __init init_IRQ(void)
139 /* MFT2 : system timer */
140 irq_set_chip_and_handler(M32R_IRQ_MFT2, &mappi_irq_type,
142 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
143 disable_mappi_irq(M32R_IRQ_MFT2);
145 #if defined(CONFIG_SERIAL_M32R_SIO)
146 /* SIO0_R : uart receive data */
147 irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &mappi_irq_type,
149 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
150 disable_mappi_irq(M32R_IRQ_SIO0_R);
152 /* SIO0_S : uart send data */
153 irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &mappi_irq_type,
155 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
156 disable_mappi_irq(M32R_IRQ_SIO0_S);
158 /* SIO1_R : uart receive data */
159 irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &mappi_irq_type,
161 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
162 disable_mappi_irq(M32R_IRQ_SIO1_R);
164 /* SIO1_S : uart send data */
165 irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &mappi_irq_type,
167 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
168 disable_mappi_irq(M32R_IRQ_SIO1_S);
169 #endif /* CONFIG_SERIAL_M32R_SIO */
171 /* INT#67-#71: CFC#0 IREQ on PLD */
172 for (i = 0 ; i < CONFIG_M32R_CFC_NUM ; i++ ) {
173 irq_set_chip_and_handler(PLD_IRQ_CF0 + i,
174 &m32700ut_pld_irq_type,
176 pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr
177 = PLD_ICUCR_ISMOD01; /* 'L' level sense */
178 disable_m32700ut_pld_irq(PLD_IRQ_CF0 + i);
181 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
182 /* INT#76: 16552D#0 IREQ on PLD */
183 irq_set_chip_and_handler(PLD_IRQ_UART0, &m32700ut_pld_irq_type,
185 pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr
186 = PLD_ICUCR_ISMOD03; /* 'H' level sense */
187 disable_m32700ut_pld_irq(PLD_IRQ_UART0);
189 /* INT#77: 16552D#1 IREQ on PLD */
190 irq_set_chip_and_handler(PLD_IRQ_UART1, &m32700ut_pld_irq_type,
192 pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr
193 = PLD_ICUCR_ISMOD03; /* 'H' level sense */
194 disable_m32700ut_pld_irq(PLD_IRQ_UART1);
195 #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */
197 #if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE)
198 /* INT#80: AK4524 IREQ on PLD */
199 irq_set_chip_and_handler(PLD_IRQ_SNDINT, &m32700ut_pld_irq_type,
201 pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr
202 = PLD_ICUCR_ISMOD01; /* 'L' level sense */
203 disable_m32700ut_pld_irq(PLD_IRQ_SNDINT);
204 #endif /* CONFIG_IDC_AK4524 || CONFIG_IDC_AK4524_MODULE */
207 * INT1# is used for UART, MMC, CF Controller in FPGA.
210 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD11;
211 enable_mappi_irq(M32R_IRQ_INT1);