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/pci.h>
14 #include <linux/serial_8250.h>
16 #include <asm/mc146818-time.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 sni_io_resource = {
62 .start = 0x00000000UL,
65 .flags = IORESOURCE_IO,
68 static struct resource pcit_io_resources[] = {
73 .flags = IORESOURCE_BUSY
78 .flags = IORESOURCE_BUSY
83 .flags = IORESOURCE_BUSY
87 .name = "dma page reg",
88 .flags = IORESOURCE_BUSY
93 .flags = IORESOURCE_BUSY
97 .name = "PCI config addr",
98 .flags = IORESOURCE_BUSY
102 .name = "PCI config data",
103 .flags = IORESOURCE_BUSY
107 static struct resource sni_mem_resource = {
108 .start = 0x18000000UL,
110 .name = "PCIT PCI MEM",
111 .flags = IORESOURCE_MEM
114 static void __init sni_pcit_resource_init(void)
118 /* request I/O space for devices used on all i[345]86 PCs */
119 for (i = 0; i < ARRAY_SIZE(pcit_io_resources); i++)
120 request_resource(&sni_io_resource, pcit_io_resources + i);
124 extern struct pci_ops sni_pcit_ops;
126 static struct pci_controller sni_pcit_controller = {
127 .pci_ops = &sni_pcit_ops,
128 .mem_resource = &sni_mem_resource,
129 .mem_offset = 0x00000000UL,
130 .io_resource = &sni_io_resource,
131 .io_offset = 0x00000000UL,
132 .io_map_base = SNI_PORT_BASE
135 static void enable_pcit_irq(unsigned int irq)
137 u32 mask = 1 << (irq - SNI_PCIT_INT_START + 24);
139 *(volatile u32 *)SNI_PCIT_INT_REG |= mask;
142 void disable_pcit_irq(unsigned int irq)
144 u32 mask = 1 << (irq - SNI_PCIT_INT_START + 24);
146 *(volatile u32 *)SNI_PCIT_INT_REG &= ~mask;
149 void end_pcit_irq(unsigned int irq)
151 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
152 enable_pcit_irq(irq);
155 static struct irq_chip pcit_irq_type = {
157 .ack = disable_pcit_irq,
158 .mask = disable_pcit_irq,
159 .mask_ack = disable_pcit_irq,
160 .unmask = enable_pcit_irq,
164 static void pcit_hwint1(void)
166 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
169 clear_c0_status(IE_IRQ1);
170 irq = ffs((pending >> 16) & 0x7f);
173 do_IRQ (irq + SNI_PCIT_INT_START - 1);
174 set_c0_status (IE_IRQ1);
177 static void pcit_hwint0(void)
179 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
182 clear_c0_status(IE_IRQ0);
183 irq = ffs((pending >> 16) & 0x3f);
186 do_IRQ (irq + SNI_PCIT_INT_START - 1);
187 set_c0_status (IE_IRQ0);
190 static void sni_pcit_hwint(void)
192 u32 pending = read_c0_cause() & read_c0_status();
194 if (pending & C_IRQ1)
196 else if (pending & C_IRQ2)
197 do_IRQ (MIPS_CPU_IRQ_BASE + 4);
198 else if (pending & C_IRQ3)
199 do_IRQ (MIPS_CPU_IRQ_BASE + 5);
200 else if (pending & C_IRQ5)
201 do_IRQ (MIPS_CPU_IRQ_BASE + 7);
204 static void sni_pcit_hwint_cplus(void)
206 u32 pending = read_c0_cause() & read_c0_status();
208 if (pending & C_IRQ0)
210 else if (pending & C_IRQ1)
211 do_IRQ (MIPS_CPU_IRQ_BASE + 3);
212 else if (pending & C_IRQ2)
213 do_IRQ (MIPS_CPU_IRQ_BASE + 4);
214 else if (pending & C_IRQ3)
215 do_IRQ (MIPS_CPU_IRQ_BASE + 5);
216 else if (pending & C_IRQ5)
217 do_IRQ (MIPS_CPU_IRQ_BASE + 7);
220 void __init sni_pcit_irq_init(void)
225 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
226 set_irq_chip(i, &pcit_irq_type);
227 *(volatile u32 *)SNI_PCIT_INT_REG = 0;
228 sni_hwint = sni_pcit_hwint;
229 change_c0_status(ST0_IM, IE_IRQ1);
230 setup_irq (SNI_PCIT_INT_START + 6, &sni_isa_irq);
233 void __init sni_pcit_cplus_irq_init(void)
238 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
239 set_irq_chip(i, &pcit_irq_type);
240 *(volatile u32 *)SNI_PCIT_INT_REG = 0x40000000;
241 sni_hwint = sni_pcit_hwint_cplus;
242 change_c0_status(ST0_IM, IE_IRQ0);
243 setup_irq (MIPS_CPU_IRQ_BASE + 3, &sni_isa_irq);
246 void sni_pcit_init(void)
248 rtc_mips_get_time = mc146818_get_cmos_time;
249 rtc_mips_set_time = mc146818_set_rtc_mmss;
250 board_time_init = sni_cpu_time_init;
251 ioport_resource.end = sni_io_resource.end;
253 PCIBIOS_MIN_IO = 0x9000;
254 register_pci_controller(&sni_pcit_controller);
256 sni_pcit_resource_init();
259 static int __init snirm_pcit_setup_devinit(void)
261 switch (sni_brd_type) {
262 case SNI_BRD_PCI_TOWER:
263 platform_device_register(&pcit_serial8250_device);
266 case SNI_BRD_PCI_TOWER_CPLUS:
267 platform_device_register(&pcit_cplus_serial8250_device);
273 device_initcall(snirm_pcit_setup_devinit);