drm/panfrost: Remove set but not used variable 'bo'
[linux/fpc-iii.git] / include / linux / of_address.h
blobeac7ab109df40892e55d2fdb5a003bbf294b7b87
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __OF_ADDRESS_H
3 #define __OF_ADDRESS_H
4 #include <linux/ioport.h>
5 #include <linux/errno.h>
6 #include <linux/of.h>
7 #include <linux/io.h>
9 struct of_pci_range_parser {
10 struct device_node *node;
11 const __be32 *range;
12 const __be32 *end;
13 int np;
14 int pna;
15 bool dma;
18 struct of_pci_range {
19 u32 pci_space;
20 u64 pci_addr;
21 u64 cpu_addr;
22 u64 size;
23 u32 flags;
26 #define for_each_of_pci_range(parser, range) \
27 for (; of_pci_range_parser_one(parser, range);)
29 /* Translate a DMA address from device space to CPU space */
30 extern u64 of_translate_dma_address(struct device_node *dev,
31 const __be32 *in_addr);
33 #ifdef CONFIG_OF_ADDRESS
34 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
35 extern int of_address_to_resource(struct device_node *dev, int index,
36 struct resource *r);
37 extern void __iomem *of_iomap(struct device_node *device, int index);
38 void __iomem *of_io_request_and_map(struct device_node *device,
39 int index, const char *name);
41 /* Extract an address from a device, returns the region size and
42 * the address space flags too. The PCI version uses a BAR number
43 * instead of an absolute index
45 extern const __be32 *of_get_address(struct device_node *dev, int index,
46 u64 *size, unsigned int *flags);
48 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
49 struct device_node *node);
50 extern int of_pci_dma_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 bool of_dma_is_coherent(struct device_node *np);
56 #else /* CONFIG_OF_ADDRESS */
57 static inline void __iomem *of_io_request_and_map(struct device_node *device,
58 int index, const char *name)
60 return IOMEM_ERR_PTR(-EINVAL);
63 static inline u64 of_translate_address(struct device_node *np,
64 const __be32 *addr)
66 return OF_BAD_ADDR;
69 static inline const __be32 *of_get_address(struct device_node *dev, int index,
70 u64 *size, unsigned int *flags)
72 return NULL;
75 static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
76 struct device_node *node)
78 return -ENOSYS;
81 static inline int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
82 struct device_node *node)
84 return -ENOSYS;
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)
91 return NULL;
94 static inline bool of_dma_is_coherent(struct device_node *np)
96 return false;
98 #endif /* CONFIG_OF_ADDRESS */
100 #ifdef CONFIG_OF
101 extern int of_address_to_resource(struct device_node *dev, int index,
102 struct resource *r);
103 void __iomem *of_iomap(struct device_node *node, int index);
104 #else
105 static inline int of_address_to_resource(struct device_node *dev, int index,
106 struct resource *r)
108 return -EINVAL;
111 static inline void __iomem *of_iomap(struct device_node *device, int index)
113 return NULL;
115 #endif
117 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
118 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
119 u64 *size, unsigned int *flags);
120 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
121 struct resource *r);
122 extern int of_pci_range_to_resource(struct of_pci_range *range,
123 struct device_node *np,
124 struct resource *res);
125 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
126 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
127 struct resource *r)
129 return -ENOSYS;
132 static inline const __be32 *of_get_pci_address(struct device_node *dev,
133 int bar_no, u64 *size, unsigned int *flags)
135 return NULL;
137 static inline int of_pci_range_to_resource(struct of_pci_range *range,
138 struct device_node *np,
139 struct resource *res)
141 return -ENOSYS;
143 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
145 #endif /* __OF_ADDRESS_H */