Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6-block.git] / include / linux / of_address.h
CommitLineData
6b884a8d
GL
1#ifndef __OF_ADDRESS_H
2#define __OF_ADDRESS_H
3#include <linux/ioport.h>
99ce39e3 4#include <linux/errno.h>
6b884a8d
GL
5#include <linux/of.h>
6
a850a755 7#ifdef CONFIG_OF_ADDRESS
0131d897 8extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
5d61b165 9extern bool of_can_translate_address(struct device_node *dev);
1f5bef30
GL
10extern int of_address_to_resource(struct device_node *dev, int index,
11 struct resource *r);
90e33f62
GL
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);
6b884a8d
GL
16extern void __iomem *of_iomap(struct device_node *device, int index);
17
22ae782f
GL
18/* Extract an address from a device, returns the region size and
19 * the address space flags too. The PCI version uses a BAR number
20 * instead of an absolute index
21 */
47b1e689 22extern const __be32 *of_get_address(struct device_node *dev, int index,
22ae782f
GL
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
a850a755 30#else /* CONFIG_OF_ADDRESS */
0bce04be 31#ifndef of_address_to_resource
a850a755
GL
32static inline int of_address_to_resource(struct device_node *dev, int index,
33 struct resource *r)
34{
35 return -EINVAL;
36}
0bce04be 37#endif
a850a755
GL
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}
45static inline void __iomem *of_iomap(struct device_node *device, int index)
46{
47 return NULL;
48}
47b1e689 49static inline const __be32 *of_get_address(struct device_node *dev, int index,
a850a755
GL
50 u64 *size, unsigned int *flags)
51{
52 return NULL;
53}
54#endif /* CONFIG_OF_ADDRESS */
55
56
57#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
0131d897 58extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
22ae782f
GL
59 u64 *size, unsigned int *flags);
60extern int of_pci_address_to_resource(struct device_node *dev, int bar,
61 struct resource *r);
a850a755 62#else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
22ae782f
GL
63static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
64 struct resource *r)
65{
66 return -ENOSYS;
67}
68
0131d897 69static inline const __be32 *of_get_pci_address(struct device_node *dev,
22ae782f
GL
70 int bar_no, u64 *size, unsigned int *flags)
71{
72 return NULL;
73}
a850a755 74#endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
22ae782f 75
6b884a8d
GL
76#endif /* __OF_ADDRESS_H */
77