3 #include <linux/ioport.h>
4 #include <linux/errno.h>
8 struct of_pci_range_parser {
9 struct device_node *node;
24 #define for_each_of_pci_range(parser, range) \
25 for (; of_pci_range_parser_one(parser, range);)
27 /* Translate a DMA address from device space to CPU space */
28 extern u64 of_translate_dma_address(struct device_node *dev,
29 const __be32 *in_addr);
31 #ifdef CONFIG_OF_ADDRESS
32 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
33 extern int of_address_to_resource(struct device_node *dev, int index,
35 extern struct device_node *of_find_matching_node_by_address(
36 struct device_node *from,
37 const struct of_device_id *matches,
39 extern void __iomem *of_iomap(struct device_node *device, int index);
40 void __iomem *of_io_request_and_map(struct device_node *device,
41 int index, const char *name);
43 /* Extract an address from a device, returns the region size and
44 * the address space flags too. The PCI version uses a BAR number
45 * instead of an absolute index
47 extern const __be32 *of_get_address(struct device_node *dev, int index,
48 u64 *size, unsigned int *flags);
50 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
51 struct device_node *node);
52 extern struct of_pci_range *of_pci_range_parser_one(
53 struct of_pci_range_parser *parser,
54 struct of_pci_range *range);
55 extern int of_dma_get_range(struct device_node *np, u64 *dma_addr,
56 u64 *paddr, u64 *size);
57 extern bool of_dma_is_coherent(struct device_node *np);
58 #else /* CONFIG_OF_ADDRESS */
59 static inline void __iomem *of_io_request_and_map(struct device_node *device,
60 int index, const char *name)
62 return IOMEM_ERR_PTR(-EINVAL);
65 static inline u64 of_translate_address(struct device_node *np,
71 static inline struct device_node *of_find_matching_node_by_address(
72 struct device_node *from,
73 const struct of_device_id *matches,
79 static inline const __be32 *of_get_address(struct device_node *dev, int index,
80 u64 *size, unsigned int *flags)
85 static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
86 struct device_node *node)
91 static inline struct of_pci_range *of_pci_range_parser_one(
92 struct of_pci_range_parser *parser,
93 struct of_pci_range *range)
98 static inline int of_dma_get_range(struct device_node *np, u64 *dma_addr,
99 u64 *paddr, u64 *size)
104 static inline bool of_dma_is_coherent(struct device_node *np)
108 #endif /* CONFIG_OF_ADDRESS */
111 extern int of_address_to_resource(struct device_node *dev, int index,
113 void __iomem *of_iomap(struct device_node *node, int index);
115 static inline int of_address_to_resource(struct device_node *dev, int index,
121 static inline void __iomem *of_iomap(struct device_node *device, int index)
127 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
128 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
129 u64 *size, unsigned int *flags);
130 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
132 extern int of_pci_range_to_resource(struct of_pci_range *range,
133 struct device_node *np,
134 struct resource *res);
135 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
136 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
142 static inline const __be32 *of_get_pci_address(struct device_node *dev,
143 int bar_no, u64 *size, unsigned int *flags)
147 static inline int of_pci_range_to_resource(struct of_pci_range *range,
148 struct device_node *np,
149 struct resource *res)
153 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
155 #endif /* __OF_ADDRESS_H */