11da177e4SLinus Torvalds #include <linux/init.h> 21da177e4SLinus Torvalds #include <linux/pci.h> 31da177e4SLinus Torvalds 41da177e4SLinus Torvalds /* PCI interrupt pins */ 51da177e4SLinus Torvalds #define PCIA 1 61da177e4SLinus Torvalds #define PCIB 2 71da177e4SLinus Torvalds #define PCIC 3 81da177e4SLinus Torvalds #define PCID 4 91da177e4SLinus Torvalds 101da177e4SLinus Torvalds /* This table is filled in by interrogating the PIIX4 chip */ 11*28eb0e46SGreg Kroah-Hartman static char pci_irq[5] = { 122eaaac50SRalf Baechle }; 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds static char irq_tab[][5] __initdata = { 151da177e4SLinus Torvalds /* INTA INTB INTC INTD */ 161da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 0: GT64120 PCI bridge */ 171da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 1: Unused */ 181da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 2: Unused */ 191da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 3: Unused */ 201da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 4: Unused */ 211da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 5: Unused */ 221da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 6: Unused */ 231da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 7: Unused */ 241da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 8: Unused */ 251da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 9: Unused */ 261da177e4SLinus Torvalds {0, 0, 0, 0, PCID }, /* 10: PIIX4 USB */ 271da177e4SLinus Torvalds {0, PCIB, 0, 0, 0 }, /* 11: AMD 79C973 Ethernet */ 281da177e4SLinus Torvalds {0, PCIC, 0, 0, 0 }, /* 12: Crystal 4281 Sound */ 291da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 13: Unused */ 301da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 14: Unused */ 311da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 15: Unused */ 321da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 16: Unused */ 331da177e4SLinus Torvalds {0, 0, 0, 0, 0 }, /* 17: Bonito/SOC-it PCI Bridge*/ 341da177e4SLinus Torvalds {0, PCIA, PCIB, PCIC, PCID }, /* 18: PCI Slot 1 */ 351da177e4SLinus Torvalds {0, PCIB, PCIC, PCID, PCIA }, /* 19: PCI Slot 2 */ 361da177e4SLinus Torvalds {0, PCIC, PCID, PCIA, PCIB }, /* 20: PCI Slot 3 */ 371da177e4SLinus Torvalds {0, PCID, PCIA, PCIB, PCIC } /* 21: PCI Slot 4 */ 381da177e4SLinus Torvalds }; 391da177e4SLinus Torvalds 4019df0d11SRalf Baechle int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 411da177e4SLinus Torvalds { 421da177e4SLinus Torvalds int virq; 431da177e4SLinus Torvalds virq = irq_tab[slot][pin]; 441da177e4SLinus Torvalds return pci_irq[virq]; 451da177e4SLinus Torvalds } 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds /* Do platform specific device initialization at pci_enable_device() time */ 481da177e4SLinus Torvalds int pcibios_plat_dev_init(struct pci_dev *dev) 491da177e4SLinus Torvalds { 501da177e4SLinus Torvalds return 0; 511da177e4SLinus Torvalds } 521da177e4SLinus Torvalds 53*28eb0e46SGreg Kroah-Hartman static void malta_piix_func0_fixup(struct pci_dev *pdev) 541da177e4SLinus Torvalds { 551da177e4SLinus Torvalds unsigned char reg_val; 56*28eb0e46SGreg Kroah-Hartman static int piixirqmap[16] = { /* PIIX PIRQC[A:D] irq mappings */ 571da177e4SLinus Torvalds 0, 0, 0, 3, 581da177e4SLinus Torvalds 4, 5, 6, 7, 591da177e4SLinus Torvalds 0, 9, 10, 11, 601da177e4SLinus Torvalds 12, 0, 14, 15 611da177e4SLinus Torvalds }; 621da177e4SLinus Torvalds int i; 631da177e4SLinus Torvalds 641da177e4SLinus Torvalds /* Interrogate PIIX4 to get PCI IRQ mapping */ 651da177e4SLinus Torvalds for (i = 0; i <= 3; i++) { 661da177e4SLinus Torvalds pci_read_config_byte(pdev, 0x60+i, ®_val); 671da177e4SLinus Torvalds if (reg_val & 0x80) 681da177e4SLinus Torvalds pci_irq[PCIA+i] = 0; /* Disabled */ 691da177e4SLinus Torvalds else 701da177e4SLinus Torvalds pci_irq[PCIA+i] = piixirqmap[reg_val & 15]; 711da177e4SLinus Torvalds } 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds /* Done by YAMON 2.00 onwards */ 741da177e4SLinus Torvalds if (PCI_SLOT(pdev->devfn) == 10) { 751da177e4SLinus Torvalds /* 761da177e4SLinus Torvalds * Set top of main memory accessible by ISA or DMA 771da177e4SLinus Torvalds * devices to 16 Mb. 781da177e4SLinus Torvalds */ 791da177e4SLinus Torvalds pci_read_config_byte(pdev, 0x69, ®_val); 801da177e4SLinus Torvalds pci_write_config_byte(pdev, 0x69, reg_val | 0xf0); 811da177e4SLinus Torvalds } 821da177e4SLinus Torvalds } 831da177e4SLinus Torvalds 841da177e4SLinus Torvalds DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, 851da177e4SLinus Torvalds malta_piix_func0_fixup); 861da177e4SLinus Torvalds 87*28eb0e46SGreg Kroah-Hartman static void malta_piix_func1_fixup(struct pci_dev *pdev) 881da177e4SLinus Torvalds { 891da177e4SLinus Torvalds unsigned char reg_val; 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds /* Done by YAMON 2.02 onwards */ 921da177e4SLinus Torvalds if (PCI_SLOT(pdev->devfn) == 10) { 931da177e4SLinus Torvalds /* 941da177e4SLinus Torvalds * IDE Decode enable. 951da177e4SLinus Torvalds */ 961da177e4SLinus Torvalds pci_read_config_byte(pdev, 0x41, ®_val); 971da177e4SLinus Torvalds pci_write_config_byte(pdev, 0x41, reg_val|0x80); 981da177e4SLinus Torvalds pci_read_config_byte(pdev, 0x43, ®_val); 991da177e4SLinus Torvalds pci_write_config_byte(pdev, 0x43, reg_val|0x80); 1001da177e4SLinus Torvalds } 1011da177e4SLinus Torvalds } 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, 1041da177e4SLinus Torvalds malta_piix_func1_fixup); 105497e5ff0SRalf Baechle 106497e5ff0SRalf Baechle /* Enable PCI 2.1 compatibility in PIIX4 */ 107*28eb0e46SGreg Kroah-Hartman static void quirk_dlcsetup(struct pci_dev *dev) 108497e5ff0SRalf Baechle { 109497e5ff0SRalf Baechle u8 odlc, ndlc; 110497e5ff0SRalf Baechle 111497e5ff0SRalf Baechle (void) pci_read_config_byte(dev, 0x82, &odlc); 112497e5ff0SRalf Baechle /* Enable passive releases and delayed transaction */ 113497e5ff0SRalf Baechle ndlc = odlc | 7; 114497e5ff0SRalf Baechle (void) pci_write_config_byte(dev, 0x82, ndlc); 115497e5ff0SRalf Baechle } 116497e5ff0SRalf Baechle 117497e5ff0SRalf Baechle DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, 118497e5ff0SRalf Baechle quirk_dlcsetup); 119