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/irq.h>
15 #include <linux/pci.h>
16 #include <linux/serial_8250.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 deactivated.\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 pcimt_cmos_rsrc
[] = {
97 .flags
= IORESOURCE_IO
102 .flags
= IORESOURCE_IRQ
106 static struct platform_device pcimt_cmos_device
= {
108 .num_resources
= ARRAY_SIZE(pcimt_cmos_rsrc
),
109 .resource
= pcimt_cmos_rsrc
113 static struct resource sni_io_resource
= {
114 .start
= 0x00000000UL
,
116 .name
= "PCIMT IO MEM",
117 .flags
= IORESOURCE_IO
,
120 static struct resource pcimt_io_resources
[] = {
125 .flags
= IORESOURCE_BUSY
130 .flags
= IORESOURCE_BUSY
135 .flags
= IORESOURCE_BUSY
139 .name
= "dma page reg",
140 .flags
= IORESOURCE_BUSY
145 .flags
= IORESOURCE_BUSY
149 .name
= "PCI config data",
150 .flags
= IORESOURCE_BUSY
154 static struct resource pcimt_mem_resources
[] = {
157 * this region should only be 4 bytes long,
158 * but it's 16MB on all RM300C I've checked
162 .name
= "PCI INT ACK",
163 .flags
= IORESOURCE_BUSY
167 static struct resource sni_mem_resource
= {
168 .start
= 0x18000000UL
,
170 .name
= "PCIMT PCI MEM",
171 .flags
= IORESOURCE_MEM
174 static void __init
sni_pcimt_resource_init(void)
178 /* request I/O space for devices used on all i[345]86 PCs */
179 for (i
= 0; i
< ARRAY_SIZE(pcimt_io_resources
); i
++)
180 request_resource(&sni_io_resource
, pcimt_io_resources
+ i
);
181 /* request MEM space for devices used on all i[345]86 PCs */
182 for (i
= 0; i
< ARRAY_SIZE(pcimt_mem_resources
); i
++)
183 request_resource(&sni_mem_resource
, pcimt_mem_resources
+ i
);
186 extern struct pci_ops sni_pcimt_ops
;
189 static struct pci_controller sni_controller
= {
190 .pci_ops
= &sni_pcimt_ops
,
191 .mem_resource
= &sni_mem_resource
,
192 .mem_offset
= 0x00000000UL
,
193 .io_resource
= &sni_io_resource
,
194 .io_offset
= 0x00000000UL
,
195 .io_map_base
= SNI_PORT_BASE
199 static void enable_pcimt_irq(struct irq_data
*d
)
201 unsigned int mask
= 1 << (d
->irq
- PCIMT_IRQ_INT2
);
203 *(volatile u8
*) PCIMT_IRQSEL
|= mask
;
206 void disable_pcimt_irq(struct irq_data
*d
)
208 unsigned int mask
= ~(1 << (d
->irq
- PCIMT_IRQ_INT2
));
210 *(volatile u8
*) PCIMT_IRQSEL
&= mask
;
213 static struct irq_chip pcimt_irq_type
= {
215 .irq_mask
= disable_pcimt_irq
,
216 .irq_unmask
= enable_pcimt_irq
,
220 * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
221 * button interrupts. Later ...
223 static void pcimt_hwint0(void)
225 panic("Received int0 but no handler yet ...");
229 * hwint 1 deals with EISA and SCSI interrupts,
231 * The EISA_INT bit in CSITPEND is high active, all others are low active.
233 static void pcimt_hwint1(void)
235 u8 pend
= *(volatile char *)PCIMT_CSITPEND
;
238 if (pend
& IT_EISA
) {
241 * Note: ASIC PCI's builtin interrupt acknowledge feature is
242 * broken. Using it may result in loss of some or all i8259
243 * interrupts, so don't use PCIMT_INT_ACKNOWLEDGE ...
246 if (unlikely(irq
< 0))
252 if (!(pend
& IT_SCSI
)) {
253 flags
= read_c0_status();
254 clear_c0_status(ST0_IM
);
255 do_IRQ(PCIMT_IRQ_SCSI
);
256 write_c0_status(flags
);
261 * hwint 3 should deal with the PCI A - D interrupts,
263 static void pcimt_hwint3(void)
265 u8 pend
= *(volatile char *)PCIMT_CSITPEND
;
268 pend
&= (IT_INTA
| IT_INTB
| IT_INTC
| IT_INTD
);
269 pend
^= (IT_INTA
| IT_INTB
| IT_INTC
| IT_INTD
);
270 clear_c0_status(IE_IRQ3
);
271 irq
= PCIMT_IRQ_INT2
+ ffs(pend
) - 1;
273 set_c0_status(IE_IRQ3
);
276 static void sni_pcimt_hwint(void)
278 u32 pending
= read_c0_cause() & read_c0_status();
280 if (pending
& C_IRQ5
)
281 do_IRQ(MIPS_CPU_IRQ_BASE
+ 7);
282 else if (pending
& C_IRQ4
)
283 do_IRQ(MIPS_CPU_IRQ_BASE
+ 6);
284 else if (pending
& C_IRQ3
)
286 else if (pending
& C_IRQ1
)
288 else if (pending
& C_IRQ0
) {
293 void __init
sni_pcimt_irq_init(void)
297 *(volatile u8
*) PCIMT_IRQSEL
= IT_ETH
| IT_EISA
;
299 /* Actually we've got more interrupts to handle ... */
300 for (i
= PCIMT_IRQ_INT2
; i
<= PCIMT_IRQ_SCSI
; i
++)
301 irq_set_chip_and_handler(i
, &pcimt_irq_type
, handle_level_irq
);
302 sni_hwint
= sni_pcimt_hwint
;
303 change_c0_status(ST0_IM
, IE_IRQ1
|IE_IRQ3
);
306 void __init
sni_pcimt_init(void)
310 ioport_resource
.end
= sni_io_resource
.end
;
312 PCIBIOS_MIN_IO
= 0x9000;
313 register_pci_controller(&sni_controller
);
315 sni_pcimt_resource_init();
318 static int __init
snirm_pcimt_setup_devinit(void)
320 switch (sni_brd_type
) {
321 case SNI_BRD_PCI_MTOWER
:
322 case SNI_BRD_PCI_DESKTOP
:
323 case SNI_BRD_PCI_MTOWER_CPLUS
:
324 platform_device_register(&pcimt_serial8250_device
);
325 platform_device_register(&pcimt_cmos_device
);
332 device_initcall(snirm_pcimt_setup_devinit
);