3 #include <linux/ioport.h>
4 #include <linux/errno.h>
7 struct of_pci_range_parser {
8 struct device_node *node;
23 #define for_each_of_pci_range(parser, range) \
24 for (; of_pci_range_parser_one(parser, range);)
26 static inline void of_pci_range_to_resource(struct of_pci_range *range,
27 struct device_node *np,
30 res->flags = range->flags;
31 res->start = range->cpu_addr;
32 res->end = range->cpu_addr + range->size - 1;
33 res->parent = res->child = res->sibling = NULL;
34 res->name = np->full_name;
37 #ifdef CONFIG_OF_ADDRESS
38 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
39 extern bool of_can_translate_address(struct device_node *dev);
40 extern int of_address_to_resource(struct device_node *dev, int index,
42 extern struct device_node *of_find_matching_node_by_address(
43 struct device_node *from,
44 const struct of_device_id *matches,
46 extern void __iomem *of_iomap(struct device_node *device, int index);
48 /* Extract an address from a device, returns the region size and
49 * the address space flags too. The PCI version uses a BAR number
50 * instead of an absolute index
52 extern const __be32 *of_get_address(struct device_node *dev, int index,
53 u64 *size, unsigned int *flags);
55 #ifndef pci_address_to_pio
56 static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
57 #define pci_address_to_pio pci_address_to_pio
60 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
61 struct device_node *node);
62 extern struct of_pci_range *of_pci_range_parser_one(
63 struct of_pci_range_parser *parser,
64 struct of_pci_range *range);
65 #else /* CONFIG_OF_ADDRESS */
66 #ifndef of_address_to_resource
67 static inline int of_address_to_resource(struct device_node *dev, int index,
73 static inline struct device_node *of_find_matching_node_by_address(
74 struct device_node *from,
75 const struct of_device_id *matches,
81 static inline void __iomem *of_iomap(struct device_node *device, int index)
86 static inline const __be32 *of_get_address(struct device_node *dev, int index,
87 u64 *size, unsigned int *flags)
92 static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
93 struct device_node *node)
98 static inline struct of_pci_range *of_pci_range_parser_one(
99 struct of_pci_range_parser *parser,
100 struct of_pci_range *range)
104 #endif /* CONFIG_OF_ADDRESS */
107 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
108 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
109 u64 *size, unsigned int *flags);
110 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
112 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
113 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
119 static inline const __be32 *of_get_pci_address(struct device_node *dev,
120 int bar_no, u64 *size, unsigned int *flags)
124 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
126 #endif /* __OF_ADDRESS_H */