visws.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Low-Level PCI Support for SGI Visual Workstation
  3. *
  4. * (c) 1999--2000 Martin Mares <mj@ucw.cz>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/pci.h>
  8. #include <linux/init.h>
  9. #include <asm/setup.h>
  10. #include <asm/pci_x86.h>
  11. #include <asm/visws/cobalt.h>
  12. #include <asm/visws/lithium.h>
  13. static int pci_visws_enable_irq(struct pci_dev *dev) { return 0; }
  14. static void pci_visws_disable_irq(struct pci_dev *dev) { }
  15. /* int (*pcibios_enable_irq)(struct pci_dev *dev) = &pci_visws_enable_irq; */
  16. /* void (*pcibios_disable_irq)(struct pci_dev *dev) = &pci_visws_disable_irq; */
  17. /* void __init pcibios_penalize_isa_irq(int irq, int active) {} */
  18. unsigned int pci_bus0, pci_bus1;
  19. static int __init visws_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  20. {
  21. int irq, bus = dev->bus->number;
  22. pin--;
  23. /* Nothing useful at PIIX4 pin 1 */
  24. if (bus == pci_bus0 && slot == 4 && pin == 0)
  25. return -1;
  26. /* PIIX4 USB is on Bus 0, Slot 4, Line 3 */
  27. if (bus == pci_bus0 && slot == 4 && pin == 3) {
  28. irq = CO_IRQ(CO_APIC_PIIX4_USB);
  29. goto out;
  30. }
  31. /* First pin spread down 1 APIC entry per slot */
  32. if (pin == 0) {
  33. irq = CO_IRQ((bus == pci_bus0 ? CO_APIC_PCIB_BASE0 :
  34. CO_APIC_PCIA_BASE0) + slot);
  35. goto out;
  36. }
  37. /* lines 1,2,3 from any slot is shared in this twirly pattern */
  38. if (bus == pci_bus1) {
  39. /* lines 1-3 from devices 0 1 rotate over 2 apic entries */
  40. irq = CO_IRQ(CO_APIC_PCIA_BASE123 + ((slot + (pin - 1)) % 2));
  41. } else { /* bus == pci_bus0 */
  42. /* lines 1-3 from devices 0-3 rotate over 3 apic entries */
  43. if (slot == 0)
  44. slot = 3; /* same pattern */
  45. irq = CO_IRQ(CO_APIC_PCIA_BASE123 + ((3 - slot) + (pin - 1) % 3));
  46. }
  47. out:
  48. printk(KERN_DEBUG "PCI: Bus %d Slot %d Line %d -> IRQ %d\n", bus, slot, pin, irq);
  49. return irq;
  50. }
  51. void __init pcibios_update_irq(struct pci_dev *dev, int irq)
  52. {
  53. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
  54. }
  55. int __init pci_visws_init(void)
  56. {
  57. pcibios_enable_irq = &pci_visws_enable_irq;
  58. pcibios_disable_irq = &pci_visws_disable_irq;
  59. /* The VISWS supports configuration access type 1 only */
  60. pci_probe = (pci_probe | PCI_PROBE_CONF1) &
  61. ~(PCI_PROBE_BIOS | PCI_PROBE_CONF2);
  62. pci_bus0 = li_pcib_read16(LI_PCI_BUSNUM) & 0xff;
  63. pci_bus1 = li_pcia_read16(LI_PCI_BUSNUM) & 0xff;
  64. printk(KERN_INFO "PCI: Lithium bridge A bus: %u, "
  65. "bridge B (PIIX4) bus: %u\n", pci_bus1, pci_bus0);
  66. raw_pci_ops = &pci_direct_conf1;
  67. pci_scan_bus_with_sysdata(pci_bus0);
  68. pci_scan_bus_with_sysdata(pci_bus1);
  69. pci_fixup_irqs(pci_common_swizzle, visws_map_irq);
  70. pcibios_resource_survey();
  71. /* Request bus scan */
  72. return 1;
  73. }