4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
11 #include <linux/init.h>
12 #include <linux/interrupt.h>
13 #include <linux/irq.h>
14 #include <linux/platform_device.h>
15 #include <linux/serial_8250.h>
20 #define PORT(_base,_irq) \
25 .iotype = UPIO_PORT, \
26 .flags = UPF_BOOT_AUTOCONF, \
29 static struct plat_serial8250_port a20r_data
[] = {
35 static struct platform_device a20r_serial8250_device
= {
37 .id
= PLAT8250_DEV_PLATFORM
,
39 .platform_data
= a20r_data
,
43 static struct resource a20r_ds1216_rsrc
[] = {
47 .flags
= IORESOURCE_MEM
51 static struct platform_device a20r_ds1216_device
= {
53 .num_resources
= ARRAY_SIZE(a20r_ds1216_rsrc
),
54 .resource
= a20r_ds1216_rsrc
57 static struct resource snirm_82596_rsrc
[] = {
61 .flags
= IORESOURCE_MEM
66 .flags
= IORESOURCE_MEM
71 .flags
= IORESOURCE_MEM
76 .flags
= IORESOURCE_IRQ
79 .flags
= 0x01 /* 16bit mpu port access */
83 static struct platform_device snirm_82596_pdev
= {
84 .name
= "snirm_82596",
85 .num_resources
= ARRAY_SIZE(snirm_82596_rsrc
),
86 .resource
= snirm_82596_rsrc
89 static struct resource snirm_53c710_rsrc
[] = {
93 .flags
= IORESOURCE_MEM
98 .flags
= IORESOURCE_IRQ
102 static struct platform_device snirm_53c710_pdev
= {
103 .name
= "snirm_53c710",
104 .num_resources
= ARRAY_SIZE(snirm_53c710_rsrc
),
105 .resource
= snirm_53c710_rsrc
108 static struct resource sc26xx_rsrc
[] = {
112 .flags
= IORESOURCE_MEM
117 .flags
= IORESOURCE_IRQ
121 static unsigned int sc26xx_data
[2] = {
122 /* DTR | RTS | DSR | CTS | DCD | RI */
123 (8 << 0) | (4 << 4) | (6 << 8) | (0 << 12) | (6 << 16) | (0 << 20),
124 (3 << 0) | (2 << 4) | (1 << 8) | (2 << 12) | (3 << 16) | (4 << 20)
127 static struct platform_device sc26xx_pdev
= {
129 .num_resources
= ARRAY_SIZE(sc26xx_rsrc
),
130 .resource
= sc26xx_rsrc
,
132 .platform_data
= sc26xx_data
,
136 static u32
a20r_ack_hwint(void)
138 u32 status
= read_c0_status();
140 write_c0_status(status
| 0x00010000);
165 : "Jr" (PCIMT_UCONF
), "Jr" (0xbc000000));
166 write_c0_status(status
);
171 static inline void unmask_a20r_irq(unsigned int irq
)
173 set_c0_status(0x100 << (irq
- SNI_A20R_IRQ_BASE
));
177 static inline void mask_a20r_irq(unsigned int irq
)
179 clear_c0_status(0x100 << (irq
- SNI_A20R_IRQ_BASE
));
180 irq_disable_hazard();
183 static void end_a20r_irq(unsigned int irq
)
185 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
| IRQ_INPROGRESS
))) {
187 unmask_a20r_irq(irq
);
191 static struct irq_chip a20r_irq_type
= {
193 .ack
= mask_a20r_irq
,
194 .mask
= mask_a20r_irq
,
195 .mask_ack
= mask_a20r_irq
,
196 .unmask
= unmask_a20r_irq
,
201 * hwint 0 receive all interrupts
203 static void a20r_hwint(void)
208 clear_c0_status(IE_IRQ0
);
209 status
= a20r_ack_hwint();
210 cause
= read_c0_cause();
212 irq
= ffs(((cause
& status
) >> 8) & 0xf8);
214 do_IRQ(SNI_A20R_IRQ_BASE
+ irq
- 1);
215 set_c0_status(IE_IRQ0
);
218 void __init
sni_a20r_irq_init(void)
222 for (i
= SNI_A20R_IRQ_BASE
+ 2 ; i
< SNI_A20R_IRQ_BASE
+ 8; i
++)
223 set_irq_chip_and_handler(i
, &a20r_irq_type
, handle_level_irq
);
224 sni_hwint
= a20r_hwint
;
225 change_c0_status(ST0_IM
, IE_IRQ0
);
226 setup_irq(SNI_A20R_IRQ_BASE
+ 3, &sni_isa_irq
);
229 void sni_a20r_init(void)
231 /* FIXME, remove if not needed */
234 static int __init
snirm_a20r_setup_devinit(void)
236 switch (sni_brd_type
) {
237 case SNI_BRD_TOWER_OASIC
:
238 case SNI_BRD_MINITOWER
:
239 platform_device_register(&snirm_82596_pdev
);
240 platform_device_register(&snirm_53c710_pdev
);
241 platform_device_register(&sc26xx_pdev
);
242 platform_device_register(&a20r_serial8250_device
);
243 platform_device_register(&a20r_ds1216_device
);
244 sni_eisa_root_init();
250 device_initcall(snirm_a20r_setup_devinit
);