2 * linux/arch/m32r/platforms/opsput/setup.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/irq.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
20 #include <asm/system.h>
25 * OPSP Interrupt Control Unit (Level 1)
27 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
29 icu_data_t icu_data
[OPSPUT_NUM_CPU_IRQ
];
31 static void disable_opsput_irq(unsigned int irq
)
33 unsigned long port
, data
;
36 data
= icu_data
[irq
].icucr
|M32R_ICUCR_ILEVEL7
;
40 static void enable_opsput_irq(unsigned int irq
)
42 unsigned long port
, data
;
45 data
= icu_data
[irq
].icucr
|M32R_ICUCR_IEN
|M32R_ICUCR_ILEVEL6
;
49 static void mask_opsput(struct irq_data
*data
)
51 disable_opsput_irq(data
->irq
);
54 static void unmask_opsput(struct irq_data
*data
)
56 enable_opsput_irq(data
->irq
);
59 static void shutdown_opsput(struct irq_data
*data
)
63 port
= irq2port(data
->irq
);
64 outl(M32R_ICUCR_ILEVEL7
, port
);
67 static struct irq_chip opsput_irq_type
=
70 .irq_shutdown
= shutdown_opsput
,
71 .irq_mask
= mask_opsput
,
72 .irq_unmask
= unmask_opsput
,
76 * Interrupt Control Unit of PLD on OPSPUT (Level 2)
78 #define irq2pldirq(x) ((x) - OPSPUT_PLD_IRQ_BASE)
79 #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
80 (((x) - 1) * sizeof(unsigned short)))
83 unsigned short icucr
; /* ICU Control Register */
86 static pld_icu_data_t pld_icu_data
[OPSPUT_NUM_PLD_IRQ
];
88 static void disable_opsput_pld_irq(unsigned int irq
)
90 unsigned long port
, data
;
93 pldirq
= irq2pldirq(irq
);
94 port
= pldirq2port(pldirq
);
95 data
= pld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
99 static void enable_opsput_pld_irq(unsigned int irq
)
101 unsigned long port
, data
;
104 pldirq
= irq2pldirq(irq
);
105 port
= pldirq2port(pldirq
);
106 data
= pld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
110 static void mask_and_ack_opsput_pld(unsigned int irq
)
112 disable_opsput_pld_irq(irq
);
113 // mask_and_ack_opsput(M32R_IRQ_INT1);
116 static void end_opsput_pld_irq(unsigned int irq
)
118 enable_opsput_pld_irq(irq
);
119 enable_opsput_irq(M32R_IRQ_INT1
);
122 static unsigned int startup_opsput_pld_irq(unsigned int irq
)
124 enable_opsput_pld_irq(irq
);
128 static void shutdown_opsput_pld_irq(unsigned int irq
)
133 pldirq
= irq2pldirq(irq
);
134 // shutdown_opsput_irq(M32R_IRQ_INT1);
135 port
= pldirq2port(pldirq
);
136 outw(PLD_ICUCR_ILEVEL7
, port
);
139 static struct irq_chip opsput_pld_irq_type
=
141 .name
= "OPSPUT-PLD-IRQ",
142 .startup
= startup_opsput_pld_irq
,
143 .shutdown
= shutdown_opsput_pld_irq
,
144 .enable
= enable_opsput_pld_irq
,
145 .disable
= disable_opsput_pld_irq
,
146 .ack
= mask_and_ack_opsput_pld
,
147 .end
= end_opsput_pld_irq
151 * Interrupt Control Unit of PLD on OPSPUT-LAN (Level 2)
153 #define irq2lanpldirq(x) ((x) - OPSPUT_LAN_PLD_IRQ_BASE)
154 #define lanpldirq2port(x) (unsigned long)((int)OPSPUT_LAN_ICUCR1 + \
155 (((x) - 1) * sizeof(unsigned short)))
157 static pld_icu_data_t lanpld_icu_data
[OPSPUT_NUM_LAN_PLD_IRQ
];
159 static void disable_opsput_lanpld_irq(unsigned int irq
)
161 unsigned long port
, data
;
164 pldirq
= irq2lanpldirq(irq
);
165 port
= lanpldirq2port(pldirq
);
166 data
= lanpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
170 static void enable_opsput_lanpld_irq(unsigned int irq
)
172 unsigned long port
, data
;
175 pldirq
= irq2lanpldirq(irq
);
176 port
= lanpldirq2port(pldirq
);
177 data
= lanpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
181 static void mask_and_ack_opsput_lanpld(unsigned int irq
)
183 disable_opsput_lanpld_irq(irq
);
186 static void end_opsput_lanpld_irq(unsigned int irq
)
188 enable_opsput_lanpld_irq(irq
);
189 enable_opsput_irq(M32R_IRQ_INT0
);
192 static unsigned int startup_opsput_lanpld_irq(unsigned int irq
)
194 enable_opsput_lanpld_irq(irq
);
198 static void shutdown_opsput_lanpld_irq(unsigned int irq
)
203 pldirq
= irq2lanpldirq(irq
);
204 port
= lanpldirq2port(pldirq
);
205 outw(PLD_ICUCR_ILEVEL7
, port
);
208 static struct irq_chip opsput_lanpld_irq_type
=
210 .name
= "OPSPUT-PLD-LAN-IRQ",
211 .startup
= startup_opsput_lanpld_irq
,
212 .shutdown
= shutdown_opsput_lanpld_irq
,
213 .enable
= enable_opsput_lanpld_irq
,
214 .disable
= disable_opsput_lanpld_irq
,
215 .ack
= mask_and_ack_opsput_lanpld
,
216 .end
= end_opsput_lanpld_irq
220 * Interrupt Control Unit of PLD on OPSPUT-LCD (Level 2)
222 #define irq2lcdpldirq(x) ((x) - OPSPUT_LCD_PLD_IRQ_BASE)
223 #define lcdpldirq2port(x) (unsigned long)((int)OPSPUT_LCD_ICUCR1 + \
224 (((x) - 1) * sizeof(unsigned short)))
226 static pld_icu_data_t lcdpld_icu_data
[OPSPUT_NUM_LCD_PLD_IRQ
];
228 static void disable_opsput_lcdpld_irq(unsigned int irq
)
230 unsigned long port
, data
;
233 pldirq
= irq2lcdpldirq(irq
);
234 port
= lcdpldirq2port(pldirq
);
235 data
= lcdpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
239 static void enable_opsput_lcdpld_irq(unsigned int irq
)
241 unsigned long port
, data
;
244 pldirq
= irq2lcdpldirq(irq
);
245 port
= lcdpldirq2port(pldirq
);
246 data
= lcdpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
250 static void mask_and_ack_opsput_lcdpld(unsigned int irq
)
252 disable_opsput_lcdpld_irq(irq
);
255 static void end_opsput_lcdpld_irq(unsigned int irq
)
257 enable_opsput_lcdpld_irq(irq
);
258 enable_opsput_irq(M32R_IRQ_INT2
);
261 static unsigned int startup_opsput_lcdpld_irq(unsigned int irq
)
263 enable_opsput_lcdpld_irq(irq
);
267 static void shutdown_opsput_lcdpld_irq(unsigned int irq
)
272 pldirq
= irq2lcdpldirq(irq
);
273 port
= lcdpldirq2port(pldirq
);
274 outw(PLD_ICUCR_ILEVEL7
, port
);
277 static struct irq_chip opsput_lcdpld_irq_type
=
279 "OPSPUT-PLD-LCD-IRQ",
280 startup_opsput_lcdpld_irq
,
281 shutdown_opsput_lcdpld_irq
,
282 enable_opsput_lcdpld_irq
,
283 disable_opsput_lcdpld_irq
,
284 mask_and_ack_opsput_lcdpld
,
285 end_opsput_lcdpld_irq
288 void __init
init_IRQ(void)
290 #if defined(CONFIG_SMC91X)
291 /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/
292 set_irq_chip(OPSPUT_LAN_IRQ_LAN
, &opsput_lanpld_irq_type
);
293 lanpld_icu_data
[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD02
; /* "H" edge sense */
294 disable_opsput_lanpld_irq(OPSPUT_LAN_IRQ_LAN
);
295 #endif /* CONFIG_SMC91X */
297 /* MFT2 : system timer */
298 set_irq_chip_and_handler(M32R_IRQ_MFT2
, &opsput_irq_type
,
300 icu_data
[M32R_IRQ_MFT2
].icucr
= M32R_ICUCR_IEN
;
301 disable_opsput_irq(M32R_IRQ_MFT2
);
304 set_irq_chip_and_handler(M32R_IRQ_SIO0_R
, &opsput_irq_type
,
306 icu_data
[M32R_IRQ_SIO0_R
].icucr
= 0;
307 disable_opsput_irq(M32R_IRQ_SIO0_R
);
310 set_irq_chip_and_handler(M32R_IRQ_SIO0_S
, &opsput_irq_type
,
312 icu_data
[M32R_IRQ_SIO0_S
].icucr
= 0;
313 disable_opsput_irq(M32R_IRQ_SIO0_S
);
316 set_irq_chip_and_handler(M32R_IRQ_SIO1_R
, &opsput_irq_type
,
318 icu_data
[M32R_IRQ_SIO1_R
].icucr
= 0;
319 disable_opsput_irq(M32R_IRQ_SIO1_R
);
322 set_irq_chip_and_handler(M32R_IRQ_SIO1_S
, &opsput_irq_type
,
324 icu_data
[M32R_IRQ_SIO1_S
].icucr
= 0;
325 disable_opsput_irq(M32R_IRQ_SIO1_S
);
328 set_irq_chip_and_handler(M32R_IRQ_DMA1
, &opsput_irq_type
,
330 icu_data
[M32R_IRQ_DMA1
].icucr
= 0;
331 disable_opsput_irq(M32R_IRQ_DMA1
);
333 #ifdef CONFIG_SERIAL_M32R_PLDSIO
334 /* INT#1: SIO0 Receive on PLD */
335 set_irq_chip(PLD_IRQ_SIO0_RCV
, &opsput_pld_irq_type
);
336 pld_icu_data
[irq2pldirq(PLD_IRQ_SIO0_RCV
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD03
;
337 disable_opsput_pld_irq(PLD_IRQ_SIO0_RCV
);
339 /* INT#1: SIO0 Send on PLD */
340 set_irq_chip(PLD_IRQ_SIO0_SND
, &opsput_pld_irq_type
);
341 pld_icu_data
[irq2pldirq(PLD_IRQ_SIO0_SND
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD03
;
342 disable_opsput_pld_irq(PLD_IRQ_SIO0_SND
);
343 #endif /* CONFIG_SERIAL_M32R_PLDSIO */
345 /* INT#1: CFC IREQ on PLD */
346 set_irq_chip(PLD_IRQ_CFIREQ
, &opsput_pld_irq_type
);
347 pld_icu_data
[irq2pldirq(PLD_IRQ_CFIREQ
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD01
; /* 'L' level sense */
348 disable_opsput_pld_irq(PLD_IRQ_CFIREQ
);
350 /* INT#1: CFC Insert on PLD */
351 set_irq_chip(PLD_IRQ_CFC_INSERT
, &opsput_pld_irq_type
);
352 pld_icu_data
[irq2pldirq(PLD_IRQ_CFC_INSERT
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD00
; /* 'L' edge sense */
353 disable_opsput_pld_irq(PLD_IRQ_CFC_INSERT
);
355 /* INT#1: CFC Eject on PLD */
356 set_irq_chip(PLD_IRQ_CFC_EJECT
, &opsput_pld_irq_type
);
357 pld_icu_data
[irq2pldirq(PLD_IRQ_CFC_EJECT
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD02
; /* 'H' edge sense */
358 disable_opsput_pld_irq(PLD_IRQ_CFC_EJECT
);
361 * INT0# is used for LAN, DIO
364 icu_data
[M32R_IRQ_INT0
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD11
;
365 enable_opsput_irq(M32R_IRQ_INT0
);
368 * INT1# is used for UART, MMC, CF Controller in FPGA.
371 icu_data
[M32R_IRQ_INT1
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD11
;
372 enable_opsput_irq(M32R_IRQ_INT1
);
374 #if defined(CONFIG_USB)
375 outw(USBCR_OTGS
, USBCR
); /* USBCR: non-OTG */
377 set_irq_chip(OPSPUT_LCD_IRQ_USB_INT1
, &opsput_lcdpld_irq_type
);
378 lcdpld_icu_data
[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD01
; /* "L" level sense */
379 disable_opsput_lcdpld_irq(OPSPUT_LCD_IRQ_USB_INT1
);
382 * INT2# is used for BAT, USB, AUDIO
385 icu_data
[M32R_IRQ_INT2
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD01
;
386 enable_opsput_irq(M32R_IRQ_INT2
);
388 #if defined(CONFIG_VIDEO_M32R_AR)
390 * INT3# is used for AR
392 set_irq_chip_and_handler(M32R_IRQ_INT3
, &opsput_irq_type
,
394 icu_data
[M32R_IRQ_INT3
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD10
;
395 disable_opsput_irq(M32R_IRQ_INT3
);
396 #endif /* CONFIG_VIDEO_M32R_AR */
399 #if defined(CONFIG_SMC91X)
401 #define LAN_IOSTART 0x300
402 #define LAN_IOEND 0x320
403 static struct resource smc91x_resources
[] = {
405 .start
= (LAN_IOSTART
),
407 .flags
= IORESOURCE_MEM
,
410 .start
= OPSPUT_LAN_IRQ_LAN
,
411 .end
= OPSPUT_LAN_IRQ_LAN
,
412 .flags
= IORESOURCE_IRQ
,
416 static struct platform_device smc91x_device
= {
419 .num_resources
= ARRAY_SIZE(smc91x_resources
),
420 .resource
= smc91x_resources
,
424 #if defined(CONFIG_FB_S1D13XXX)
426 #include <video/s1d13xxxfb.h>
427 #include <asm/s1d13806.h>
429 static struct s1d13xxxfb_pdata s1d13xxxfb_data
= {
430 .initregs
= s1d13xxxfb_initregs
,
431 .initregssize
= ARRAY_SIZE(s1d13xxxfb_initregs
),
432 .platform_init_video
= NULL
,
434 .platform_suspend_video
= NULL
,
435 .platform_resume_video
= NULL
,
439 static struct resource s1d13xxxfb_resources
[] = {
441 .start
= 0x10600000UL
,
443 .flags
= IORESOURCE_MEM
,
446 .start
= 0x10400000UL
,
448 .flags
= IORESOURCE_MEM
,
452 static struct platform_device s1d13xxxfb_device
= {
453 .name
= S1D_DEVICENAME
,
456 .platform_data
= &s1d13xxxfb_data
,
458 .num_resources
= ARRAY_SIZE(s1d13xxxfb_resources
),
459 .resource
= s1d13xxxfb_resources
,
463 static int __init
platform_init(void)
465 #if defined(CONFIG_SMC91X)
466 platform_device_register(&smc91x_device
);
468 #if defined(CONFIG_FB_S1D13XXX)
469 platform_device_register(&s1d13xxxfb_device
);
473 arch_initcall(platform_init
);