24 #include <linux/kernel.h>
26 #include <linux/pci.h>
30 #include <asm/byteorder.h>
33 #include <asm/uaccess.h>
34 #include <asm/machdep.h>
35 #include <asm/pci-bridge.h>
43 #define DBG(x...) printk(x)
48 #define tsi_mk_config_addr(bus, devfunc, offset) \
49 ((((bus)<<16) | ((devfunc)<<8) | (offset & 0xfc)) + tsi108_pci_cfg_base)
52 static u32 tsi108_pci_cfg_phys;
64 volatile unsigned char *cfg_addr;
67 if (
ppc_md.pci_exclude_device)
68 if (
ppc_md.pci_exclude_device(hose, bus->
number, devfunc))
76 printk(
"PCI CFG write : ");
78 printk(
"%d ADDR=0x%08x ", len, (
uint) cfg_addr);
79 printk(
"data = 0x%08x\n", val);
121 if ((err_addr & 0xFF000000) == pci_cfg_base) {
132 #define __tsi108_read_pci_config(x, addr, op) \
133 __asm__ __volatile__( \
137 ".section .fixup,\"ax\"\n" \
140 ".section __ex_table,\"a\"\n" \
144 : "=r"(x) : "r"(addr))
150 volatile unsigned char *cfg_addr;
154 if (
ppc_md.pci_exclude_device)
155 if (
ppc_md.pci_exclude_device(hose, bus->
number, devfn))
178 if ((0xFFFFFFFF != temp) && (0xFFFF != temp) && (0xFF != temp)) {
179 printk(
"PCI CFG read : ");
181 printk(
"%d ADDR=0x%08x ", len, (
uint) cfg_addr);
182 printk(
"data = 0x%x\n", *val);
193 static struct pci_ops tsi108_direct_pci_ops = {
203 const int *bus_range;
208 tsi108_pci_cfg_phys = cfg_phys;
209 DBG(
"TSI_PCI: %s tsi108_pci_cfg_base=0x%x\n", __func__,
217 if (bus_range ==
NULL || len < 2 *
sizeof(
int)) {
225 printk(
"PCI Host bridge init failed\n");
230 hose->
last_busno = bus_range ? bus_range[1] : 0xff;
232 (hose)->
ops = &tsi108_direct_pci_ops;
235 "Firmware bus number: %d->%d\n",
248 static void tsi108_pci_int_mask(
u_int irq)
255 irp_cfg |= (1 << int_line);
256 irp_cfg &= ~(3 << (8 + (int_line * 2)));
262 static void tsi108_pci_int_unmask(
u_int irq)
269 irp_cfg &= ~(1 << int_line);
270 irp_cfg |= (3 << (8 + (int_line * 2)));
275 static void init_pci_source(
void)
284 static inline unsigned int get_pci_source(
void)
302 for (i = 0; i < 4; i++, mask++) {
303 if (temp & (1 << mask % 4)) {
320 printk(
"TSI108_PIC: error in TSI108_PCI_IRP_STAT\n");
326 printk(
">> stat=0x%08x intad=0x%08x ", pci_irp_stat, temp);
330 printk(
"cfg_ctl=0x%08x ", temp);
334 printk(
"irp_enable=0x%08x\n", temp);
346 static void tsi108_pci_irq_unmask(
struct irq_data *
d)
348 tsi108_pci_int_unmask(d->
irq);
358 static void tsi108_pci_irq_mask(
struct irq_data *d)
360 tsi108_pci_int_mask(d->
irq);
363 static void tsi108_pci_irq_ack(
struct irq_data *d)
365 tsi108_pci_int_mask(d->
irq);
372 static struct irq_chip tsi108_pci_irq = {
373 .name =
"tsi108_PCI_int",
374 .irq_mask = tsi108_pci_irq_mask,
375 .irq_ack = tsi108_pci_irq_ack,
376 .irq_unmask = tsi108_pci_irq_unmask,
380 const u32 *intspec,
unsigned int intsize,
383 *out_hwirq = intspec[0];
388 static int pci_irq_host_map(
struct irq_domain *
h,
unsigned int virq,
391 DBG(
"%s(%d, 0x%lx)\n", __func__, virq, hw);
392 if ((virq >= 1) && (virq <= 4)){
401 .map = pci_irq_host_map,
402 .xlate = pci_irq_host_xlate,
420 DBG(
"Tsi108_pci_int_init: initializing PCI interrupts\n");
422 pci_irq_host = irq_domain_add_legacy_isa(node, &pci_irq_domain_ops,
NULL);
423 if (pci_irq_host ==
NULL) {
424 printk(
KERN_ERR "pci_irq_host: failed to allocate irq domain!\n");
436 if (cascade_irq !=
NO_IRQ)