2 * Low-Level PCI Support for SGI Visual Workstation
4 * (c) 1999--2000 Martin Mares <mj@suse.cz>
7 #include <linux/config.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/pci.h>
12 #include <linux/init.h>
13 #include <linux/irq.h>
16 #include <asm/lithium.h>
21 unsigned int pci_probe
= 0;
24 * The VISWS uses configuration access type 1 only.
27 #define CONFIG_CMD(dev, where) (0x80000000 | (dev->bus->number << 16) | (dev->devfn << 8) | (where & ~3))
29 static int pci_conf1_read_config_byte(struct pci_dev
*dev
, int where
, u8
*value
)
31 outl(CONFIG_CMD(dev
,where
), 0xCF8);
32 *value
= inb(0xCFC + (where
&3));
33 return PCIBIOS_SUCCESSFUL
;
36 static int pci_conf1_read_config_word(struct pci_dev
*dev
, int where
, u16
*value
)
38 outl(CONFIG_CMD(dev
,where
), 0xCF8);
39 *value
= inw(0xCFC + (where
&2));
40 return PCIBIOS_SUCCESSFUL
;
43 static int pci_conf1_read_config_dword(struct pci_dev
*dev
, int where
, u32
*value
)
45 outl(CONFIG_CMD(dev
,where
), 0xCF8);
47 return PCIBIOS_SUCCESSFUL
;
50 static int pci_conf1_write_config_byte(struct pci_dev
*dev
, int where
, u8 value
)
52 outl(CONFIG_CMD(dev
,where
), 0xCF8);
53 outb(value
, 0xCFC + (where
&3));
54 return PCIBIOS_SUCCESSFUL
;
57 static int pci_conf1_write_config_word(struct pci_dev
*dev
, int where
, u16 value
)
59 outl(CONFIG_CMD(dev
,where
), 0xCF8);
60 outw(value
, 0xCFC + (where
&2));
61 return PCIBIOS_SUCCESSFUL
;
64 static int pci_conf1_write_config_dword(struct pci_dev
*dev
, int where
, u32 value
)
66 outl(CONFIG_CMD(dev
,where
), 0xCF8);
68 return PCIBIOS_SUCCESSFUL
;
73 static struct pci_ops visws_pci_ops
= {
74 pci_conf1_read_config_byte
,
75 pci_conf1_read_config_word
,
76 pci_conf1_read_config_dword
,
77 pci_conf1_write_config_byte
,
78 pci_conf1_write_config_word
,
79 pci_conf1_write_config_dword
82 static void __init
pcibios_fixup_irqs(void)
84 struct pci_dev
*dev
, *p
;
88 pci_for_each_dev(dev
) {
89 pci_read_config_byte(dev
, PCI_INTERRUPT_PIN
, &pin
);
94 if (dev
->bus
->parent
) {
95 p
= dev
->bus
->parent
->self
;
96 pin
= (pin
+ PCI_SLOT(dev
->devfn
)) % 4;
99 irq
= visws_get_PCI_irq_vector(p
->bus
->number
, PCI_SLOT(p
->devfn
), pin
+1);
102 DBG("PCI IRQ: %s pin %d -> %d\n", dev
->slot_name
, pin
, irq
);
106 void __init
pcibios_fixup_bus(struct pci_bus
*b
)
108 pci_read_bridge_bases(b
);
112 static struct resource visws_pci_bus_resources
[2] = {
113 { "Host bus 1", 0xf4000000, 0xf7ffffff, 0 },
114 { "Host bus 2", 0xf0000000, 0xf3ffffff, 0 }
118 void __init
pcibios_init(void)
120 unsigned int sec_bus
= li_pcib_read16(LI_PCI_BUSNUM
) & 0xff;
122 printk("PCI: Probing PCI hardware on host buses 00 and %02x\n", sec_bus
);
123 pci_scan_bus(0, &visws_pci_ops
, NULL
);
124 pci_scan_bus(sec_bus
, &visws_pci_ops
, NULL
);
125 pcibios_fixup_irqs();
126 pcibios_resource_survey();
129 char * __init
pcibios_setup(char *str
)
134 int pcibios_enable_device(struct pci_dev
*dev
)
136 return pcibios_enable_resources(dev
);
139 void __init
pcibios_penalize_isa_irq(irq
)