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 | } |
Andreas Larsson | 0e622d3 | 2012-11-23 12:24:09 +0100 | [diff] [blame] | 45 | #ifndef of_iomap |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 46 | static inline void __iomem *of_iomap(struct device_node *device, int index) |
| 47 | { |
| 48 | return NULL; |
| 49 | } |
Andreas Larsson | 0e622d3 | 2012-11-23 12:24:09 +0100 | [diff] [blame] | 50 | #endif |
Kim Phillips | 47b1e68 | 2012-10-08 19:41:58 -0500 | [diff] [blame] | 51 | 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] | 52 | u64 *size, unsigned int *flags) |
| 53 | { |
| 54 | return NULL; |
| 55 | } |
| 56 | #endif /* CONFIG_OF_ADDRESS */ |
| 57 | |
| 58 | |
| 59 | #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI) |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 60 | 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] | 61 | u64 *size, unsigned int *flags); |
| 62 | extern int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 63 | struct resource *r); |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 64 | #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 65 | static inline int of_pci_address_to_resource(struct device_node *dev, int bar, |
| 66 | struct resource *r) |
| 67 | { |
| 68 | return -ENOSYS; |
| 69 | } |
| 70 | |
Sebastian Andrzej Siewior | 0131d89 | 2010-12-01 10:54:46 +0100 | [diff] [blame] | 71 | static inline const __be32 *of_get_pci_address(struct device_node *dev, |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 72 | int bar_no, u64 *size, unsigned int *flags) |
| 73 | { |
| 74 | return NULL; |
| 75 | } |
Grant Likely | a850a75 | 2012-02-14 14:06:55 -0700 | [diff] [blame] | 76 | #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */ |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 77 | |
Grant Likely | 6b884a8 | 2010-06-08 07:48:09 -0600 | [diff] [blame] | 78 | #endif /* __OF_ADDRESS_H */ |
| 79 | |