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/platform_device.h>
14 #include <linux/serial_8250.h>
19 #define PORT(_base,_irq) \
24 .iotype = UPIO_PORT, \
25 .flags = UPF_BOOT_AUTOCONF, \
28 static struct plat_serial8250_port a20r_data[] = {
34 static struct platform_device a20r_serial8250_device = {
36 .id = PLAT8250_DEV_PLATFORM,
38 .platform_data = a20r_data,
42 static struct resource a20r_ds1216_rsrc[] = {
46 .flags = IORESOURCE_MEM
50 static struct platform_device a20r_ds1216_device = {
52 .num_resources = ARRAY_SIZE(a20r_ds1216_rsrc),
53 .resource = a20r_ds1216_rsrc
56 static struct resource snirm_82596_rsrc[] = {
60 .flags = IORESOURCE_MEM
65 .flags = IORESOURCE_MEM
70 .flags = IORESOURCE_MEM
75 .flags = IORESOURCE_IRQ
78 .flags = 0x01 /* 16bit mpu port access */
82 static struct platform_device snirm_82596_pdev = {
83 .name = "snirm_82596",
84 .num_resources = ARRAY_SIZE(snirm_82596_rsrc),
85 .resource = snirm_82596_rsrc
88 static struct resource snirm_53c710_rsrc[] = {
92 .flags = IORESOURCE_MEM
97 .flags = IORESOURCE_IRQ
101 static struct platform_device snirm_53c710_pdev = {
102 .name = "snirm_53c710",
103 .num_resources = ARRAY_SIZE(snirm_53c710_rsrc),
104 .resource = snirm_53c710_rsrc
107 static struct resource sc26xx_rsrc[] = {
111 .flags = IORESOURCE_MEM
116 .flags = IORESOURCE_IRQ
120 static unsigned int sc26xx_data[2] = {
121 /* DTR | RTS | DSR | CTS | DCD | RI */
122 (8 << 0) | (4 << 4) | (6 << 8) | (0 << 12) | (6 << 16) | (0 << 20),
123 (3 << 0) | (2 << 4) | (1 << 8) | (2 << 12) | (3 << 16) | (4 << 20)
126 static struct platform_device sc26xx_pdev = {
128 .num_resources = ARRAY_SIZE(sc26xx_rsrc),
129 .resource = sc26xx_rsrc,
131 .platform_data = sc26xx_data,
135 static u32 a20r_ack_hwint(void)
137 u32 status = read_c0_status();
139 write_c0_status(status | 0x00010000);
164 : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
165 write_c0_status(status);
170 static inline void unmask_a20r_irq(unsigned int irq)
172 set_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
176 static inline void mask_a20r_irq(unsigned int irq)
178 clear_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
179 irq_disable_hazard();
182 static void end_a20r_irq(unsigned int irq)
184 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
186 unmask_a20r_irq(irq);
190 static struct irq_chip a20r_irq_type = {
192 .ack = mask_a20r_irq,
193 .mask = mask_a20r_irq,
194 .mask_ack = mask_a20r_irq,
195 .unmask = unmask_a20r_irq,
200 * hwint 0 receive all interrupts
202 static void a20r_hwint(void)
207 clear_c0_status(IE_IRQ0);
208 status = a20r_ack_hwint();
209 cause = read_c0_cause();
211 irq = ffs(((cause & status) >> 8) & 0xf8);
213 do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
214 set_c0_status(IE_IRQ0);
217 void __init sni_a20r_irq_init(void)
221 for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
222 set_irq_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
223 sni_hwint = a20r_hwint;
224 change_c0_status(ST0_IM, IE_IRQ0);
225 setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
228 void sni_a20r_init(void)
230 /* FIXME, remove if not needed */
233 static int __init snirm_a20r_setup_devinit(void)
235 switch (sni_brd_type) {
236 case SNI_BRD_TOWER_OASIC:
237 case SNI_BRD_MINITOWER:
238 platform_device_register(&snirm_82596_pdev);
239 platform_device_register(&snirm_53c710_pdev);
240 platform_device_register(&sc26xx_pdev);
241 platform_device_register(&a20r_serial8250_device);
242 platform_device_register(&a20r_ds1216_device);
243 sni_eisa_root_init();
249 device_initcall(snirm_a20r_setup_devinit);