blob: bf588a05d0d0f9af194d0d415b2ce29d47787aad [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sebastian Andrzej Siewior04bea682011-01-24 09:58:55 +05302#ifndef __OF_PCI_H
3#define __OF_PCI_H
4
5#include <linux/pci.h>
Thomas Petazzoni0d5a6db2013-08-09 22:27:09 +02006#include <linux/msi.h>
Sebastian Andrzej Siewior04bea682011-01-24 09:58:55 +05307
8struct pci_dev;
Grant Likely530210c2013-09-15 16:39:11 +01009struct of_phandle_args;
Benjamin Herrenschmidt98d9f30c82011-04-11 11:37:07 +100010struct device_node;
Arnd Bergmann64c5c752014-06-04 04:40:19 -050011
Robin Murphy5c1d3312016-06-07 18:44:48 +010012#ifdef CONFIG_OF_PCI
Arnd Bergmann64c5c752014-06-04 04:40:19 -050013int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
Benjamin Herrenschmidt98d9f30c82011-04-11 11:37:07 +100014struct device_node *of_pci_find_child_device(struct device_node *parent,
15 unsigned int devfn);
Thierry Reding45ab9702013-05-16 17:55:18 +020016int of_pci_get_devfn(struct device_node *np);
Arnd Bergmann64c5c752014-06-04 04:40:19 -050017int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
Thierry Reding4e23d3f2013-05-16 17:55:19 +020018int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
Liviu Dudau41e5c0f2014-09-29 15:29:27 +010019int of_get_pci_domain_nr(struct device_node *node);
Shawn Lin9a1dc382016-11-14 15:21:14 -060020int of_pci_get_max_link_speed(struct device_node *node);
Marc Zyngierf81c11a2015-09-04 17:50:08 +010021void of_pci_check_probe_only(void);
Robin Murphy987068f2016-09-12 17:13:40 +010022int of_pci_map_rid(struct device_node *np, u32 rid,
23 const char *map_name, const char *map_mask_name,
24 struct device_node **target, u32 *id_out);
Arnd Bergmann64c5c752014-06-04 04:40:19 -050025#else
26static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
27{
28 return 0;
29}
30
31static inline struct device_node *of_pci_find_child_device(struct device_node *parent,
32 unsigned int devfn)
33{
34 return NULL;
35}
36
37static inline int of_pci_get_devfn(struct device_node *np)
38{
39 return -EINVAL;
40}
41
42static inline int
43of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
44{
45 return 0;
46}
47
48static inline int
49of_pci_parse_bus_range(struct device_node *node, struct resource *res)
50{
51 return -EINVAL;
52}
Liviu Dudau41e5c0f2014-09-29 15:29:27 +010053
54static inline int
55of_get_pci_domain_nr(struct device_node *node)
56{
57 return -1;
58}
Murali Karicheric49b8fc2015-03-03 12:52:12 -050059
Robin Murphy987068f2016-09-12 17:13:40 +010060static inline int of_pci_map_rid(struct device_node *np, u32 rid,
61 const char *map_name, const char *map_mask_name,
62 struct device_node **target, u32 *id_out)
63{
64 return -EINVAL;
65}
66
Shawn Lin9a1dc382016-11-14 15:21:14 -060067static inline int
68of_pci_get_max_link_speed(struct device_node *node)
69{
70 return -EINVAL;
71}
72
Marc Zyngierf81c11a2015-09-04 17:50:08 +010073static inline void of_pci_check_probe_only(void) { }
Arnd Bergmann64c5c752014-06-04 04:40:19 -050074#endif
Benjamin Herrenschmidt98d9f30c82011-04-11 11:37:07 +100075
Liviu Dudaucbe40972014-09-29 15:29:28 +010076#if defined(CONFIG_OF_ADDRESS)
77int of_pci_get_host_bridge_resources(struct device_node *dev,
78 unsigned char busno, unsigned char bus_max,
79 struct list_head *resources, resource_size_t *io_base);
Arnd Bergmann40704b12015-12-18 16:02:41 +010080#else
81static inline int of_pci_get_host_bridge_resources(struct device_node *dev,
82 unsigned char busno, unsigned char bus_max,
83 struct list_head *resources, resource_size_t *io_base)
84{
85 return -EINVAL;
86}
Liviu Dudaucbe40972014-09-29 15:29:28 +010087#endif
88
Sebastian Andrzej Siewior04bea682011-01-24 09:58:55 +053089#endif