1#ifndef __OF_ADDRESS_H
2#define __OF_ADDRESS_H
3#include <linux/ioport.h>
4#include <linux/errno.h>
5#include <linux/of.h>
6
7#ifdef CONFIG_OF_ADDRESS
8extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
9extern bool of_can_translate_address(struct device_node *dev);
10extern int of_address_to_resource(struct device_node *dev, int index,
11 struct resource *r);
12extern struct device_node *of_find_matching_node_by_address(
13 struct device_node *from,
14 const struct of_device_id *matches,
15 u64 base_address);
16extern void __iomem *of_iomap(struct device_node *device, int index);
17
18
19
20
21
22extern const __be32 *of_get_address(struct device_node *dev, int index,
23 u64 *size, unsigned int *flags);
24
25#ifndef pci_address_to_pio
26static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
27#define pci_address_to_pio pci_address_to_pio
28#endif
29
30#else
31#ifndef of_address_to_resource
32static inline int of_address_to_resource(struct device_node *dev, int index,
33 struct resource *r)
34{
35 return -EINVAL;
36}
37#endif
38static inline struct device_node *of_find_matching_node_by_address(
39 struct device_node *from,
40 const struct of_device_id *matches,
41 u64 base_address)
42{
43 return NULL;
44}
45#ifndef of_iomap
46static inline void __iomem *of_iomap(struct device_node *device, int index)
47{
48 return NULL;
49}
50#endif
51static inline const __be32 *of_get_address(struct device_node *dev, int index,
52 u64 *size, unsigned int *flags)
53{
54 return NULL;
55}
56#endif
57
58
59#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
60extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
61 u64 *size, unsigned int *flags);
62extern int of_pci_address_to_resource(struct device_node *dev, int bar,
63 struct resource *r);
64#else
65static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
66 struct resource *r)
67{
68 return -ENOSYS;
69}
70
71static inline const __be32 *of_get_pci_address(struct device_node *dev,
72 int bar_no, u64 *size, unsigned int *flags)
73{
74 return NULL;
75}
76#endif
77
78#endif
79
80