2 * linux/arch/m32r/kernel/setup_m32700ut.c
4 * Setup routines for Renesas M32700UT Board
6 * Copyright (c) 2002-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi
9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this
11 * archive for more details.
14 #include <linux/config.h>
15 #include <linux/irq.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/device.h>
20 #include <asm/system.h>
25 * M32700 Interrupt Control Unit (Level 1)
27 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
31 unsigned long icucr; /* ICU Control Register */
33 static icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
35 icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
36 #endif /* CONFIG_SMP */
39 static void disable_m32700ut_irq(unsigned int irq)
41 unsigned long port, data;
44 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
48 static void enable_m32700ut_irq(unsigned int irq)
50 unsigned long port, data;
53 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
57 static void mask_and_ack_m32700ut(unsigned int irq)
59 disable_m32700ut_irq(irq);
62 static void end_m32700ut_irq(unsigned int irq)
64 enable_m32700ut_irq(irq);
67 static unsigned int startup_m32700ut_irq(unsigned int irq)
69 enable_m32700ut_irq(irq);
73 static void shutdown_m32700ut_irq(unsigned int irq)
78 outl(M32R_ICUCR_ILEVEL7, port);
81 static struct hw_interrupt_type m32700ut_irq_type =
83 .typename = "M32700UT-IRQ",
84 .startup = startup_m32700ut_irq,
85 .shutdown = shutdown_m32700ut_irq,
86 .enable = enable_m32700ut_irq,
87 .disable = disable_m32700ut_irq,
88 .ack = mask_and_ack_m32700ut,
89 .end = end_m32700ut_irq
93 * Interrupt Control Unit of PLD on M32700UT (Level 2)
95 #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
96 #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
97 (((x) - 1) * sizeof(unsigned short)))
100 unsigned short icucr; /* ICU Control Register */
103 static pld_icu_data_t pld_icu_data[M32700UT_NUM_PLD_IRQ];
105 static void disable_m32700ut_pld_irq(unsigned int irq)
107 unsigned long port, data;
110 pldirq = irq2pldirq(irq);
111 // disable_m32700ut_irq(M32R_IRQ_INT1);
112 port = pldirq2port(pldirq);
113 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
117 static void enable_m32700ut_pld_irq(unsigned int irq)
119 unsigned long port, data;
122 pldirq = irq2pldirq(irq);
123 // enable_m32700ut_irq(M32R_IRQ_INT1);
124 port = pldirq2port(pldirq);
125 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
129 static void mask_and_ack_m32700ut_pld(unsigned int irq)
131 disable_m32700ut_pld_irq(irq);
132 // mask_and_ack_m32700ut(M32R_IRQ_INT1);
135 static void end_m32700ut_pld_irq(unsigned int irq)
137 enable_m32700ut_pld_irq(irq);
138 end_m32700ut_irq(M32R_IRQ_INT1);
141 static unsigned int startup_m32700ut_pld_irq(unsigned int irq)
143 enable_m32700ut_pld_irq(irq);
147 static void shutdown_m32700ut_pld_irq(unsigned int irq)
152 pldirq = irq2pldirq(irq);
153 // shutdown_m32700ut_irq(M32R_IRQ_INT1);
154 port = pldirq2port(pldirq);
155 outw(PLD_ICUCR_ILEVEL7, port);
158 static struct hw_interrupt_type m32700ut_pld_irq_type =
160 .typename = "M32700UT-PLD-IRQ",
161 .startup = startup_m32700ut_pld_irq,
162 .shutdown = shutdown_m32700ut_pld_irq,
163 .enable = enable_m32700ut_pld_irq,
164 .disable = disable_m32700ut_pld_irq,
165 .ack = mask_and_ack_m32700ut_pld,
166 .end = end_m32700ut_pld_irq
170 * Interrupt Control Unit of PLD on M32700UT-LAN (Level 2)
172 #define irq2lanpldirq(x) ((x) - M32700UT_LAN_PLD_IRQ_BASE)
173 #define lanpldirq2port(x) (unsigned long)((int)M32700UT_LAN_ICUCR1 + \
174 (((x) - 1) * sizeof(unsigned short)))
176 static pld_icu_data_t lanpld_icu_data[M32700UT_NUM_LAN_PLD_IRQ];
178 static void disable_m32700ut_lanpld_irq(unsigned int irq)
180 unsigned long port, data;
183 pldirq = irq2lanpldirq(irq);
184 port = lanpldirq2port(pldirq);
185 data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
189 static void enable_m32700ut_lanpld_irq(unsigned int irq)
191 unsigned long port, data;
194 pldirq = irq2lanpldirq(irq);
195 port = lanpldirq2port(pldirq);
196 data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
200 static void mask_and_ack_m32700ut_lanpld(unsigned int irq)
202 disable_m32700ut_lanpld_irq(irq);
205 static void end_m32700ut_lanpld_irq(unsigned int irq)
207 enable_m32700ut_lanpld_irq(irq);
208 end_m32700ut_irq(M32R_IRQ_INT0);
211 static unsigned int startup_m32700ut_lanpld_irq(unsigned int irq)
213 enable_m32700ut_lanpld_irq(irq);
217 static void shutdown_m32700ut_lanpld_irq(unsigned int irq)
222 pldirq = irq2lanpldirq(irq);
223 port = lanpldirq2port(pldirq);
224 outw(PLD_ICUCR_ILEVEL7, port);
227 static struct hw_interrupt_type m32700ut_lanpld_irq_type =
229 .typename = "M32700UT-PLD-LAN-IRQ",
230 .startup = startup_m32700ut_lanpld_irq,
231 .shutdown = shutdown_m32700ut_lanpld_irq,
232 .enable = enable_m32700ut_lanpld_irq,
233 .disable = disable_m32700ut_lanpld_irq,
234 .ack = mask_and_ack_m32700ut_lanpld,
235 .end = end_m32700ut_lanpld_irq
239 * Interrupt Control Unit of PLD on M32700UT-LCD (Level 2)
241 #define irq2lcdpldirq(x) ((x) - M32700UT_LCD_PLD_IRQ_BASE)
242 #define lcdpldirq2port(x) (unsigned long)((int)M32700UT_LCD_ICUCR1 + \
243 (((x) - 1) * sizeof(unsigned short)))
245 static pld_icu_data_t lcdpld_icu_data[M32700UT_NUM_LCD_PLD_IRQ];
247 static void disable_m32700ut_lcdpld_irq(unsigned int irq)
249 unsigned long port, data;
252 pldirq = irq2lcdpldirq(irq);
253 port = lcdpldirq2port(pldirq);
254 data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
258 static void enable_m32700ut_lcdpld_irq(unsigned int irq)
260 unsigned long port, data;
263 pldirq = irq2lcdpldirq(irq);
264 port = lcdpldirq2port(pldirq);
265 data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
269 static void mask_and_ack_m32700ut_lcdpld(unsigned int irq)
271 disable_m32700ut_lcdpld_irq(irq);
274 static void end_m32700ut_lcdpld_irq(unsigned int irq)
276 enable_m32700ut_lcdpld_irq(irq);
277 end_m32700ut_irq(M32R_IRQ_INT2);
280 static unsigned int startup_m32700ut_lcdpld_irq(unsigned int irq)
282 enable_m32700ut_lcdpld_irq(irq);
286 static void shutdown_m32700ut_lcdpld_irq(unsigned int irq)
291 pldirq = irq2lcdpldirq(irq);
292 port = lcdpldirq2port(pldirq);
293 outw(PLD_ICUCR_ILEVEL7, port);
296 static struct hw_interrupt_type m32700ut_lcdpld_irq_type =
298 .typename = "M32700UT-PLD-LCD-IRQ",
299 .startup = startup_m32700ut_lcdpld_irq,
300 .shutdown = shutdown_m32700ut_lcdpld_irq,
301 .enable = enable_m32700ut_lcdpld_irq,
302 .disable = disable_m32700ut_lcdpld_irq,
303 .ack = mask_and_ack_m32700ut_lcdpld,
304 .end = end_m32700ut_lcdpld_irq
307 void __init init_IRQ(void)
309 #if defined(CONFIG_SMC91X)
310 /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
311 irq_desc[M32700UT_LAN_IRQ_LAN].status = IRQ_DISABLED;
312 irq_desc[M32700UT_LAN_IRQ_LAN].handler = &m32700ut_lanpld_irq_type;
313 irq_desc[M32700UT_LAN_IRQ_LAN].action = 0;
314 irq_desc[M32700UT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */
315 lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
316 disable_m32700ut_lanpld_irq(M32700UT_LAN_IRQ_LAN);
317 #endif /* CONFIG_SMC91X */
319 /* MFT2 : system timer */
320 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
321 irq_desc[M32R_IRQ_MFT2].handler = &m32700ut_irq_type;
322 irq_desc[M32R_IRQ_MFT2].action = 0;
323 irq_desc[M32R_IRQ_MFT2].depth = 1;
324 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
325 disable_m32700ut_irq(M32R_IRQ_MFT2);
328 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
329 irq_desc[M32R_IRQ_SIO0_R].handler = &m32700ut_irq_type;
330 irq_desc[M32R_IRQ_SIO0_R].action = 0;
331 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
332 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
333 disable_m32700ut_irq(M32R_IRQ_SIO0_R);
336 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
337 irq_desc[M32R_IRQ_SIO0_S].handler = &m32700ut_irq_type;
338 irq_desc[M32R_IRQ_SIO0_S].action = 0;
339 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
340 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
341 disable_m32700ut_irq(M32R_IRQ_SIO0_S);
344 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
345 irq_desc[M32R_IRQ_SIO1_R].handler = &m32700ut_irq_type;
346 irq_desc[M32R_IRQ_SIO1_R].action = 0;
347 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
348 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
349 disable_m32700ut_irq(M32R_IRQ_SIO1_R);
352 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
353 irq_desc[M32R_IRQ_SIO1_S].handler = &m32700ut_irq_type;
354 irq_desc[M32R_IRQ_SIO1_S].action = 0;
355 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
356 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
357 disable_m32700ut_irq(M32R_IRQ_SIO1_S);
360 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED;
361 irq_desc[M32R_IRQ_DMA1].handler = &m32700ut_irq_type;
362 irq_desc[M32R_IRQ_DMA1].action = 0;
363 irq_desc[M32R_IRQ_DMA1].depth = 1;
364 icu_data[M32R_IRQ_DMA1].icucr = 0;
365 disable_m32700ut_irq(M32R_IRQ_DMA1);
367 #ifdef CONFIG_SERIAL_M32R_PLDSIO
368 /* INT#1: SIO0 Receive on PLD */
369 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED;
370 irq_desc[PLD_IRQ_SIO0_RCV].handler = &m32700ut_pld_irq_type;
371 irq_desc[PLD_IRQ_SIO0_RCV].action = 0;
372 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */
373 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
374 disable_m32700ut_pld_irq(PLD_IRQ_SIO0_RCV);
376 /* INT#1: SIO0 Send on PLD */
377 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED;
378 irq_desc[PLD_IRQ_SIO0_SND].handler = &m32700ut_pld_irq_type;
379 irq_desc[PLD_IRQ_SIO0_SND].action = 0;
380 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */
381 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
382 disable_m32700ut_pld_irq(PLD_IRQ_SIO0_SND);
383 #endif /* CONFIG_SERIAL_M32R_PLDSIO */
385 /* INT#1: CFC IREQ on PLD */
386 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
387 irq_desc[PLD_IRQ_CFIREQ].handler = &m32700ut_pld_irq_type;
388 irq_desc[PLD_IRQ_CFIREQ].action = 0;
389 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
390 pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
391 disable_m32700ut_pld_irq(PLD_IRQ_CFIREQ);
393 /* INT#1: CFC Insert on PLD */
394 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
395 irq_desc[PLD_IRQ_CFC_INSERT].handler = &m32700ut_pld_irq_type;
396 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
397 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
398 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
399 disable_m32700ut_pld_irq(PLD_IRQ_CFC_INSERT);
401 /* INT#1: CFC Eject on PLD */
402 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
403 irq_desc[PLD_IRQ_CFC_EJECT].handler = &m32700ut_pld_irq_type;
404 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
405 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
406 pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
407 disable_m32700ut_pld_irq(PLD_IRQ_CFC_EJECT);
410 * INT0# is used for LAN, DIO
413 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
414 enable_m32700ut_irq(M32R_IRQ_INT0);
417 * INT1# is used for UART, MMC, CF Controller in FPGA.
420 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
421 enable_m32700ut_irq(M32R_IRQ_INT1);
423 #if defined(CONFIG_USB)
424 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
426 irq_desc[M32700UT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED;
427 irq_desc[M32700UT_LCD_IRQ_USB_INT1].handler = &m32700ut_lcdpld_irq_type;
428 irq_desc[M32700UT_LCD_IRQ_USB_INT1].action = 0;
429 irq_desc[M32700UT_LCD_IRQ_USB_INT1].depth = 1;
430 lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
431 disable_m32700ut_lcdpld_irq(M32700UT_LCD_IRQ_USB_INT1);
434 * INT2# is used for BAT, USB, AUDIO
437 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
438 enable_m32700ut_irq(M32R_IRQ_INT2);
440 #if defined(CONFIG_VIDEO_M32R_AR)
442 * INT3# is used for AR
444 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
445 irq_desc[M32R_IRQ_INT3].handler = &m32700ut_irq_type;
446 irq_desc[M32R_IRQ_INT3].action = 0;
447 irq_desc[M32R_IRQ_INT3].depth = 1;
448 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
449 disable_m32700ut_irq(M32R_IRQ_INT3);
450 #endif /* CONFIG_VIDEO_M32R_AR */
453 #if defined(CONFIG_SMC91X)
455 #define LAN_IOSTART 0x300
456 #define LAN_IOEND 0x320
457 static struct resource smc91x_resources[] = {
459 .start = (LAN_IOSTART),
461 .flags = IORESOURCE_MEM,
464 .start = M32700UT_LAN_IRQ_LAN,
465 .end = M32700UT_LAN_IRQ_LAN,
466 .flags = IORESOURCE_IRQ,
470 static struct platform_device smc91x_device = {
473 .num_resources = ARRAY_SIZE(smc91x_resources),
474 .resource = smc91x_resources,
478 #if defined(CONFIG_FB_S1D13XXX)
480 #include <video/s1d13xxxfb.h>
481 #include <asm/s1d13806.h>
483 static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
484 .initregs = s1d13xxxfb_initregs,
485 .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
486 .platform_init_video = NULL,
488 .platform_suspend_video = NULL,
489 .platform_resume_video = NULL,
493 static struct resource s1d13xxxfb_resources[] = {
495 .start = 0x10600000UL,
497 .flags = IORESOURCE_MEM,
500 .start = 0x10400000UL,
502 .flags = IORESOURCE_MEM,
506 static struct platform_device s1d13xxxfb_device = {
507 .name = S1D_DEVICENAME,
510 .platform_data = &s1d13xxxfb_data,
512 .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
513 .resource = s1d13xxxfb_resources,
517 static int __init platform_init(void)
519 #if defined(CONFIG_SMC91X)
520 platform_device_register(&smc91x_device);
522 #if defined(CONFIG_FB_S1D13XXX)
523 platform_device_register(&s1d13xxxfb_device);
527 arch_initcall(platform_init);