]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/of_address.h
HID: sony: Remove the size check for the Dualshock 4 HID Descriptor
[mirror_ubuntu-artful-kernel.git] / include / linux / of_address.h
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 struct 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
15 struct 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
26 /* Translate a DMA address from device space to CPU space */
27 extern u64 of_translate_dma_address(struct device_node *dev,
28 const __be32 *in_addr);
29
30 #ifdef CONFIG_OF_ADDRESS
31 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
32 extern int of_address_to_resource(struct device_node *dev, int index,
33 struct resource *r);
34 extern struct device_node *of_find_matching_node_by_address(
35 struct device_node *from,
36 const struct of_device_id *matches,
37 u64 base_address);
38 extern void __iomem *of_iomap(struct device_node *device, int index);
39
40 /* Extract an address from a device, returns the region size and
41 * the address space flags too. The PCI version uses a BAR number
42 * instead of an absolute index
43 */
44 extern const __be32 *of_get_address(struct device_node *dev, int index,
45 u64 *size, unsigned int *flags);
46
47 extern int pci_register_io_range(phys_addr_t addr, resource_size_t size);
48 extern unsigned long pci_address_to_pio(phys_addr_t addr);
49 extern phys_addr_t pci_pio_to_address(unsigned long pio);
50
51 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
52 struct device_node *node);
53 extern struct of_pci_range *of_pci_range_parser_one(
54 struct of_pci_range_parser *parser,
55 struct of_pci_range *range);
56 extern int of_dma_get_range(struct device_node *np, u64 *dma_addr,
57 u64 *paddr, u64 *size);
58 extern bool of_dma_is_coherent(struct device_node *np);
59 #else /* CONFIG_OF_ADDRESS */
60 static inline struct device_node *of_find_matching_node_by_address(
61 struct device_node *from,
62 const struct of_device_id *matches,
63 u64 base_address)
64 {
65 return NULL;
66 }
67
68 static inline const __be32 *of_get_address(struct device_node *dev, int index,
69 u64 *size, unsigned int *flags)
70 {
71 return NULL;
72 }
73
74 static inline phys_addr_t pci_pio_to_address(unsigned long pio)
75 {
76 return 0;
77 }
78
79 static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
80 struct device_node *node)
81 {
82 return -1;
83 }
84
85 static inline struct of_pci_range *of_pci_range_parser_one(
86 struct of_pci_range_parser *parser,
87 struct of_pci_range *range)
88 {
89 return NULL;
90 }
91
92 static inline int of_dma_get_range(struct device_node *np, u64 *dma_addr,
93 u64 *paddr, u64 *size)
94 {
95 return -ENODEV;
96 }
97
98 static inline bool of_dma_is_coherent(struct device_node *np)
99 {
100 return false;
101 }
102 #endif /* CONFIG_OF_ADDRESS */
103
104 #ifdef CONFIG_OF
105 extern int of_address_to_resource(struct device_node *dev, int index,
106 struct resource *r);
107 void __iomem *of_iomap(struct device_node *node, int index);
108 void __iomem *of_io_request_and_map(struct device_node *device,
109 int index, const char *name);
110 #else
111
112 #include <linux/io.h>
113
114 static inline int of_address_to_resource(struct device_node *dev, int index,
115 struct resource *r)
116 {
117 return -EINVAL;
118 }
119
120 static inline void __iomem *of_iomap(struct device_node *device, int index)
121 {
122 return NULL;
123 }
124
125 static inline void __iomem *of_io_request_and_map(struct device_node *device,
126 int index, const char *name)
127 {
128 return IOMEM_ERR_PTR(-EINVAL);
129 }
130 #endif
131
132 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
133 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
134 u64 *size, unsigned int *flags);
135 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
136 struct resource *r);
137 extern int of_pci_range_to_resource(struct of_pci_range *range,
138 struct device_node *np,
139 struct resource *res);
140 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
141 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
142 struct resource *r)
143 {
144 return -ENOSYS;
145 }
146
147 static inline const __be32 *of_get_pci_address(struct device_node *dev,
148 int bar_no, u64 *size, unsigned int *flags)
149 {
150 return NULL;
151 }
152 static inline int of_pci_range_to_resource(struct of_pci_range *range,
153 struct device_node *np,
154 struct resource *res)
155 {
156 return -ENOSYS;
157 }
158 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
159
160 #endif /* __OF_ADDRESS_H */
161