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>
18 #include <asm/ds1216.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 snirm_82596_rsrc[] = {
47 .flags = IORESOURCE_MEM
52 .flags = IORESOURCE_MEM
57 .flags = IORESOURCE_MEM
62 .flags = IORESOURCE_IRQ
65 .flags = 0x01 /* 16bit mpu port access */
69 static struct platform_device snirm_82596_pdev = {
70 .name = "snirm_82596",
71 .num_resources = ARRAY_SIZE(snirm_82596_rsrc),
72 .resource = snirm_82596_rsrc
75 static struct resource snirm_53c710_rsrc[] = {
79 .flags = IORESOURCE_MEM
84 .flags = IORESOURCE_IRQ
88 static struct platform_device snirm_53c710_pdev = {
89 .name = "snirm_53c710",
90 .num_resources = ARRAY_SIZE(snirm_53c710_rsrc),
91 .resource = snirm_53c710_rsrc
94 static struct resource sc26xx_rsrc[] = {
98 .flags = IORESOURCE_MEM
103 .flags = IORESOURCE_IRQ
107 static struct platform_device sc26xx_pdev = {
109 .num_resources = ARRAY_SIZE(sc26xx_rsrc),
110 .resource = sc26xx_rsrc
113 static u32 a20r_ack_hwint(void)
115 u32 status = read_c0_status();
117 write_c0_status (status | 0x00010000);
142 : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
143 write_c0_status(status);
148 static inline void unmask_a20r_irq(unsigned int irq)
150 set_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
154 static inline void mask_a20r_irq(unsigned int irq)
156 clear_c0_status(0x100 << (irq - SNI_A20R_IRQ_BASE));
157 irq_disable_hazard();
160 static void end_a20r_irq(unsigned int irq)
162 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
164 unmask_a20r_irq(irq);
168 static struct irq_chip a20r_irq_type = {
170 .ack = mask_a20r_irq,
171 .mask = mask_a20r_irq,
172 .mask_ack = mask_a20r_irq,
173 .unmask = unmask_a20r_irq,
178 * hwint 0 receive all interrupts
180 static void a20r_hwint(void)
185 clear_c0_status (IE_IRQ0);
186 status = a20r_ack_hwint();
187 cause = read_c0_cause();
189 irq = ffs(((cause & status) >> 8) & 0xf8);
191 do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
192 set_c0_status(IE_IRQ0);
195 void __init sni_a20r_irq_init(void)
199 for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
200 set_irq_chip(i, &a20r_irq_type);
201 sni_hwint = a20r_hwint;
202 change_c0_status(ST0_IM, IE_IRQ0);
203 setup_irq (SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
206 void sni_a20r_init(void)
208 ds1216_base = (volatile unsigned char *) SNI_DS1216_A20R_BASE;
209 rtc_mips_get_time = ds1216_get_cmos_time;
212 static int __init snirm_a20r_setup_devinit(void)
214 switch (sni_brd_type) {
215 case SNI_BRD_TOWER_OASIC:
216 case SNI_BRD_MINITOWER:
217 platform_device_register(&snirm_82596_pdev);
218 platform_device_register(&snirm_53c710_pdev);
219 platform_device_register(&sc26xx_pdev);
220 platform_device_register(&a20r_serial8250_device);
227 device_initcall(snirm_a20r_setup_devinit);