Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 1 | #ifndef __OF_IOMMU_H |
| 2 | #define __OF_IOMMU_H |
| 3 | |
Will Deacon | 7eba1d5 | 2014-08-27 16:20:32 +0100 | [diff] [blame] | 4 | #include <linux/device.h> |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame] | 5 | #include <linux/iommu.h> |
| 6 | #include <linux/of.h> |
| 7 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 8 | #ifdef CONFIG_OF_IOMMU |
| 9 | |
| 10 | extern int of_get_dma_window(struct device_node *dn, const char *prefix, |
| 11 | int index, unsigned long *busno, dma_addr_t *addr, |
| 12 | size_t *size); |
| 13 | |
Robin Murphy | 53c92d7 | 2016-04-07 18:42:05 +0100 | [diff] [blame] | 14 | extern const struct iommu_ops *of_iommu_configure(struct device *dev, |
Murali Karicheri | ed74862 | 2015-03-03 12:52:08 -0500 | [diff] [blame] | 15 | struct device_node *master_np); |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame] | 16 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 17 | #else |
| 18 | |
| 19 | static inline int of_get_dma_window(struct device_node *dn, const char *prefix, |
| 20 | int index, unsigned long *busno, dma_addr_t *addr, |
| 21 | size_t *size) |
| 22 | { |
| 23 | return -EINVAL; |
| 24 | } |
| 25 | |
Robin Murphy | 53c92d7 | 2016-04-07 18:42:05 +0100 | [diff] [blame] | 26 | static inline const struct iommu_ops *of_iommu_configure(struct device *dev, |
Murali Karicheri | ed74862 | 2015-03-03 12:52:08 -0500 | [diff] [blame] | 27 | struct device_node *master_np) |
Will Deacon | 7eba1d5 | 2014-08-27 16:20:32 +0100 | [diff] [blame] | 28 | { |
| 29 | return NULL; |
| 30 | } |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame] | 31 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 32 | #endif /* CONFIG_OF_IOMMU */ |
| 33 | |
Lorenzo Pieralisi | e4f10ff | 2016-11-21 10:01:36 +0000 | [diff] [blame] | 34 | static inline void of_iommu_set_ops(struct device_node *np, |
| 35 | const struct iommu_ops *ops) |
| 36 | { |
| 37 | iommu_register_instance(&np->fwnode, ops); |
| 38 | } |
| 39 | |
| 40 | static inline const struct iommu_ops *of_iommu_get_ops(struct device_node *np) |
| 41 | { |
| 42 | return iommu_get_instance(&np->fwnode); |
| 43 | } |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame] | 44 | |
| 45 | extern struct of_device_id __iommu_of_table; |
| 46 | |
| 47 | typedef int (*of_iommu_init_fn)(struct device_node *); |
| 48 | |
| 49 | #define IOMMU_OF_DECLARE(name, compat, fn) \ |
| 50 | _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn) |
| 51 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 52 | #endif /* __OF_IOMMU_H */ |