Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 1 | #ifndef __OF_ADDRESS_H |
| 2 | #define __OF_ADDRESS_H |
| 3 | #include <linux/ioport.h> |
Grant Likely | 99ce39e | 2011-07-05 23:42:37 -0600 | [diff] [blame] | 4 | #include <linux/errno.h> |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 5 | #include <linux/of.h> |
| 6 | |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 7 | #ifdef CONFIG_OF_ADDRESS |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 8 | extern u64 of_translate_address(struct device_node *np, const __be32 *addr); |
Grant Likely | 1f5bef3 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 9 | extern int of_address_to_resource(struct device_node *dev, int index, |
| 10 | struct resource *r); |
Grant Likely | 90e33f6 | 2011-07-05 23:42:28 -0600 | [diff] [blame] | 11 | extern struct device_node *of_find_matching_node_by_address( |
| 12 | struct device_node *from, |
| 13 | const struct of_device_id *matches, |
| 14 | u64 base_address); |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 15 | extern void __iomem *of_iomap(struct device_node *device, int index); |
| 16 | |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 17 | /* Extract an address from a device, returns the region size and |
| 18 | * the address space flags too. The PCI version uses a BAR number |
| 19 | * instead of an absolute index |
| 20 | */ |
| 21 | extern const u32 *of_get_address(struct device_node *dev, int index, |
| 22 | u64 *size, unsigned int *flags); |
| 23 | |
| 24 | #ifndef pci_address_to_pio |
| 25 | static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } |
| 26 | #define pci_address_to_pio pci_address_to_pio |
| 27 | #endif |
| 28 | |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 29 | #else /* CONFIG_OF_ADDRESS */ |
| 30 | static inline int of_address_to_resource(struct device_node *dev, int index, |
| 31 | struct resource *r) |
| 32 | { |
| 33 | return -EINVAL; |
| 34 | } |
| 35 | static inline struct device_node *of_find_matching_node_by_address( |
| 36 | struct device_node *from, |
| 37 | const struct of_device_id *matches, |
| 38 | u64 base_address) |
| 39 | { |
| 40 | return NULL; |
| 41 | } |
| 42 | static inline void __iomem *of_iomap(struct device_node *device, int index) |
| 43 | { |
| 44 | return NULL; |
| 45 | } |
| 46 | static inline const u32 *of_get_address(struct device_node *dev, int index, |
| 47 | u64 *size, unsigned int *flags) |
| 48 | { |
| 49 | return NULL; |
| 50 | } |
| 51 | #endif /* CONFIG_OF_ADDRESS */ |
| 52 | |
| 53 | |
| 54 | #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI) |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 55 | extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 56 | u64 *size, unsigned int *flags); |
| 57 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 58 | struct resource *r); |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 59 | #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 60 | static inline int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 61 | struct resource *r) |
| 62 | { |
| 63 | return -ENOSYS; |
| 64 | } |
| 65 | |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 66 | static inline const __be32 *of_get_pci_address(struct device_node *dev, |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 67 | int bar_no, u64 *size, unsigned int *flags) |
| 68 | { |
| 69 | return NULL; |
| 70 | } |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 71 | #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 72 | |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 73 | #endif /* __OF_ADDRESS_H */ |
| 74 | |