fixup-ocelot.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2001 MontaVista Software Inc.
  3. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  4. *
  5. * arch/mips/gt64120/momenco_ocelot/pci.c
  6. * Board-specific PCI routines for gt64120 controller.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/pci.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <asm/pci.h>
  18. void __devinit pcibios_fixup_bus(struct pci_bus *bus)
  19. {
  20. struct pci_bus *current_bus = bus;
  21. struct pci_dev *devices;
  22. struct list_head *devices_link;
  23. u16 cmd;
  24. list_for_each(devices_link, &(current_bus->devices)) {
  25. devices = pci_dev_b(devices_link);
  26. if (devices == NULL)
  27. continue;
  28. if (PCI_SLOT(devices->devfn) == 1) {
  29. /*
  30. * Slot 1 is primary ether port, i82559
  31. * we double-check against that assumption
  32. */
  33. if ((devices->vendor != 0x8086) ||
  34. (devices->device != 0x1209)) {
  35. panic("pcibios_fixup_bus: found "
  36. "unexpected PCI device in slot 1.");
  37. }
  38. devices->irq = 2; /* irq_nr is 2 for INT0 */
  39. } else if (PCI_SLOT(devices->devfn) == 2) {
  40. /*
  41. * Slot 2 is secondary ether port, i21143
  42. * we double-check against that assumption
  43. */
  44. if ((devices->vendor != 0x1011) ||
  45. (devices->device != 0x19)) {
  46. panic("galileo_pcibios_fixup_bus: "
  47. "found unexpected PCI device in slot 2.");
  48. }
  49. devices->irq = 3; /* irq_nr is 3 for INT1 */
  50. } else if (PCI_SLOT(devices->devfn) == 4) {
  51. /* PMC Slot 1 */
  52. devices->irq = 8; /* irq_nr is 8 for INT6 */
  53. } else if (PCI_SLOT(devices->devfn) == 5) {
  54. /* PMC Slot 1 */
  55. devices->irq = 9; /* irq_nr is 9 for INT7 */
  56. } else {
  57. /* We don't have assign interrupts for other devices. */
  58. devices->irq = 0xff;
  59. }
  60. /* Assign an interrupt number for the device */
  61. bus->ops->write_byte(devices, PCI_INTERRUPT_LINE,
  62. devices->irq);
  63. /* enable master */
  64. bus->ops->read_word(devices, PCI_COMMAND, &cmd);
  65. cmd |= PCI_COMMAND_MASTER;
  66. bus->ops->write_word(devices, PCI_COMMAND, cmd);
  67. }
  68. }