2 * linux/arch/m32r/kernel/setup_opsput.c
4 * Setup routines for Renesas OPSPUT Board
6 * Copyright (c) 2002-2005
7 * Hiroyuki Kondo, Hirokazu Takata,
8 * Hitoshi Yamamoto, Takeo Takahashi, Mamoru Sakugawa
10 * This file is subject to the terms and conditions of the GNU General
11 * Public License. See the file "COPYING" in the main directory of this
12 * archive for more details.
15 #include <linux/config.h>
16 #include <linux/irq.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/device.h>
21 #include <asm/system.h>
26 * OPSP Interrupt Control Unit (Level 1)
28 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
32 unsigned long icucr; /* ICU Control Register */
34 #endif /* CONFIG_SMP */
36 static icu_data_t icu_data[OPSPUT_NUM_CPU_IRQ];
38 static void disable_opsput_irq(unsigned int irq)
40 unsigned long port, data;
43 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
47 static void enable_opsput_irq(unsigned int irq)
49 unsigned long port, data;
52 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
56 static void mask_and_ack_opsput(unsigned int irq)
58 disable_opsput_irq(irq);
61 static void end_opsput_irq(unsigned int irq)
63 enable_opsput_irq(irq);
66 static unsigned int startup_opsput_irq(unsigned int irq)
68 enable_opsput_irq(irq);
72 static void shutdown_opsput_irq(unsigned int irq)
77 outl(M32R_ICUCR_ILEVEL7, port);
80 static struct hw_interrupt_type opsput_irq_type =
82 .typename = "OPSPUT-IRQ",
83 .startup = startup_opsput_irq,
84 .shutdown = shutdown_opsput_irq,
85 .enable = enable_opsput_irq,
86 .disable = disable_opsput_irq,
87 .ack = mask_and_ack_opsput,
92 * Interrupt Control Unit of PLD on OPSPUT (Level 2)
94 #define irq2pldirq(x) ((x) - OPSPUT_PLD_IRQ_BASE)
95 #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
96 (((x) - 1) * sizeof(unsigned short)))
99 unsigned short icucr; /* ICU Control Register */
102 static pld_icu_data_t pld_icu_data[OPSPUT_NUM_PLD_IRQ];
104 static void disable_opsput_pld_irq(unsigned int irq)
106 unsigned long port, data;
109 pldirq = irq2pldirq(irq);
110 // disable_opsput_irq(M32R_IRQ_INT1);
111 port = pldirq2port(pldirq);
112 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
116 static void enable_opsput_pld_irq(unsigned int irq)
118 unsigned long port, data;
121 pldirq = irq2pldirq(irq);
122 // enable_opsput_irq(M32R_IRQ_INT1);
123 port = pldirq2port(pldirq);
124 data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
128 static void mask_and_ack_opsput_pld(unsigned int irq)
130 disable_opsput_pld_irq(irq);
131 // mask_and_ack_opsput(M32R_IRQ_INT1);
134 static void end_opsput_pld_irq(unsigned int irq)
136 enable_opsput_pld_irq(irq);
137 end_opsput_irq(M32R_IRQ_INT1);
140 static unsigned int startup_opsput_pld_irq(unsigned int irq)
142 enable_opsput_pld_irq(irq);
146 static void shutdown_opsput_pld_irq(unsigned int irq)
151 pldirq = irq2pldirq(irq);
152 // shutdown_opsput_irq(M32R_IRQ_INT1);
153 port = pldirq2port(pldirq);
154 outw(PLD_ICUCR_ILEVEL7, port);
157 static struct hw_interrupt_type opsput_pld_irq_type =
159 .typename = "OPSPUT-PLD-IRQ",
160 .startup = startup_opsput_pld_irq,
161 .shutdown = shutdown_opsput_pld_irq,
162 .enable = enable_opsput_pld_irq,
163 .disable = disable_opsput_pld_irq,
164 .ack = mask_and_ack_opsput_pld,
165 .end = end_opsput_pld_irq
169 * Interrupt Control Unit of PLD on OPSPUT-LAN (Level 2)
171 #define irq2lanpldirq(x) ((x) - OPSPUT_LAN_PLD_IRQ_BASE)
172 #define lanpldirq2port(x) (unsigned long)((int)OPSPUT_LAN_ICUCR1 + \
173 (((x) - 1) * sizeof(unsigned short)))
175 static pld_icu_data_t lanpld_icu_data[OPSPUT_NUM_LAN_PLD_IRQ];
177 static void disable_opsput_lanpld_irq(unsigned int irq)
179 unsigned long port, data;
182 pldirq = irq2lanpldirq(irq);
183 port = lanpldirq2port(pldirq);
184 data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
188 static void enable_opsput_lanpld_irq(unsigned int irq)
190 unsigned long port, data;
193 pldirq = irq2lanpldirq(irq);
194 port = lanpldirq2port(pldirq);
195 data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
199 static void mask_and_ack_opsput_lanpld(unsigned int irq)
201 disable_opsput_lanpld_irq(irq);
204 static void end_opsput_lanpld_irq(unsigned int irq)
206 enable_opsput_lanpld_irq(irq);
207 end_opsput_irq(M32R_IRQ_INT0);
210 static unsigned int startup_opsput_lanpld_irq(unsigned int irq)
212 enable_opsput_lanpld_irq(irq);
216 static void shutdown_opsput_lanpld_irq(unsigned int irq)
221 pldirq = irq2lanpldirq(irq);
222 port = lanpldirq2port(pldirq);
223 outw(PLD_ICUCR_ILEVEL7, port);
226 static struct hw_interrupt_type opsput_lanpld_irq_type =
228 "OPSPUT-PLD-LAN-IRQ",
229 startup_opsput_lanpld_irq,
230 shutdown_opsput_lanpld_irq,
231 enable_opsput_lanpld_irq,
232 disable_opsput_lanpld_irq,
233 mask_and_ack_opsput_lanpld,
234 end_opsput_lanpld_irq
238 * Interrupt Control Unit of PLD on OPSPUT-LCD (Level 2)
240 #define irq2lcdpldirq(x) ((x) - OPSPUT_LCD_PLD_IRQ_BASE)
241 #define lcdpldirq2port(x) (unsigned long)((int)OPSPUT_LCD_ICUCR1 + \
242 (((x) - 1) * sizeof(unsigned short)))
244 static pld_icu_data_t lcdpld_icu_data[OPSPUT_NUM_LCD_PLD_IRQ];
246 static void disable_opsput_lcdpld_irq(unsigned int irq)
248 unsigned long port, data;
251 pldirq = irq2lcdpldirq(irq);
252 port = lcdpldirq2port(pldirq);
253 data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
257 static void enable_opsput_lcdpld_irq(unsigned int irq)
259 unsigned long port, data;
262 pldirq = irq2lcdpldirq(irq);
263 port = lcdpldirq2port(pldirq);
264 data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
268 static void mask_and_ack_opsput_lcdpld(unsigned int irq)
270 disable_opsput_lcdpld_irq(irq);
273 static void end_opsput_lcdpld_irq(unsigned int irq)
275 enable_opsput_lcdpld_irq(irq);
276 end_opsput_irq(M32R_IRQ_INT2);
279 static unsigned int startup_opsput_lcdpld_irq(unsigned int irq)
281 enable_opsput_lcdpld_irq(irq);
285 static void shutdown_opsput_lcdpld_irq(unsigned int irq)
290 pldirq = irq2lcdpldirq(irq);
291 port = lcdpldirq2port(pldirq);
292 outw(PLD_ICUCR_ILEVEL7, port);
295 static struct hw_interrupt_type opsput_lcdpld_irq_type =
297 "OPSPUT-PLD-LCD-IRQ",
298 startup_opsput_lcdpld_irq,
299 shutdown_opsput_lcdpld_irq,
300 enable_opsput_lcdpld_irq,
301 disable_opsput_lcdpld_irq,
302 mask_and_ack_opsput_lcdpld,
303 end_opsput_lcdpld_irq
306 void __init init_IRQ(void)
308 #if defined(CONFIG_SMC91X)
309 /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/
310 irq_desc[OPSPUT_LAN_IRQ_LAN].status = IRQ_DISABLED;
311 irq_desc[OPSPUT_LAN_IRQ_LAN].handler = &opsput_lanpld_irq_type;
312 irq_desc[OPSPUT_LAN_IRQ_LAN].action = 0;
313 irq_desc[OPSPUT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */
314 lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
315 disable_opsput_lanpld_irq(OPSPUT_LAN_IRQ_LAN);
316 #endif /* CONFIG_SMC91X */
318 /* MFT2 : system timer */
319 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
320 irq_desc[M32R_IRQ_MFT2].handler = &opsput_irq_type;
321 irq_desc[M32R_IRQ_MFT2].action = 0;
322 irq_desc[M32R_IRQ_MFT2].depth = 1;
323 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
324 disable_opsput_irq(M32R_IRQ_MFT2);
327 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
328 irq_desc[M32R_IRQ_SIO0_R].handler = &opsput_irq_type;
329 irq_desc[M32R_IRQ_SIO0_R].action = 0;
330 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
331 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
332 disable_opsput_irq(M32R_IRQ_SIO0_R);
335 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
336 irq_desc[M32R_IRQ_SIO0_S].handler = &opsput_irq_type;
337 irq_desc[M32R_IRQ_SIO0_S].action = 0;
338 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
339 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
340 disable_opsput_irq(M32R_IRQ_SIO0_S);
343 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
344 irq_desc[M32R_IRQ_SIO1_R].handler = &opsput_irq_type;
345 irq_desc[M32R_IRQ_SIO1_R].action = 0;
346 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
347 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
348 disable_opsput_irq(M32R_IRQ_SIO1_R);
351 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
352 irq_desc[M32R_IRQ_SIO1_S].handler = &opsput_irq_type;
353 irq_desc[M32R_IRQ_SIO1_S].action = 0;
354 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
355 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
356 disable_opsput_irq(M32R_IRQ_SIO1_S);
359 irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED;
360 irq_desc[M32R_IRQ_DMA1].handler = &opsput_irq_type;
361 irq_desc[M32R_IRQ_DMA1].action = 0;
362 irq_desc[M32R_IRQ_DMA1].depth = 1;
363 icu_data[M32R_IRQ_DMA1].icucr = 0;
364 disable_opsput_irq(M32R_IRQ_DMA1);
366 #ifdef CONFIG_SERIAL_M32R_PLDSIO
367 /* INT#1: SIO0 Receive on PLD */
368 irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED;
369 irq_desc[PLD_IRQ_SIO0_RCV].handler = &opsput_pld_irq_type;
370 irq_desc[PLD_IRQ_SIO0_RCV].action = 0;
371 irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */
372 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
373 disable_opsput_pld_irq(PLD_IRQ_SIO0_RCV);
375 /* INT#1: SIO0 Send on PLD */
376 irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED;
377 irq_desc[PLD_IRQ_SIO0_SND].handler = &opsput_pld_irq_type;
378 irq_desc[PLD_IRQ_SIO0_SND].action = 0;
379 irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */
380 pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
381 disable_opsput_pld_irq(PLD_IRQ_SIO0_SND);
382 #endif /* CONFIG_SERIAL_M32R_PLDSIO */
384 #if defined(CONFIG_M32R_CFC)
385 /* INT#1: CFC IREQ on PLD */
386 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
387 irq_desc[PLD_IRQ_CFIREQ].handler = &opsput_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_opsput_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 = &opsput_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_opsput_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 = &opsput_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_opsput_pld_irq(PLD_IRQ_CFC_EJECT);
408 #endif /* CONFIG_M32R_CFC */
412 * INT0# is used for LAN, DIO
415 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
416 enable_opsput_irq(M32R_IRQ_INT0);
419 * INT1# is used for UART, MMC, CF Controller in FPGA.
422 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
423 enable_opsput_irq(M32R_IRQ_INT1);
425 #if defined(CONFIG_USB)
426 outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
428 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED;
429 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].handler = &opsput_lcdpld_irq_type;
430 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].action = 0;
431 irq_desc[OPSPUT_LCD_IRQ_USB_INT1].depth = 1;
432 lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
433 disable_opsput_lcdpld_irq(OPSPUT_LCD_IRQ_USB_INT1);
436 * INT2# is used for BAT, USB, AUDIO
439 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
440 enable_opsput_irq(M32R_IRQ_INT2);
442 #if defined(CONFIG_VIDEO_M32R_AR)
444 * INT3# is used for AR
446 irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
447 irq_desc[M32R_IRQ_INT3].handler = &opsput_irq_type;
448 irq_desc[M32R_IRQ_INT3].action = 0;
449 irq_desc[M32R_IRQ_INT3].depth = 1;
450 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
451 disable_opsput_irq(M32R_IRQ_INT3);
452 #endif /* CONFIG_VIDEO_M32R_AR */
455 #if defined(CONFIG_SMC91X)
457 #define LAN_IOSTART 0x300
458 #define LAN_IOEND 0x320
459 static struct resource smc91x_resources[] = {
461 .start = (LAN_IOSTART),
463 .flags = IORESOURCE_MEM,
466 .start = OPSPUT_LAN_IRQ_LAN,
467 .end = OPSPUT_LAN_IRQ_LAN,
468 .flags = IORESOURCE_IRQ,
472 static struct platform_device smc91x_device = {
475 .num_resources = ARRAY_SIZE(smc91x_resources),
476 .resource = smc91x_resources,
480 #if defined(CONFIG_FB_S1D13XXX)
482 #include <video/s1d13xxxfb.h>
483 #include <asm/s1d13806.h>
485 static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
486 .initregs = s1d13xxxfb_initregs,
487 .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
488 .platform_init_video = NULL,
490 .platform_suspend_video = NULL,
491 .platform_resume_video = NULL,
495 static struct resource s1d13xxxfb_resources[] = {
497 .start = 0x10600000UL,
499 .flags = IORESOURCE_MEM,
502 .start = 0x10400000UL,
504 .flags = IORESOURCE_MEM,
508 static struct platform_device s1d13xxxfb_device = {
509 .name = S1D_DEVICENAME,
512 .platform_data = &s1d13xxxfb_data,
514 .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
515 .resource = s1d13xxxfb_resources,
519 static int __init platform_init(void)
521 #if defined(CONFIG_SMC91X)
522 platform_device_register(&smc91x_device);
524 #if defined(CONFIG_FB_S1D13XXX)
525 platform_device_register(&s1d13xxxfb_device);
529 arch_initcall(platform_init);