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>
17 #include <asm/mc146818-time.h>
20 #include <asm/i8259.h>
21 #include <asm/irq_cpu.h>
23 #define cacheconf (*(volatile unsigned int *)PCIMT_CACHECONF)
24 #define invspace (*(volatile unsigned int *)PCIMT_INVSPACE)
26 static void __init sni_pcimt_sc_init(void)
28 unsigned int scsiz, sc_size;
30 scsiz = cacheconf & 7;
32 printk("Second level cache is deactived.\n");
36 printk("Invalid second level cache size configured, "
37 "deactivating second level cache.\n");
42 sc_size = 128 << scsiz;
43 printk("%dkb second level cache detected, deactivating.\n", sc_size);
49 * A bit more gossip about the iron we're running on ...
51 static inline void sni_pcimt_detect(void)
58 csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
60 p += sprintf(p, "%s PCI", (csmsr & 0x80) ? "RM200" : "RM300");
61 if ((csmsr & 0x80) == 0)
62 p += sprintf(p, ", board revision %s",
63 (csmsr & 0x20) ? "D" : "C");
65 asic = (csmsr & 0x08) ? asic : !asic;
66 p += sprintf(p, ", ASIC PCI Rev %s", asic ? "1.0" : "1.1");
67 printk("%s.\n", boardtype);
70 #define PORT(_base,_irq) \
75 .iotype = UPIO_PORT, \
76 .flags = UPF_BOOT_AUTOCONF, \
79 static struct plat_serial8250_port pcimt_data[] = {
85 static struct platform_device pcimt_serial8250_device = {
87 .id = PLAT8250_DEV_PLATFORM,
89 .platform_data = pcimt_data,
93 static struct resource sni_io_resource = {
94 .start = 0x00000000UL,
96 .name = "PCIMT IO MEM",
97 .flags = IORESOURCE_IO,
100 static struct resource pcimt_io_resources[] = {
105 .flags = IORESOURCE_BUSY
110 .flags = IORESOURCE_BUSY
115 .flags = IORESOURCE_BUSY
119 .name = "dma page reg",
120 .flags = IORESOURCE_BUSY
125 .flags = IORESOURCE_BUSY
129 .name = "PCI config data",
130 .flags = IORESOURCE_BUSY
134 static struct resource pcimt_mem_resources[] = {
137 * this region should only be 4 bytes long,
138 * but it's 16MB on all RM300C I've checked
142 .name = "PCI INT ACK",
143 .flags = IORESOURCE_BUSY
147 static struct resource sni_mem_resource = {
148 .start = 0x18000000UL,
150 .name = "PCIMT PCI MEM",
151 .flags = IORESOURCE_MEM
154 static void __init sni_pcimt_resource_init(void)
158 /* request I/O space for devices used on all i[345]86 PCs */
159 for (i = 0; i < ARRAY_SIZE(pcimt_io_resources); i++)
160 request_resource(&sni_io_resource, pcimt_io_resources + i);
161 /* request MEM space for devices used on all i[345]86 PCs */
162 for (i = 0; i < ARRAY_SIZE(pcimt_mem_resources); i++)
163 request_resource(&sni_mem_resource, pcimt_mem_resources + i);
166 extern struct pci_ops sni_pcimt_ops;
168 static struct pci_controller sni_controller = {
169 .pci_ops = &sni_pcimt_ops,
170 .mem_resource = &sni_mem_resource,
171 .mem_offset = 0x00000000UL,
172 .io_resource = &sni_io_resource,
173 .io_offset = 0x00000000UL,
174 .io_map_base = SNI_PORT_BASE
177 static void enable_pcimt_irq(unsigned int irq)
179 unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2);
181 *(volatile u8 *) PCIMT_IRQSEL |= mask;
184 void disable_pcimt_irq(unsigned int irq)
186 unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2));
188 *(volatile u8 *) PCIMT_IRQSEL &= mask;
191 static void end_pcimt_irq(unsigned int irq)
193 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
194 enable_pcimt_irq(irq);
197 static struct irq_chip pcimt_irq_type = {
199 .ack = disable_pcimt_irq,
200 .mask = disable_pcimt_irq,
201 .mask_ack = disable_pcimt_irq,
202 .unmask = enable_pcimt_irq,
203 .end = end_pcimt_irq,
207 * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
208 * button interrupts. Later ...
210 static void pcimt_hwint0(void)
212 panic("Received int0 but no handler yet ...");
216 * hwint 1 deals with EISA and SCSI interrupts,
218 * The EISA_INT bit in CSITPEND is high active, all others are low active.
220 static void pcimt_hwint1(void)
222 u8 pend = *(volatile char *)PCIMT_CSITPEND;
225 if (pend & IT_EISA) {
228 * Note: ASIC PCI's builtin interrupt achknowledge feature is
229 * broken. Using it may result in loss of some or all i8259
230 * interupts, so don't use PCIMT_INT_ACKNOWLEDGE ...
233 if (unlikely(irq < 0))
239 if (!(pend & IT_SCSI)) {
240 flags = read_c0_status();
241 clear_c0_status(ST0_IM);
242 do_IRQ(PCIMT_IRQ_SCSI);
243 write_c0_status(flags);
248 * hwint 3 should deal with the PCI A - D interrupts,
250 static void pcimt_hwint3(void)
252 u8 pend = *(volatile char *)PCIMT_CSITPEND;
255 pend &= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
256 pend ^= (IT_INTA | IT_INTB | IT_INTC | IT_INTD);
257 clear_c0_status(IE_IRQ3);
258 irq = PCIMT_IRQ_INT2 + ffs(pend) - 1;
260 set_c0_status(IE_IRQ3);
263 static void sni_pcimt_hwint(void)
265 u32 pending = read_c0_cause() & read_c0_status();
267 if (pending & C_IRQ5)
268 do_IRQ (MIPS_CPU_IRQ_BASE + 7);
269 else if (pending & C_IRQ4)
270 do_IRQ (MIPS_CPU_IRQ_BASE + 6);
271 else if (pending & C_IRQ3)
273 else if (pending & C_IRQ1)
275 else if (pending & C_IRQ0) {
280 void __init sni_pcimt_irq_init(void)
284 *(volatile u8 *) PCIMT_IRQSEL = IT_ETH | IT_EISA;
286 /* Actually we've got more interrupts to handle ... */
287 for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_SCSI; i++)
288 set_irq_chip(i, &pcimt_irq_type);
289 sni_hwint = sni_pcimt_hwint;
290 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ3);
293 void sni_pcimt_init(void)
297 rtc_mips_get_time = mc146818_get_cmos_time;
298 rtc_mips_set_time = mc146818_set_rtc_mmss;
299 board_time_init = sni_cpu_time_init;
300 ioport_resource.end = sni_io_resource.end;
302 PCIBIOS_MIN_IO = 0x9000;
303 register_pci_controller(&sni_controller);
305 sni_pcimt_resource_init();
308 static int __init snirm_pcimt_setup_devinit(void)
310 switch (sni_brd_type) {
311 case SNI_BRD_PCI_MTOWER:
312 case SNI_BRD_PCI_DESKTOP:
313 case SNI_BRD_PCI_MTOWER_CPLUS:
314 platform_device_register(&pcimt_serial8250_device);
321 device_initcall(snirm_pcimt_setup_devinit);