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 = 0x00001000UL,
64 .name = "PCIT IO MEM",
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 data",
98 .flags = IORESOURCE_BUSY
102 static struct resource sni_mem_resource = {
103 .start = 0x10000000UL,
105 .name = "PCIT PCI MEM",
106 .flags = IORESOURCE_MEM
110 * The RM200/RM300 has a few holes in it's PCI/EISA memory address space used
111 * for other purposes. Be paranoid and allocate all of the before the PCI
112 * code gets a chance to to map anything else there ...
114 * This leaves the following areas available:
116 * 0x10000000 - 0x1009ffff (640kB) PCI/EISA/ISA Bus Memory
117 * 0x10100000 - 0x13ffffff ( 15MB) PCI/EISA/ISA Bus Memory
118 * 0x18000000 - 0x1fbfffff (124MB) PCI/EISA Bus Memory
119 * 0x1ff08000 - 0x1ffeffff (816kB) PCI/EISA Bus Memory
120 * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory
122 static struct resource pcit_mem_resources[] = {
127 .flags = IORESOURCE_BUSY
131 .name = "Cache Replacement Area",
132 .flags = IORESOURCE_BUSY
136 .name = "Video RAM area",
137 .flags = IORESOURCE_BUSY
141 .name = "ISA Reserved",
142 .flags = IORESOURCE_BUSY
147 .flags = IORESOURCE_BUSY
152 .flags = IORESOURCE_BUSY
157 .flags = IORESOURCE_BUSY
162 .flags = IORESOURCE_BUSY
167 .flags = IORESOURCE_BUSY
171 .name = "NVRAM / EEPROM",
172 .flags = IORESOURCE_BUSY
177 .flags = IORESOURCE_BUSY
182 .flags = IORESOURCE_BUSY
186 .name = "Main Memory",
187 .flags = IORESOURCE_BUSY
191 static void __init sni_pcit_resource_init(void)
195 /* request I/O space for devices used on all i[345]86 PCs */
196 for (i = 0; i < ARRAY_SIZE(pcit_io_resources); i++)
197 request_resource(&ioport_resource, pcit_io_resources + i);
199 /* request mem space for pcimt-specific devices */
200 for (i = 0; i < ARRAY_SIZE(pcit_mem_resources); i++)
201 request_resource(&sni_mem_resource, pcit_mem_resources + i);
203 ioport_resource.end = sni_io_resource.end;
207 extern struct pci_ops sni_pcit_ops;
209 static struct pci_controller sni_pcit_controller = {
210 .pci_ops = &sni_pcit_ops,
211 .mem_resource = &sni_mem_resource,
212 .mem_offset = 0x10000000UL,
213 .io_resource = &sni_io_resource,
214 .io_offset = 0x00000000UL
217 static void enable_pcit_irq(unsigned int irq)
219 u32 mask = 1 << (irq - SNI_PCIT_INT_START + 24);
221 *(volatile u32 *)SNI_PCIT_INT_REG |= mask;
224 void disable_pcit_irq(unsigned int irq)
226 u32 mask = 1 << (irq - SNI_PCIT_INT_START + 24);
228 *(volatile u32 *)SNI_PCIT_INT_REG &= ~mask;
231 void end_pcit_irq(unsigned int irq)
233 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
234 enable_pcit_irq(irq);
237 static struct irq_chip pcit_irq_type = {
239 .ack = disable_pcit_irq,
240 .mask = disable_pcit_irq,
241 .mask_ack = disable_pcit_irq,
242 .unmask = enable_pcit_irq,
246 static void pcit_hwint1(void)
248 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
251 clear_c0_status(IE_IRQ1);
252 irq = ffs((pending >> 16) & 0x7f);
255 do_IRQ (irq + SNI_PCIT_INT_START - 1);
256 set_c0_status (IE_IRQ1);
259 static void pcit_hwint0(void)
261 u32 pending = *(volatile u32 *)SNI_PCIT_INT_REG;
264 clear_c0_status(IE_IRQ0);
265 irq = ffs((pending >> 16) & 0x7f);
268 do_IRQ (irq + SNI_PCIT_INT_START - 1);
269 set_c0_status (IE_IRQ0);
272 static void sni_pcit_hwint(void)
274 u32 pending = (read_c0_cause() & read_c0_status());
276 if (pending & C_IRQ1)
278 else if (pending & C_IRQ2)
279 do_IRQ (MIPS_CPU_IRQ_BASE + 4);
280 else if (pending & C_IRQ3)
281 do_IRQ (MIPS_CPU_IRQ_BASE + 5);
282 else if (pending & C_IRQ5)
283 do_IRQ (MIPS_CPU_IRQ_BASE + 7);
286 static void sni_pcit_hwint_cplus(void)
288 u32 pending = (read_c0_cause() & read_c0_status());
290 if (pending & C_IRQ0)
292 else if (pending & C_IRQ2)
293 do_IRQ (MIPS_CPU_IRQ_BASE + 4);
294 else if (pending & C_IRQ3)
295 do_IRQ (MIPS_CPU_IRQ_BASE + 5);
296 else if (pending & C_IRQ5)
297 do_IRQ (MIPS_CPU_IRQ_BASE + 7);
300 void __init sni_pcit_irq_init(void)
305 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
306 set_irq_chip(i, &pcit_irq_type);
307 *(volatile u32 *)SNI_PCIT_INT_REG = 0;
308 sni_hwint = sni_pcit_hwint;
309 change_c0_status(ST0_IM, IE_IRQ1);
310 setup_irq (SNI_PCIT_INT_START + 6, &sni_isa_irq);
313 void __init sni_pcit_cplus_irq_init(void)
318 for (i = SNI_PCIT_INT_START; i <= SNI_PCIT_INT_END; i++)
319 set_irq_chip(i, &pcit_irq_type);
320 *(volatile u32 *)SNI_PCIT_INT_REG = 0;
321 sni_hwint = sni_pcit_hwint_cplus;
322 change_c0_status(ST0_IM, IE_IRQ0);
323 setup_irq (SNI_PCIT_INT_START + 6, &sni_isa_irq);
326 void sni_pcit_init(void)
328 sni_pcit_resource_init();
329 rtc_mips_get_time = mc146818_get_cmos_time;
330 rtc_mips_set_time = mc146818_set_rtc_mmss;
331 board_time_init = sni_cpu_time_init;
333 register_pci_controller(&sni_pcit_controller);
337 static int __init snirm_pcit_setup_devinit(void)
339 switch (sni_brd_type) {
340 case SNI_BRD_PCI_TOWER:
341 platform_device_register(&pcit_serial8250_device);
344 case SNI_BRD_PCI_TOWER_CPLUS:
345 platform_device_register(&pcit_cplus_serial8250_device);
351 device_initcall(snirm_pcit_setup_devinit);