diff options
author | Liviu Dudau <Liviu.Dudau@arm.com> | 2014-09-29 10:29:27 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-09-30 19:08:57 -0400 |
commit | 41e5c0f81d3e676d671d96a0a1fafb27abfbd9d7 (patch) | |
tree | 674d5c5bc98998014d5b454f059bb052660057d5 /drivers/of | |
parent | 670ba0c8883b576d0aec28bd7a838358a4be1406 (diff) |
of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr()
Add pci_get_new_domain_nr() to allocate a new domain number and
of_get_pci_domain_nr() to retrieve the PCI domain number of a given device
from DT. Host bridge drivers or architecture-specific code can choose to
implement their PCI domain number policy using these two functions.
Using of_get_pci_domain_nr() guarantees a stable PCI domain number on every
boot provided that all host bridge controllers are assigned a number in the
device tree using "linux,pci-domain" property. Mixing use of
pci_get_new_domain_nr() and of_get_pci_domain_nr() is not recommended as it
can lead to potentially conflicting domain numbers being assigned to root
buses behind different host bridges.
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Arnd Bergmann <arnd@arndb.de>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/of_pci.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 848199633798..82d172fa145a 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c | |||
@@ -89,6 +89,31 @@ int of_pci_parse_bus_range(struct device_node *node, struct resource *res) | |||
89 | } | 89 | } |
90 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); | 90 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); |
91 | 91 | ||
92 | /** | ||
93 | * This function will try to obtain the host bridge domain number by | ||
94 | * finding a property called "linux,pci-domain" of the given device node. | ||
95 | * | ||
96 | * @node: device tree node with the domain information | ||
97 | * | ||
98 | * Returns the associated domain number from DT in the range [0-0xffff], or | ||
99 | * a negative value if the required property is not found. | ||
100 | */ | ||
101 | int of_get_pci_domain_nr(struct device_node *node) | ||
102 | { | ||
103 | const __be32 *value; | ||
104 | int len; | ||
105 | u16 domain; | ||
106 | |||
107 | value = of_get_property(node, "linux,pci-domain", &len); | ||
108 | if (!value || len < sizeof(*value)) | ||
109 | return -EINVAL; | ||
110 | |||
111 | domain = (u16)be32_to_cpup(value); | ||
112 | |||
113 | return domain; | ||
114 | } | ||
115 | EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); | ||
116 | |||
92 | #ifdef CONFIG_PCI_MSI | 117 | #ifdef CONFIG_PCI_MSI |
93 | 118 | ||
94 | static LIST_HEAD(of_pci_msi_chip_list); | 119 | static LIST_HEAD(of_pci_msi_chip_list); |