2 * linux/arch/m32r/platforms/m32700ut/setup.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/irq.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
23 * M32700 Interrupt Control Unit (Level 1)
25 #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
27 icu_data_t icu_data
[M32700UT_NUM_CPU_IRQ
];
29 static void disable_m32700ut_irq(unsigned int irq
)
31 unsigned long port
, data
;
34 data
= icu_data
[irq
].icucr
|M32R_ICUCR_ILEVEL7
;
38 static void enable_m32700ut_irq(unsigned int irq
)
40 unsigned long port
, data
;
43 data
= icu_data
[irq
].icucr
|M32R_ICUCR_IEN
|M32R_ICUCR_ILEVEL6
;
47 static void mask_m32700ut(struct irq_data
*data
)
49 disable_m32700ut_irq(data
->irq
);
52 static void unmask_m32700ut(struct irq_data
*data
)
54 enable_m32700ut_irq(data
->irq
);
57 static void shutdown_m32700ut(struct irq_data
*data
)
61 port
= irq2port(data
->irq
);
62 outl(M32R_ICUCR_ILEVEL7
, port
);
65 static struct irq_chip m32700ut_irq_type
=
67 .name
= "M32700UT-IRQ",
68 .irq_shutdown
= shutdown_m32700ut
,
69 .irq_mask
= mask_m32700ut
,
70 .irq_unmask
= unmask_m32700ut
74 * Interrupt Control Unit of PLD on M32700UT (Level 2)
76 #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
77 #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
78 (((x) - 1) * sizeof(unsigned short)))
81 unsigned short icucr
; /* ICU Control Register */
84 static pld_icu_data_t pld_icu_data
[M32700UT_NUM_PLD_IRQ
];
86 static void disable_m32700ut_pld_irq(unsigned int irq
)
88 unsigned long port
, data
;
91 pldirq
= irq2pldirq(irq
);
92 port
= pldirq2port(pldirq
);
93 data
= pld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
97 static void enable_m32700ut_pld_irq(unsigned int irq
)
99 unsigned long port
, data
;
102 pldirq
= irq2pldirq(irq
);
103 port
= pldirq2port(pldirq
);
104 data
= pld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
108 static void mask_m32700ut_pld(struct irq_data
*data
)
110 disable_m32700ut_pld_irq(data
->irq
);
113 static void unmask_m32700ut_pld(struct irq_data
*data
)
115 enable_m32700ut_pld_irq(data
->irq
);
116 enable_m32700ut_irq(M32R_IRQ_INT1
);
119 static void shutdown_m32700ut_pld_irq(struct irq_data
*data
)
124 pldirq
= irq2pldirq(data
->irq
);
125 port
= pldirq2port(pldirq
);
126 outw(PLD_ICUCR_ILEVEL7
, port
);
129 static struct irq_chip m32700ut_pld_irq_type
=
131 .name
= "M32700UT-PLD-IRQ",
132 .irq_shutdown
= shutdown_m32700ut_pld_irq
,
133 .irq_mask
= mask_m32700ut_pld
,
134 .irq_unmask
= unmask_m32700ut_pld
,
138 * Interrupt Control Unit of PLD on M32700UT-LAN (Level 2)
140 #define irq2lanpldirq(x) ((x) - M32700UT_LAN_PLD_IRQ_BASE)
141 #define lanpldirq2port(x) (unsigned long)((int)M32700UT_LAN_ICUCR1 + \
142 (((x) - 1) * sizeof(unsigned short)))
144 static pld_icu_data_t lanpld_icu_data
[M32700UT_NUM_LAN_PLD_IRQ
];
146 static void disable_m32700ut_lanpld_irq(unsigned int irq
)
148 unsigned long port
, data
;
151 pldirq
= irq2lanpldirq(irq
);
152 port
= lanpldirq2port(pldirq
);
153 data
= lanpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
157 static void enable_m32700ut_lanpld_irq(unsigned int irq
)
159 unsigned long port
, data
;
162 pldirq
= irq2lanpldirq(irq
);
163 port
= lanpldirq2port(pldirq
);
164 data
= lanpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
168 static void mask_m32700ut_lanpld(struct irq_data
*data
)
170 disable_m32700ut_lanpld_irq(data
->irq
);
173 static void unmask_m32700ut_lanpld(struct irq_data
*data
)
175 enable_m32700ut_lanpld_irq(data
->irq
);
176 enable_m32700ut_irq(M32R_IRQ_INT0
);
179 static void shutdown_m32700ut_lanpld(struct irq_data
*data
)
184 pldirq
= irq2lanpldirq(data
->irq
);
185 port
= lanpldirq2port(pldirq
);
186 outw(PLD_ICUCR_ILEVEL7
, port
);
189 static struct irq_chip m32700ut_lanpld_irq_type
=
191 .name
= "M32700UT-PLD-LAN-IRQ",
192 .irq_shutdown
= shutdown_m32700ut_lanpld
,
193 .irq_mask
= mask_m32700ut_lanpld
,
194 .irq_unmask
= unmask_m32700ut_lanpld
,
198 * Interrupt Control Unit of PLD on M32700UT-LCD (Level 2)
200 #define irq2lcdpldirq(x) ((x) - M32700UT_LCD_PLD_IRQ_BASE)
201 #define lcdpldirq2port(x) (unsigned long)((int)M32700UT_LCD_ICUCR1 + \
202 (((x) - 1) * sizeof(unsigned short)))
204 static pld_icu_data_t lcdpld_icu_data
[M32700UT_NUM_LCD_PLD_IRQ
];
206 static void disable_m32700ut_lcdpld_irq(unsigned int irq
)
208 unsigned long port
, data
;
211 pldirq
= irq2lcdpldirq(irq
);
212 port
= lcdpldirq2port(pldirq
);
213 data
= lcdpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_ILEVEL7
;
217 static void enable_m32700ut_lcdpld_irq(unsigned int irq
)
219 unsigned long port
, data
;
222 pldirq
= irq2lcdpldirq(irq
);
223 port
= lcdpldirq2port(pldirq
);
224 data
= lcdpld_icu_data
[pldirq
].icucr
|PLD_ICUCR_IEN
|PLD_ICUCR_ILEVEL6
;
228 static void mask_m32700ut_lcdpld(struct irq_data
*data
)
230 disable_m32700ut_lcdpld_irq(data
->irq
);
233 static void unmask_m32700ut_lcdpld(struct irq_data
*data
)
235 enable_m32700ut_lcdpld_irq(data
->irq
);
236 enable_m32700ut_irq(M32R_IRQ_INT2
);
239 static void shutdown_m32700ut_lcdpld(struct irq_data
*data
)
244 pldirq
= irq2lcdpldirq(data
->irq
);
245 port
= lcdpldirq2port(pldirq
);
246 outw(PLD_ICUCR_ILEVEL7
, port
);
249 static struct irq_chip m32700ut_lcdpld_irq_type
=
251 .name
= "M32700UT-PLD-LCD-IRQ",
252 .irq_shutdown
= shutdown_m32700ut_lcdpld
,
253 .irq_mask
= mask_m32700ut_lcdpld
,
254 .irq_unmask
= unmask_m32700ut_lcdpld
,
257 void __init
init_IRQ(void)
259 #if defined(CONFIG_SMC91X)
260 /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
261 irq_set_chip_and_handler(M32700UT_LAN_IRQ_LAN
,
262 &m32700ut_lanpld_irq_type
, handle_level_irq
);
263 lanpld_icu_data
[irq2lanpldirq(M32700UT_LAN_IRQ_LAN
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD02
; /* "H" edge sense */
264 disable_m32700ut_lanpld_irq(M32700UT_LAN_IRQ_LAN
);
265 #endif /* CONFIG_SMC91X */
267 /* MFT2 : system timer */
268 irq_set_chip_and_handler(M32R_IRQ_MFT2
, &m32700ut_irq_type
,
270 icu_data
[M32R_IRQ_MFT2
].icucr
= M32R_ICUCR_IEN
;
271 disable_m32700ut_irq(M32R_IRQ_MFT2
);
274 irq_set_chip_and_handler(M32R_IRQ_SIO0_R
, &m32700ut_irq_type
,
276 icu_data
[M32R_IRQ_SIO0_R
].icucr
= 0;
277 disable_m32700ut_irq(M32R_IRQ_SIO0_R
);
280 irq_set_chip_and_handler(M32R_IRQ_SIO0_S
, &m32700ut_irq_type
,
282 icu_data
[M32R_IRQ_SIO0_S
].icucr
= 0;
283 disable_m32700ut_irq(M32R_IRQ_SIO0_S
);
286 irq_set_chip_and_handler(M32R_IRQ_SIO1_R
, &m32700ut_irq_type
,
288 icu_data
[M32R_IRQ_SIO1_R
].icucr
= 0;
289 disable_m32700ut_irq(M32R_IRQ_SIO1_R
);
292 irq_set_chip_and_handler(M32R_IRQ_SIO1_S
, &m32700ut_irq_type
,
294 icu_data
[M32R_IRQ_SIO1_S
].icucr
= 0;
295 disable_m32700ut_irq(M32R_IRQ_SIO1_S
);
298 irq_set_chip_and_handler(M32R_IRQ_DMA1
, &m32700ut_irq_type
,
300 icu_data
[M32R_IRQ_DMA1
].icucr
= 0;
301 disable_m32700ut_irq(M32R_IRQ_DMA1
);
303 #ifdef CONFIG_SERIAL_M32R_PLDSIO
304 /* INT#1: SIO0 Receive on PLD */
305 irq_set_chip_and_handler(PLD_IRQ_SIO0_RCV
, &m32700ut_pld_irq_type
,
307 pld_icu_data
[irq2pldirq(PLD_IRQ_SIO0_RCV
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD03
;
308 disable_m32700ut_pld_irq(PLD_IRQ_SIO0_RCV
);
310 /* INT#1: SIO0 Send on PLD */
311 irq_set_chip_and_handler(PLD_IRQ_SIO0_SND
, &m32700ut_pld_irq_type
,
313 pld_icu_data
[irq2pldirq(PLD_IRQ_SIO0_SND
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD03
;
314 disable_m32700ut_pld_irq(PLD_IRQ_SIO0_SND
);
315 #endif /* CONFIG_SERIAL_M32R_PLDSIO */
317 /* INT#1: CFC IREQ on PLD */
318 irq_set_chip_and_handler(PLD_IRQ_CFIREQ
, &m32700ut_pld_irq_type
,
320 pld_icu_data
[irq2pldirq(PLD_IRQ_CFIREQ
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD01
; /* 'L' level sense */
321 disable_m32700ut_pld_irq(PLD_IRQ_CFIREQ
);
323 /* INT#1: CFC Insert on PLD */
324 irq_set_chip_and_handler(PLD_IRQ_CFC_INSERT
, &m32700ut_pld_irq_type
,
326 pld_icu_data
[irq2pldirq(PLD_IRQ_CFC_INSERT
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD00
; /* 'L' edge sense */
327 disable_m32700ut_pld_irq(PLD_IRQ_CFC_INSERT
);
329 /* INT#1: CFC Eject on PLD */
330 irq_set_chip_and_handler(PLD_IRQ_CFC_EJECT
, &m32700ut_pld_irq_type
,
332 pld_icu_data
[irq2pldirq(PLD_IRQ_CFC_EJECT
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD02
; /* 'H' edge sense */
333 disable_m32700ut_pld_irq(PLD_IRQ_CFC_EJECT
);
336 * INT0# is used for LAN, DIO
339 icu_data
[M32R_IRQ_INT0
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD11
;
340 enable_m32700ut_irq(M32R_IRQ_INT0
);
343 * INT1# is used for UART, MMC, CF Controller in FPGA.
346 icu_data
[M32R_IRQ_INT1
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD11
;
347 enable_m32700ut_irq(M32R_IRQ_INT1
);
349 #if defined(CONFIG_USB)
350 outw(USBCR_OTGS
, USBCR
); /* USBCR: non-OTG */
351 irq_set_chip_and_handler(M32700UT_LCD_IRQ_USB_INT1
,
352 &m32700ut_lcdpld_irq_type
, handle_level_irq
);
354 lcdpld_icu_data
[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1
)].icucr
= PLD_ICUCR_IEN
|PLD_ICUCR_ISMOD01
; /* "L" level sense */
355 disable_m32700ut_lcdpld_irq(M32700UT_LCD_IRQ_USB_INT1
);
358 * INT2# is used for BAT, USB, AUDIO
361 icu_data
[M32R_IRQ_INT2
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD01
;
362 enable_m32700ut_irq(M32R_IRQ_INT2
);
364 #if defined(CONFIG_VIDEO_M32R_AR)
366 * INT3# is used for AR
368 irq_set_chip_and_handler(M32R_IRQ_INT3
, &m32700ut_irq_type
,
370 icu_data
[M32R_IRQ_INT3
].icucr
= M32R_ICUCR_IEN
|M32R_ICUCR_ISMOD10
;
371 disable_m32700ut_irq(M32R_IRQ_INT3
);
372 #endif /* CONFIG_VIDEO_M32R_AR */
375 #if defined(CONFIG_SMC91X)
377 #define LAN_IOSTART 0x300
378 #define LAN_IOEND 0x320
379 static struct resource smc91x_resources
[] = {
381 .start
= (LAN_IOSTART
),
383 .flags
= IORESOURCE_MEM
,
386 .start
= M32700UT_LAN_IRQ_LAN
,
387 .end
= M32700UT_LAN_IRQ_LAN
,
388 .flags
= IORESOURCE_IRQ
,
392 static struct platform_device smc91x_device
= {
395 .num_resources
= ARRAY_SIZE(smc91x_resources
),
396 .resource
= smc91x_resources
,
400 #if defined(CONFIG_FB_S1D13XXX)
402 #include <video/s1d13xxxfb.h>
403 #include <asm/s1d13806.h>
405 static struct s1d13xxxfb_pdata s1d13xxxfb_data
= {
406 .initregs
= s1d13xxxfb_initregs
,
407 .initregssize
= ARRAY_SIZE(s1d13xxxfb_initregs
),
408 .platform_init_video
= NULL
,
410 .platform_suspend_video
= NULL
,
411 .platform_resume_video
= NULL
,
415 static struct resource s1d13xxxfb_resources
[] = {
417 .start
= 0x10600000UL
,
419 .flags
= IORESOURCE_MEM
,
422 .start
= 0x10400000UL
,
424 .flags
= IORESOURCE_MEM
,
428 static struct platform_device s1d13xxxfb_device
= {
429 .name
= S1D_DEVICENAME
,
432 .platform_data
= &s1d13xxxfb_data
,
434 .num_resources
= ARRAY_SIZE(s1d13xxxfb_resources
),
435 .resource
= s1d13xxxfb_resources
,
439 static int __init
platform_init(void)
441 #if defined(CONFIG_SMC91X)
442 platform_device_register(&smc91x_device
);
444 #if defined(CONFIG_FB_S1D13XXX)
445 platform_device_register(&s1d13xxxfb_device
);
449 arch_initcall(platform_init
);