2 * PCI Tower specific code
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/pci.h>
15 #include <linux/serial_8250.h>
19 #include <asm/irq_cpu.h>
22 #define PORT(_base,_irq) \
27 .iotype = UPIO_PORT, \
28 .flags = UPF_BOOT_AUTOCONF, \
31 static struct plat_serial8250_port pcit_data[] = {
37 static struct platform_device pcit_serial8250_device = {
39 .id = PLAT8250_DEV_PLATFORM,
41 .platform_data = pcit_data,
45 static struct plat_serial8250_port pcit_cplus_data[] = {
53 static struct platform_device pcit_cplus_serial8250_device = {
55 .id = PLAT8250_DEV_PLATFORM,
57 .platform_data = pcit_cplus_data,
61 static struct resource pcit_cmos_rsrc[] = {
65 .flags = IORESOURCE_IO
70 .flags = IORESOURCE_IRQ
74 static struct platform_device pcit_cmos_device = {
76 .num_resources = ARRAY_SIZE(pcit_cmos_rsrc),
77 .resource = pcit_cmos_rsrc
80 static struct platform_device pcit_pcspeaker_pdev = {
85 static struct resource sni_io_resource = {
86 .start = 0x00000000UL,
89 .flags = IORESOURCE_IO,
92 static struct resource pcit_io_resources[] = {
97 .flags = IORESOURCE_BUSY
102 .flags = IORESOURCE_BUSY
107 .flags = IORESOURCE_BUSY
111 .name = "dma page reg",
112 .flags = IORESOURCE_BUSY
117 .flags = IORESOURCE_BUSY
121 .name = "PCI config addr",
122 .flags = IORESOURCE_BUSY
126 .name = "PCI config data",
127 .flags = IORESOURCE_BUSY
131 static void __init sni_pcit_resource_init(void)
135 /* request I/O space for devices used on all i[345]86 PCs */
136 for (i = 0; i < ARRAY_SIZE(pcit_io_resources); i++)
137 request_resource(&sni_io_resource, pcit_io_resources + i);
141 extern struct pci_ops sni_pcit_ops;
144 static struct resource sni_mem_resource = {
145 .start = 0x18000000UL,
147 .name = "PCIT PCI MEM",
148 .flags = IORESOURCE_MEM
151 static struct pci_controller sni_pcit_controller = {
152 .pci_ops = &sni_pcit_ops,
153 .mem_resource = &sni_mem_resource,
154 .mem_offset = 0x00000000UL,
155 .io_resource = &sni_io_resource,
156 .io_offset = 0x00000000UL,
157 .io_map_base = SNI_PORT_BASE
159 #endif /* CONFIG_PCI */
161 static void enable_pcit_irq(struct irq_data *d)
163 u32 mask = 1 << (d->irq - SNI_PCIT_INT_START + 24);
165 *(volatile u32 *)SNI_PCIT_INT_REG |= mask;
168 void disable_pcit_irq(struct irq_data *d)
170 u32 mask = 1 << (d->irq - SNI_PCIT_INT_START + 24);
172 *(volatile u32 *)SNI_PCIT_INT_REG &= ~mask;
175 static struct irq_chip pcit_irq_type = {
177 .irq_mask = disable_pcit_irq,
178 .irq_unmask = enable_pcit_irq,
181 static void pcit_hwint1(void)
183 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
186 clear_c0_status(IE_IRQ1);
187 irq = ffs((pending >> 16) & 0x7f);
190 do_IRQ(irq + SNI_PCIT_INT_START - 1);
191 set_c0_status(IE_IRQ1);
194 static void pcit_hwint0(void)
196 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
199 clear_c0_status(IE_IRQ0);
200 irq = ffs((pending >> 16) & 0x3f);
203 do_IRQ(irq + SNI_PCIT_INT_START - 1);
204 set_c0_status(IE_IRQ0);
207 static void sni_pcit_hwint(void)
209 u32 pending = read_c0_cause() & read_c0_status();
211 if (pending & C_IRQ1)
213 else if (pending & C_IRQ2)
214 do_IRQ(MIPS_CPU_IRQ_BASE + 4);
215 else if (pending & C_IRQ3)
216 do_IRQ(MIPS_CPU_IRQ_BASE + 5);
217 else if (pending & C_IRQ5)
218 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
221 static void sni_pcit_hwint_cplus(void)
223 u32 pending = read_c0_cause() & read_c0_status();
225 if (pending & C_IRQ0)
227 else if (pending & C_IRQ1)
228 do_IRQ(MIPS_CPU_IRQ_BASE + 3);
229 else if (pending & C_IRQ2)
230 do_IRQ(MIPS_CPU_IRQ_BASE + 4);
231 else if (pending & C_IRQ3)
232 do_IRQ(MIPS_CPU_IRQ_BASE + 5);
233 else if (pending & C_IRQ5)
234 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
237 void __init sni_pcit_irq_init(void)
242 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
243 irq_set_chip_and_handler(i, &pcit_irq_type, handle_level_irq);
244 *(volatile u32 *)SNI_PCIT_INT_REG = 0;
245 sni_hwint = sni_pcit_hwint;
246 change_c0_status(ST0_IM, IE_IRQ1);
247 if (request_irq(SNI_PCIT_INT_START + 6, sni_isa_irq_handler, 0, "ISA",
249 pr_err("Failed to register ISA interrupt\n");
252 void __init sni_pcit_cplus_irq_init(void)
257 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
258 irq_set_chip_and_handler(i, &pcit_irq_type, handle_level_irq);
259 *(volatile u32 *)SNI_PCIT_INT_REG = 0x40000000;
260 sni_hwint = sni_pcit_hwint_cplus;
261 change_c0_status(ST0_IM, IE_IRQ0);
262 if (request_irq(MIPS_CPU_IRQ_BASE + 3, sni_isa_irq_handler, 0, "ISA",
264 pr_err("Failed to register ISA interrupt\n");
267 void __init sni_pcit_init(void)
269 ioport_resource.end = sni_io_resource.end;
271 PCIBIOS_MIN_IO = 0x9000;
272 register_pci_controller(&sni_pcit_controller);
274 sni_pcit_resource_init();
277 static int __init snirm_pcit_setup_devinit(void)
279 switch (sni_brd_type) {
280 case SNI_BRD_PCI_TOWER:
281 platform_device_register(&pcit_serial8250_device);
282 platform_device_register(&pcit_cmos_device);
283 platform_device_register(&pcit_pcspeaker_pdev);
286 case SNI_BRD_PCI_TOWER_CPLUS:
287 platform_device_register(&pcit_cplus_serial8250_device);
288 platform_device_register(&pcit_cmos_device);
289 platform_device_register(&pcit_pcspeaker_pdev);
295 device_initcall(snirm_pcit_setup_devinit);