diff options
-rw-r--r-- | drivers/of/of_pci.c | 25 | ||||
-rw-r--r-- | drivers/pci/pci.c | 9 | ||||
-rw-r--r-- | include/linux/of_pci.h | 7 | ||||
-rw-r--r-- | include/linux/pci.h | 3 |
4 files changed, 44 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); |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2c9ac70254e2..d36f35ff6c5d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -4406,6 +4406,15 @@ static void pci_no_domains(void) | |||
4406 | #endif | 4406 | #endif |
4407 | } | 4407 | } |
4408 | 4408 | ||
4409 | #ifdef CONFIG_PCI_DOMAINS | ||
4410 | static atomic_t __domain_nr = ATOMIC_INIT(-1); | ||
4411 | |||
4412 | int pci_get_new_domain_nr(void) | ||
4413 | { | ||
4414 | return atomic_inc_return(&__domain_nr); | ||
4415 | } | ||
4416 | #endif | ||
4417 | |||
4409 | /** | 4418 | /** |
4410 | * pci_ext_cfg_avail - can we access extended PCI config space? | 4419 | * pci_ext_cfg_avail - can we access extended PCI config space? |
4411 | * | 4420 | * |
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index dde3a4a0fa5d..71062e9602f5 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h | |||
@@ -15,6 +15,7 @@ struct device_node *of_pci_find_child_device(struct device_node *parent, | |||
15 | int of_pci_get_devfn(struct device_node *np); | 15 | int of_pci_get_devfn(struct device_node *np); |
16 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); | 16 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); |
17 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); | 17 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); |
18 | int of_get_pci_domain_nr(struct device_node *node); | ||
18 | #else | 19 | #else |
19 | static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) | 20 | static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) |
20 | { | 21 | { |
@@ -43,6 +44,12 @@ of_pci_parse_bus_range(struct device_node *node, struct resource *res) | |||
43 | { | 44 | { |
44 | return -EINVAL; | 45 | return -EINVAL; |
45 | } | 46 | } |
47 | |||
48 | static inline int | ||
49 | of_get_pci_domain_nr(struct device_node *node) | ||
50 | { | ||
51 | return -1; | ||
52 | } | ||
46 | #endif | 53 | #endif |
47 | 54 | ||
48 | #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) | 55 | #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) |
diff --git a/include/linux/pci.h b/include/linux/pci.h index a494e5d775c3..150da2d644e7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -1285,10 +1285,12 @@ void pci_cfg_access_unlock(struct pci_dev *dev); | |||
1285 | */ | 1285 | */ |
1286 | #ifdef CONFIG_PCI_DOMAINS | 1286 | #ifdef CONFIG_PCI_DOMAINS |
1287 | extern int pci_domains_supported; | 1287 | extern int pci_domains_supported; |
1288 | int pci_get_new_domain_nr(void); | ||
1288 | #else | 1289 | #else |
1289 | enum { pci_domains_supported = 0 }; | 1290 | enum { pci_domains_supported = 0 }; |
1290 | static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } | 1291 | static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } |
1291 | static inline int pci_proc_domain(struct pci_bus *bus) { return 0; } | 1292 | static inline int pci_proc_domain(struct pci_bus *bus) { return 0; } |
1293 | static inline int pci_get_new_domain_nr(void) { return -ENOSYS; } | ||
1292 | #endif /* CONFIG_PCI_DOMAINS */ | 1294 | #endif /* CONFIG_PCI_DOMAINS */ |
1293 | 1295 | ||
1294 | /* | 1296 | /* |
@@ -1417,6 +1419,7 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
1417 | 1419 | ||
1418 | static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } | 1420 | static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } |
1419 | static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) { return NULL; } | 1421 | static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) { return NULL; } |
1422 | static inline int pci_get_new_domain_nr(void) { return -ENOSYS; } | ||
1420 | 1423 | ||
1421 | #define dev_is_pci(d) (false) | 1424 | #define dev_is_pci(d) (false) |
1422 | #define dev_is_pf(d) (false) | 1425 | #define dev_is_pf(d) (false) |