diff options
| -rw-r--r-- | drivers/pci/setup-bus.c | 35 | ||||
| -rw-r--r-- | include/linux/pci.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 802f56be2149..e3e17f3c0f0f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
| @@ -646,6 +646,41 @@ void pci_setup_bridge(struct pci_bus *bus) | |||
| 646 | __pci_setup_bridge(bus, type); | 646 | __pci_setup_bridge(bus, type); |
| 647 | } | 647 | } |
| 648 | 648 | ||
| 649 | |||
| 650 | int pci_claim_bridge_resource(struct pci_dev *bridge, int i) | ||
| 651 | { | ||
| 652 | if (i < PCI_BRIDGE_RESOURCES || i > PCI_BRIDGE_RESOURCE_END) | ||
| 653 | return 0; | ||
| 654 | |||
| 655 | if (pci_claim_resource(bridge, i) == 0) | ||
| 656 | return 0; /* claimed the window */ | ||
| 657 | |||
| 658 | if ((bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI) | ||
| 659 | return 0; | ||
| 660 | |||
| 661 | if (!pci_bus_clip_resource(bridge, i)) | ||
| 662 | return -EINVAL; /* clipping didn't change anything */ | ||
| 663 | |||
| 664 | switch (i - PCI_BRIDGE_RESOURCES) { | ||
| 665 | case 0: | ||
| 666 | pci_setup_bridge_io(bridge); | ||
| 667 | break; | ||
| 668 | case 1: | ||
| 669 | pci_setup_bridge_mmio(bridge); | ||
| 670 | break; | ||
| 671 | case 2: | ||
| 672 | pci_setup_bridge_mmio_pref(bridge); | ||
| 673 | break; | ||
| 674 | default: | ||
| 675 | return -EINVAL; | ||
| 676 | } | ||
| 677 | |||
| 678 | if (pci_claim_resource(bridge, i) == 0) | ||
| 679 | return 0; /* claimed a smaller window */ | ||
| 680 | |||
| 681 | return -EINVAL; | ||
| 682 | } | ||
| 683 | |||
| 649 | /* Check whether the bridge supports optional I/O and | 684 | /* Check whether the bridge supports optional I/O and |
| 650 | prefetchable memory ranges. If not, the respective | 685 | prefetchable memory ranges. If not, the respective |
| 651 | base/limit registers must be read-only and read as 0. */ | 686 | base/limit registers must be read-only and read as 0. */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 44627f1df4ca..9603094ed59b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -1067,6 +1067,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx); | |||
| 1067 | void pci_bus_assign_resources(const struct pci_bus *bus); | 1067 | void pci_bus_assign_resources(const struct pci_bus *bus); |
| 1068 | void pci_bus_size_bridges(struct pci_bus *bus); | 1068 | void pci_bus_size_bridges(struct pci_bus *bus); |
| 1069 | int pci_claim_resource(struct pci_dev *, int); | 1069 | int pci_claim_resource(struct pci_dev *, int); |
| 1070 | int pci_claim_bridge_resource(struct pci_dev *bridge, int i); | ||
| 1070 | void pci_assign_unassigned_resources(void); | 1071 | void pci_assign_unassigned_resources(void); |
| 1071 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); | 1072 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); |
| 1072 | void pci_assign_unassigned_bus_resources(struct pci_bus *bus); | 1073 | void pci_assign_unassigned_bus_resources(struct pci_bus *bus); |
