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>
18 #include <asm/irq_cpu.h>
21 #define PORT(_base,_irq) \
26 .iotype = UPIO_PORT, \
27 .flags = UPF_BOOT_AUTOCONF, \
30 static struct plat_serial8250_port pcit_data
[] = {
36 static struct platform_device pcit_serial8250_device
= {
38 .id
= PLAT8250_DEV_PLATFORM
,
40 .platform_data
= pcit_data
,
44 static struct plat_serial8250_port pcit_cplus_data
[] = {
52 static struct platform_device pcit_cplus_serial8250_device
= {
54 .id
= PLAT8250_DEV_PLATFORM
,
56 .platform_data
= pcit_cplus_data
,
60 static struct resource pcit_cmos_rsrc
[] = {
64 .flags
= IORESOURCE_IO
69 .flags
= IORESOURCE_IRQ
73 static struct platform_device pcit_cmos_device
= {
75 .num_resources
= ARRAY_SIZE(pcit_cmos_rsrc
),
76 .resource
= pcit_cmos_rsrc
79 static struct resource sni_io_resource
= {
80 .start
= 0x00000000UL
,
83 .flags
= IORESOURCE_IO
,
86 static struct resource pcit_io_resources
[] = {
91 .flags
= IORESOURCE_BUSY
96 .flags
= IORESOURCE_BUSY
101 .flags
= IORESOURCE_BUSY
105 .name
= "dma page reg",
106 .flags
= IORESOURCE_BUSY
111 .flags
= IORESOURCE_BUSY
115 .name
= "PCI config addr",
116 .flags
= IORESOURCE_BUSY
120 .name
= "PCI config data",
121 .flags
= IORESOURCE_BUSY
125 static struct resource sni_mem_resource
= {
126 .start
= 0x18000000UL
,
128 .name
= "PCIT PCI MEM",
129 .flags
= IORESOURCE_MEM
132 static void __init
sni_pcit_resource_init(void)
136 /* request I/O space for devices used on all i[345]86 PCs */
137 for (i
= 0; i
< ARRAY_SIZE(pcit_io_resources
); i
++)
138 request_resource(&sni_io_resource
, pcit_io_resources
+ i
);
142 extern struct pci_ops sni_pcit_ops
;
144 static struct pci_controller sni_pcit_controller
= {
145 .pci_ops
= &sni_pcit_ops
,
146 .mem_resource
= &sni_mem_resource
,
147 .mem_offset
= 0x00000000UL
,
148 .io_resource
= &sni_io_resource
,
149 .io_offset
= 0x00000000UL
,
150 .io_map_base
= SNI_PORT_BASE
153 static void enable_pcit_irq(unsigned int irq
)
155 u32 mask
= 1 << (irq
- SNI_PCIT_INT_START
+ 24);
157 *(volatile u32
*)SNI_PCIT_INT_REG
|= mask
;
160 void disable_pcit_irq(unsigned int irq
)
162 u32 mask
= 1 << (irq
- SNI_PCIT_INT_START
+ 24);
164 *(volatile u32
*)SNI_PCIT_INT_REG
&= ~mask
;
167 void end_pcit_irq(unsigned int irq
)
169 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
|IRQ_INPROGRESS
)))
170 enable_pcit_irq(irq
);
173 static struct irq_chip pcit_irq_type
= {
175 .ack
= disable_pcit_irq
,
176 .mask
= disable_pcit_irq
,
177 .mask_ack
= disable_pcit_irq
,
178 .unmask
= enable_pcit_irq
,
182 static void pcit_hwint1(void)
184 u32 pending
= *(volatile u32
*)SNI_PCIT_INT_REG
;
187 clear_c0_status(IE_IRQ1
);
188 irq
= ffs((pending
>> 16) & 0x7f);
191 do_IRQ(irq
+ SNI_PCIT_INT_START
- 1);
192 set_c0_status(IE_IRQ1
);
195 static void pcit_hwint0(void)
197 u32 pending
= *(volatile u32
*)SNI_PCIT_INT_REG
;
200 clear_c0_status(IE_IRQ0
);
201 irq
= ffs((pending
>> 16) & 0x3f);
204 do_IRQ(irq
+ SNI_PCIT_INT_START
- 1);
205 set_c0_status(IE_IRQ0
);
208 static void sni_pcit_hwint(void)
210 u32 pending
= read_c0_cause() & read_c0_status();
212 if (pending
& C_IRQ1
)
214 else if (pending
& C_IRQ2
)
215 do_IRQ(MIPS_CPU_IRQ_BASE
+ 4);
216 else if (pending
& C_IRQ3
)
217 do_IRQ(MIPS_CPU_IRQ_BASE
+ 5);
218 else if (pending
& C_IRQ5
)
219 do_IRQ(MIPS_CPU_IRQ_BASE
+ 7);
222 static void sni_pcit_hwint_cplus(void)
224 u32 pending
= read_c0_cause() & read_c0_status();
226 if (pending
& C_IRQ0
)
228 else if (pending
& C_IRQ1
)
229 do_IRQ(MIPS_CPU_IRQ_BASE
+ 3);
230 else if (pending
& C_IRQ2
)
231 do_IRQ(MIPS_CPU_IRQ_BASE
+ 4);
232 else if (pending
& C_IRQ3
)
233 do_IRQ(MIPS_CPU_IRQ_BASE
+ 5);
234 else if (pending
& C_IRQ5
)
235 do_IRQ(MIPS_CPU_IRQ_BASE
+ 7);
238 void __init
sni_pcit_irq_init(void)
243 for (i
= SNI_PCIT_INT_START
; i
<= SNI_PCIT_INT_END
; i
++)
244 set_irq_chip(i
, &pcit_irq_type
);
245 *(volatile u32
*)SNI_PCIT_INT_REG
= 0;
246 sni_hwint
= sni_pcit_hwint
;
247 change_c0_status(ST0_IM
, IE_IRQ1
);
248 setup_irq(SNI_PCIT_INT_START
+ 6, &sni_isa_irq
);
251 void __init
sni_pcit_cplus_irq_init(void)
256 for (i
= SNI_PCIT_INT_START
; i
<= SNI_PCIT_INT_END
; i
++)
257 set_irq_chip(i
, &pcit_irq_type
);
258 *(volatile u32
*)SNI_PCIT_INT_REG
= 0x40000000;
259 sni_hwint
= sni_pcit_hwint_cplus
;
260 change_c0_status(ST0_IM
, IE_IRQ0
);
261 setup_irq(MIPS_CPU_IRQ_BASE
+ 3, &sni_isa_irq
);
264 void __init
sni_pcit_init(void)
266 ioport_resource
.end
= sni_io_resource
.end
;
268 PCIBIOS_MIN_IO
= 0x9000;
269 register_pci_controller(&sni_pcit_controller
);
271 sni_pcit_resource_init();
274 static int __init
snirm_pcit_setup_devinit(void)
276 switch (sni_brd_type
) {
277 case SNI_BRD_PCI_TOWER
:
278 platform_device_register(&pcit_serial8250_device
);
279 platform_device_register(&pcit_cmos_device
);
282 case SNI_BRD_PCI_TOWER_CPLUS
:
283 platform_device_register(&pcit_cplus_serial8250_device
);
284 platform_device_register(&pcit_cmos_device
);
290 device_initcall(snirm_pcit_setup_devinit
);