]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - include/linux/of_address.h
ARM: zynq: add clk binding support to the ttc
[can-eth-gw-linux.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 #ifdef CONFIG_OF_ADDRESS
8 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
9 extern bool of_can_translate_address(struct device_node *dev);
10 extern int of_address_to_resource(struct device_node *dev, int index,
11                                   struct resource *r);
12 extern 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);
16 extern void __iomem *of_iomap(struct device_node *device, int index);
17
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  */
22 extern const __be32 *of_get_address(struct device_node *dev, int index,
23                            u64 *size, unsigned int *flags);
24
25 #ifndef pci_address_to_pio
26 static 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 /* CONFIG_OF_ADDRESS */
31 static inline int of_address_to_resource(struct device_node *dev, int index,
32                                          struct resource *r)
33 {
34         return -EINVAL;
35 }
36 static inline struct device_node *of_find_matching_node_by_address(
37                                         struct device_node *from,
38                                         const struct of_device_id *matches,
39                                         u64 base_address)
40 {
41         return NULL;
42 }
43 static inline void __iomem *of_iomap(struct device_node *device, int index)
44 {
45         return NULL;
46 }
47 static inline const __be32 *of_get_address(struct device_node *dev, int index,
48                                         u64 *size, unsigned int *flags)
49 {
50         return NULL;
51 }
52 #endif /* CONFIG_OF_ADDRESS */
53
54
55 #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
56 extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
57                                u64 *size, unsigned int *flags);
58 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
59                                       struct resource *r);
60 #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
61 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
62                                              struct resource *r)
63 {
64         return -ENOSYS;
65 }
66
67 static inline const __be32 *of_get_pci_address(struct device_node *dev,
68                 int bar_no, u64 *size, unsigned int *flags)
69 {
70         return NULL;
71 }
72 #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
73
74 #endif /* __OF_ADDRESS_H */
75