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 /* Translate a DMA address from device space to CPU space */
38 extern u64 of_translate_dma_address(struct device_node *dev,
39 const __be32 *in_addr);
41 #ifdef CONFIG_OF_ADDRESS
42 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
43 extern bool of_can_translate_address(struct device_node *dev);
44 extern int of_address_to_resource(struct device_node *dev, int index,
46 extern struct device_node *of_find_matching_node_by_address(
47 struct device_node *from,
48 const struct of_device_id *matches,
50 extern void __iomem *of_iomap(struct device_node *device, int index);
52 /* Extract an address from a device, returns the region size and
53 * the address space flags too. The PCI version uses a BAR number
54 * instead of an absolute index
56 extern const __be32 *of_get_address(struct device_node *dev, int index,
57 u64 *size, unsigned int *flags);
59 extern unsigned long pci_address_to_pio(phys_addr_t addr);
61 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
62 struct device_node *node);
63 extern struct of_pci_range *of_pci_range_parser_one(
64 struct of_pci_range_parser *parser,
65 struct of_pci_range *range);
66 #else /* CONFIG_OF_ADDRESS */
67 static inline struct device_node *of_find_matching_node_by_address(
68 struct device_node *from,
69 const struct of_device_id *matches,
75 static inline const __be32 *of_get_address(struct device_node *dev, int index,
76 u64 *size, unsigned int *flags)
81 static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
82 struct device_node *node)
87 static inline struct of_pci_range *of_pci_range_parser_one(
88 struct of_pci_range_parser *parser,
89 struct of_pci_range *range)
93 #endif /* CONFIG_OF_ADDRESS */
96 extern int of_address_to_resource(struct device_node *dev, int index,
98 void __iomem *of_iomap(struct device_node *node, int index);
100 static inline int of_address_to_resource(struct device_node *dev, int index,
106 static inline void __iomem *of_iomap(struct device_node *device, int index)
112 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
113 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
114 u64 *size, unsigned int *flags);
115 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
117 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
118 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
124 static inline const __be32 *of_get_pci_address(struct device_node *dev,
125 int bar_no, u64 *size, unsigned int *flags)
129 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
131 #endif /* __OF_ADDRESS_H */