blob: e83d87fc5673de04345267bf94b90500b1caf5e9 [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
Rob Herring4670d612018-01-17 17:36:39 -060012#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PCI)
Benjamin Herrenschmidt98d9f30c82011-04-11 11:37:07 +100013struct device_node *of_pci_find_child_device(struct device_node *parent,
14 unsigned int devfn);
Thierry Reding45ab9702013-05-16 17:55:18 +020015int of_pci_get_devfn(struct device_node *np);
Marc Zyngierf81c11a2015-09-04 17:50:08 +010016void of_pci_check_probe_only(void);
Robin Murphy987068f2016-09-12 17:13:40 +010017int of_pci_map_rid(struct device_node *np, u32 rid,
18 const char *map_name, const char *map_mask_name,
19 struct device_node **target, u32 *id_out);
Arnd Bergmann64c5c752014-06-04 04:40:19 -050020#else
Arnd Bergmann64c5c752014-06-04 04:40:19 -050021static inline struct device_node *of_pci_find_child_device(struct device_node *parent,
22 unsigned int devfn)
23{
24 return NULL;
25}
26
27static inline int of_pci_get_devfn(struct device_node *np)
28{
29 return -EINVAL;
30}
31
Robin Murphy987068f2016-09-12 17:13:40 +010032static inline int of_pci_map_rid(struct device_node *np, u32 rid,
33 const char *map_name, const char *map_mask_name,
34 struct device_node **target, u32 *id_out)
35{
36 return -EINVAL;
37}
38
Marc Zyngierf81c11a2015-09-04 17:50:08 +010039static inline void of_pci_check_probe_only(void) { }
Arnd Bergmann64c5c752014-06-04 04:40:19 -050040#endif
Benjamin Herrenschmidt98d9f30c82011-04-11 11:37:07 +100041
Guenter Roecka6f10862018-03-05 15:22:30 -080042#if IS_ENABLED(CONFIG_OF_IRQ)
43int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
44#else
45static inline int
46of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
47{
48 return 0;
49}
50#endif
51
Sebastian Andrzej Siewior04bea682011-01-24 09:58:55 +053052#endif