fixup-malta.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include <linux/init.h>
  2. #include <linux/pci.h>
  3. /* PCI interrupt pins */
  4. #define PCIA 1
  5. #define PCIB 2
  6. #define PCIC 3
  7. #define PCID 4
  8. /* This table is filled in by interrogating the PIIX4 chip */
  9. static char pci_irq[5] = {
  10. };
  11. static char irq_tab[][5] __initdata = {
  12. /* INTA INTB INTC INTD */
  13. {0, 0, 0, 0, 0 }, /* 0: GT64120 PCI bridge */
  14. {0, 0, 0, 0, 0 }, /* 1: Unused */
  15. {0, 0, 0, 0, 0 }, /* 2: Unused */
  16. {0, 0, 0, 0, 0 }, /* 3: Unused */
  17. {0, 0, 0, 0, 0 }, /* 4: Unused */
  18. {0, 0, 0, 0, 0 }, /* 5: Unused */
  19. {0, 0, 0, 0, 0 }, /* 6: Unused */
  20. {0, 0, 0, 0, 0 }, /* 7: Unused */
  21. {0, 0, 0, 0, 0 }, /* 8: Unused */
  22. {0, 0, 0, 0, 0 }, /* 9: Unused */
  23. {0, 0, 0, 0, PCID }, /* 10: PIIX4 USB */
  24. {0, PCIB, 0, 0, 0 }, /* 11: AMD 79C973 Ethernet */
  25. {0, PCIC, 0, 0, 0 }, /* 12: Crystal 4281 Sound */
  26. {0, 0, 0, 0, 0 }, /* 13: Unused */
  27. {0, 0, 0, 0, 0 }, /* 14: Unused */
  28. {0, 0, 0, 0, 0 }, /* 15: Unused */
  29. {0, 0, 0, 0, 0 }, /* 16: Unused */
  30. {0, 0, 0, 0, 0 }, /* 17: Bonito/SOC-it PCI Bridge*/
  31. {0, PCIA, PCIB, PCIC, PCID }, /* 18: PCI Slot 1 */
  32. {0, PCIB, PCIC, PCID, PCIA }, /* 19: PCI Slot 2 */
  33. {0, PCIC, PCID, PCIA, PCIB }, /* 20: PCI Slot 3 */
  34. {0, PCID, PCIA, PCIB, PCIC } /* 21: PCI Slot 4 */
  35. };
  36. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  37. {
  38. int virq;
  39. virq = irq_tab[slot][pin];
  40. return pci_irq[virq];
  41. }
  42. /* Do platform specific device initialization at pci_enable_device() time */
  43. int pcibios_plat_dev_init(struct pci_dev *dev)
  44. {
  45. return 0;
  46. }
  47. static void malta_piix_func0_fixup(struct pci_dev *pdev)
  48. {
  49. unsigned char reg_val;
  50. static int piixirqmap[16] = { /* PIIX PIRQC[A:D] irq mappings */
  51. 0, 0, 0, 3,
  52. 4, 5, 6, 7,
  53. 0, 9, 10, 11,
  54. 12, 0, 14, 15
  55. };
  56. int i;
  57. /* Interrogate PIIX4 to get PCI IRQ mapping */
  58. for (i = 0; i <= 3; i++) {
  59. pci_read_config_byte(pdev, 0x60+i, &reg_val);
  60. if (reg_val & 0x80)
  61. pci_irq[PCIA+i] = 0; /* Disabled */
  62. else
  63. pci_irq[PCIA+i] = piixirqmap[reg_val & 15];
  64. }
  65. /* Done by YAMON 2.00 onwards */
  66. if (PCI_SLOT(pdev->devfn) == 10) {
  67. /*
  68. * Set top of main memory accessible by ISA or DMA
  69. * devices to 16 Mb.
  70. */
  71. pci_read_config_byte(pdev, 0x69, &reg_val);
  72. pci_write_config_byte(pdev, 0x69, reg_val | 0xf0);
  73. }
  74. }
  75. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
  76. malta_piix_func0_fixup);
  77. static void malta_piix_func1_fixup(struct pci_dev *pdev)
  78. {
  79. unsigned char reg_val;
  80. /* Done by YAMON 2.02 onwards */
  81. if (PCI_SLOT(pdev->devfn) == 10) {
  82. /*
  83. * IDE Decode enable.
  84. */
  85. pci_read_config_byte(pdev, 0x41, &reg_val);
  86. pci_write_config_byte(pdev, 0x41, reg_val|0x80);
  87. pci_read_config_byte(pdev, 0x43, &reg_val);
  88. pci_write_config_byte(pdev, 0x43, reg_val|0x80);
  89. }
  90. }
  91. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB,
  92. malta_piix_func1_fixup);
  93. /* Enable PCI 2.1 compatibility in PIIX4 */
  94. static void quirk_dlcsetup(struct pci_dev *dev)
  95. {
  96. u8 odlc, ndlc;
  97. (void) pci_read_config_byte(dev, 0x82, &odlc);
  98. /* Enable passive releases and delayed transaction */
  99. ndlc = odlc | 7;
  100. (void) pci_write_config_byte(dev, 0x82, ndlc);
  101. }
  102. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
  103. quirk_dlcsetup);