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); |
Stephen Warren | 5d61b16 | 2012-07-25 17:34:37 -0600 | [diff] [blame] | 9 | extern bool of_can_translate_address(struct device_node *dev); |
Grant Likely | 1f5bef3 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 10 | extern int of_address_to_resource(struct device_node *dev, int index, |
| 11 | struct resource *r); |
Grant Likely | 90e33f6 | 2011-07-05 23:42:28 -0600 | [diff] [blame] | 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); |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 16 | extern void __iomem *of_iomap(struct device_node *device, int index); |
| 17 | |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 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 | */ |
Kim Phillips | 47b1e68 | 2012-10-08 19:41:58 -0500 | [diff] [blame] | 22 | extern const __be32 *of_get_address(struct device_node *dev, int index, |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 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 | |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 30 | #else /* CONFIG_OF_ADDRESS */ |
Andreas Larsson | 0bce04b | 2012-11-06 00:12:03 +0000 | [diff] [blame] | 31 | #ifndef of_address_to_resource |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 32 | static inline int of_address_to_resource(struct device_node *dev, int index, |
| 33 | struct resource *r) |
| 34 | { |
| 35 | return -EINVAL; |
| 36 | } |
Andreas Larsson | 0bce04b | 2012-11-06 00:12:03 +0000 | [diff] [blame] | 37 | #endif |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 38 | static 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 | } |
| 45 | static inline void __iomem *of_iomap(struct device_node *device, int index) |
| 46 | { |
| 47 | return NULL; |
| 48 | } |
Kim Phillips | 47b1e68 | 2012-10-08 19:41:58 -0500 | [diff] [blame] | 49 | static inline const __be32 *of_get_address(struct device_node *dev, int index, |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 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) |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 58 | 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] | 59 | u64 *size, unsigned int *flags); |
| 60 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 61 | struct resource *r); |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 62 | #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 63 | static inline int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 64 | struct resource *r) |
| 65 | { |
| 66 | return -ENOSYS; |
| 67 | } |
| 68 | |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 69 | static inline const __be32 *of_get_pci_address(struct device_node *dev, |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 70 | int bar_no, u64 *size, unsigned int *flags) |
| 71 | { |
| 72 | return NULL; |
| 73 | } |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 74 | #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 75 | |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 76 | #endif /* __OF_ADDRESS_H */ |
| 77 | |