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) 1996, 97, 98, 2000, 03, 04, 06 Ralf Baechle (ralf@linux-mips.org)
9 * Copyright (C) 2006,2007 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/pci.h>
15 #include <linux/serial_8250.h>
19 #include <asm/i8259.h>
20 #include <asm/irq_cpu.h>
22 #define cacheconf (*(volatile unsigned int *)PCIMT_CACHECONF)
23 #define invspace (*(volatile unsigned int *)PCIMT_INVSPACE)
25 static void __init sni_pcimt_sc_init(void)
27 unsigned int scsiz, sc_size;
29 scsiz = cacheconf & 7;
31 printk("Second level cache is deactived.\n");
35 printk("Invalid second level cache size configured, "
36 "deactivating second level cache.\n");
41 sc_size = 128 << scsiz;
42 printk("%dkb second level cache detected, deactivating.\n", sc_size);
48 * A bit more gossip about the iron we're running on ...
50 static inline void sni_pcimt_detect(void)
57 csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
59 p += sprintf(p, "%s PCI", (csmsr & 0x80) ? "RM200" : "RM300");
60 if ((csmsr & 0x80) == 0)
61 p += sprintf(p, ", board revision %s",
62 (csmsr & 0x20) ? "D" : "C");
64 asic = (csmsr & 0x08) ? asic : !asic;
65 p += sprintf(p, ", ASIC PCI Rev %s", asic ? "1.0" : "1.1");
66 printk("%s.\n", boardtype);
69 #define PORT(_base,_irq) \
74 .iotype = UPIO_PORT, \
75 .flags = UPF_BOOT_AUTOCONF, \
78 static struct plat_serial8250_port pcimt_data[] = {
84 static struct platform_device pcimt_serial8250_device = {
86 .id = PLAT8250_DEV_PLATFORM,
88 .platform_data = pcimt_data,
92 static struct resource pcimt_cmos_rsrc[] = {
96 .flags = IORESOURCE_IO
101 .flags = IORESOURCE_IRQ
105 static struct platform_device pcimt_cmos_device = {
107 .num_resources = ARRAY_SIZE(pcimt_cmos_rsrc),
108 .resource = pcimt_cmos_rsrc
112 static struct resource sni_io_resource = {
113 .start = 0x00000000UL,
115 .name = "PCIMT IO MEM",
116 .flags = IORESOURCE_IO,
119 static struct resource pcimt_io_resources[] = {
124 .flags = IORESOURCE_BUSY
129 .flags = IORESOURCE_BUSY
134 .flags = IORESOURCE_BUSY
138 .name = "dma page reg",
139 .flags = IORESOURCE_BUSY
144 .flags = IORESOURCE_BUSY
148 .name = "PCI config data",
149 .flags = IORESOURCE_BUSY
153 static struct resource pcimt_mem_resources[] = {
156 * this region should only be 4 bytes long,
157 * but it's 16MB on all RM300C I've checked
161 .name = "PCI INT ACK",
162 .flags = IORESOURCE_BUSY
166 static struct resource sni_mem_resource = {
167 .start = 0x18000000UL,
169 .name = "PCIMT PCI MEM",
170 .flags = IORESOURCE_MEM
173 static void __init sni_pcimt_resource_init(void)
177 /* request I/O space for devices used on all i[345]86 PCs */
178 for (i = 0; i < ARRAY_SIZE(pcimt_io_resources); i++)
179 request_resource(&sni_io_resource, pcimt_io_resources + i);
180 /* request MEM space for devices used on all i[345]86 PCs */
181 for (i = 0; i < ARRAY_SIZE(pcimt_mem_resources); i++)
182 request_resource(&sni_mem_resource, pcimt_mem_resources + i);
185 extern struct pci_ops sni_pcimt_ops;
187 static struct pci_controller sni_controller = {
188 .pci_ops = &sni_pcimt_ops,
189 .mem_resource = &sni_mem_resource,
190 .mem_offset = 0x00000000UL,
191 .io_resource = &sni_io_resource,
192 .io_offset = 0x00000000UL,
193 .io_map_base = SNI_PORT_BASE
196 static void enable_pcimt_irq(unsigned int irq)
198 unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2);
200 *(volatile u8 *) PCIMT_IRQSEL |= mask;
203 void disable_pcimt_irq(unsigned int irq)
205 unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2));
207 *(volatile u8 *) PCIMT_IRQSEL &= mask;
210 static void end_pcimt_irq(unsigned int irq)
212 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
213 enable_pcimt_irq(irq);
216 static struct irq_chip pcimt_irq_type = {
218 .ack = disable_pcimt_irq,
219 .mask = disable_pcimt_irq,
220 .mask_ack = disable_pcimt_irq,
221 .unmask = enable_pcimt_irq,
222 .end = end_pcimt_irq,
226 * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
227 * button interrupts. Later ...
229 static void pcimt_hwint0(void)
231 panic("Received int0 but no handler yet ...");
235 * hwint 1 deals with EISA and SCSI interrupts,
237 * The EISA_INT bit in CSITPEND is high active, all others are low active.
239 static void pcimt_hwint1(void)
241 u8 pend = *(volatile char *)PCIMT_CSITPEND;
244 if (pend & IT_EISA) {
247 * Note: ASIC PCI's builtin interrupt acknowledge feature is
248 * broken. Using it may result in loss of some or all i8259
249 * interrupts, so don't use PCIMT_INT_ACKNOWLEDGE ...
252 if (unlikely(irq < 0))
258 if (!(pend & IT_SCSI)) {
259 flags = read_c0_status();
260 clear_c0_status(ST0_IM);
261 do_IRQ(PCIMT_IRQ_SCSI);
262 write_c0_status(flags);
267 * hwint 3 should deal with the PCI A - D interrupts,
269 static void pcimt_hwint3(void)
271 u8 pend = *(volatile char *)PCIMT_CSITPEND;
274 pend &= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
275 pend ^= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
276 clear_c0_status(IE_IRQ3);
277 irq = PCIMT_IRQ_INT2 + ffs(pend) - 1;
279 set_c0_status(IE_IRQ3);
282 static void sni_pcimt_hwint(void)
284 u32 pending = read_c0_cause() & read_c0_status();
286 if (pending & C_IRQ5)
287 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
288 else if (pending & C_IRQ4)
289 do_IRQ(MIPS_CPU_IRQ_BASE + 6);
290 else if (pending & C_IRQ3)
292 else if (pending & C_IRQ1)
294 else if (pending & C_IRQ0) {
299 void __init sni_pcimt_irq_init(void)
303 *(volatile u8 *) PCIMT_IRQSEL = IT_ETH | IT_EISA;
305 /* Actually we've got more interrupts to handle ... */
306 for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_SCSI; i++)
307 set_irq_chip_and_handler(i, &pcimt_irq_type, handle_level_irq);
308 sni_hwint = sni_pcimt_hwint;
309 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ3);
312 void __init sni_pcimt_init(void)
316 ioport_resource.end = sni_io_resource.end;
318 PCIBIOS_MIN_IO = 0x9000;
319 register_pci_controller(&sni_controller);
321 sni_pcimt_resource_init();
324 static int __init snirm_pcimt_setup_devinit(void)
326 switch (sni_brd_type) {
327 case SNI_BRD_PCI_MTOWER:
328 case SNI_BRD_PCI_DESKTOP:
329 case SNI_BRD_PCI_MTOWER_CPLUS:
330 platform_device_register(&pcimt_serial8250_device);
331 platform_device_register(&pcimt_cmos_device);
338 device_initcall(snirm_pcimt_setup_devinit);