Kill indirect include of file.h from eventfd.h, use fdget() in cgroup.c
[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
29b635c0
AM
7struct of_pci_range_parser {
8 struct device_node *node;
9 const __be32 *range;
10 const __be32 *end;
11 int np;
12 int pna;
13};
14
15struct of_pci_range {
16 u32 pci_space;
17 u64 pci_addr;
18 u64 cpu_addr;
19 u64 size;
20 u32 flags;
21};
22
23#define for_each_of_pci_range(parser, range) \
24 for (; of_pci_range_parser_one(parser, range);)
25
26static inline void of_pci_range_to_resource(struct of_pci_range *range,
27 struct device_node *np,
28 struct resource *res)
29{
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;
35}
36
a850a755 37#ifdef CONFIG_OF_ADDRESS
0131d897 38extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
5d61b165 39extern bool of_can_translate_address(struct device_node *dev);
1f5bef30
GL
40extern int of_address_to_resource(struct device_node *dev, int index,
41 struct resource *r);
90e33f62
GL
42extern struct device_node *of_find_matching_node_by_address(
43 struct device_node *from,
44 const struct of_device_id *matches,
45 u64 base_address);
6b884a8d
GL
46extern void __iomem *of_iomap(struct device_node *device, int index);
47
22ae782f
GL
48/* Extract an address from a device, returns the region size and
49 * the address space flags too. The PCI version uses a BAR number
50 * instead of an absolute index
51 */
47b1e689 52extern const __be32 *of_get_address(struct device_node *dev, int index,
22ae782f
GL
53 u64 *size, unsigned int *flags);
54
55#ifndef pci_address_to_pio
56static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
57#define pci_address_to_pio pci_address_to_pio
58#endif
59
29b635c0
AM
60extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
61 struct device_node *node);
62extern struct of_pci_range *of_pci_range_parser_one(
63 struct of_pci_range_parser *parser,
64 struct of_pci_range *range);
a850a755 65#else /* CONFIG_OF_ADDRESS */
0bce04be 66#ifndef of_address_to_resource
a850a755
GL
67static inline int of_address_to_resource(struct device_node *dev, int index,
68 struct resource *r)
69{
70 return -EINVAL;
71}
0bce04be 72#endif
a850a755
GL
73static inline struct device_node *of_find_matching_node_by_address(
74 struct device_node *from,
75 const struct of_device_id *matches,
76 u64 base_address)
77{
78 return NULL;
79}
0e622d39 80#ifndef of_iomap
a850a755
GL
81static inline void __iomem *of_iomap(struct device_node *device, int index)
82{
83 return NULL;
84}
0e622d39 85#endif
47b1e689 86static inline const __be32 *of_get_address(struct device_node *dev, int index,
a850a755
GL
87 u64 *size, unsigned int *flags)
88{
89 return NULL;
90}
29b635c0
AM
91
92static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
93 struct device_node *node)
94{
95 return -1;
96}
97
98static inline struct of_pci_range *of_pci_range_parser_one(
99 struct of_pci_range_parser *parser,
100 struct of_pci_range *range)
101{
102 return NULL;
103}
a850a755
GL
104#endif /* CONFIG_OF_ADDRESS */
105
106
107#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
0131d897 108extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
22ae782f
GL
109 u64 *size, unsigned int *flags);
110extern int of_pci_address_to_resource(struct device_node *dev, int bar,
111 struct resource *r);
a850a755 112#else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
22ae782f
GL
113static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
114 struct resource *r)
115{
116 return -ENOSYS;
117}
118
0131d897 119static inline const __be32 *of_get_pci_address(struct device_node *dev,
22ae782f
GL
120 int bar_no, u64 *size, unsigned int *flags)
121{
122 return NULL;
123}
a850a755 124#endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
22ae782f 125
6b884a8d
GL
126#endif /* __OF_ADDRESS_H */
127