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 | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame^] | 4 | #include <linux/iommu.h> |
| 5 | #include <linux/of.h> |
| 6 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 7 | #ifdef CONFIG_OF_IOMMU |
| 8 | |
| 9 | extern int of_get_dma_window(struct device_node *dn, const char *prefix, |
| 10 | int index, unsigned long *busno, dma_addr_t *addr, |
| 11 | size_t *size); |
| 12 | |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame^] | 13 | extern void of_iommu_init(void); |
| 14 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 15 | #else |
| 16 | |
| 17 | static inline int of_get_dma_window(struct device_node *dn, const char *prefix, |
| 18 | int index, unsigned long *busno, dma_addr_t *addr, |
| 19 | size_t *size) |
| 20 | { |
| 21 | return -EINVAL; |
| 22 | } |
| 23 | |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame^] | 24 | static inline void of_iommu_init(void) { } |
| 25 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 26 | #endif /* CONFIG_OF_IOMMU */ |
| 27 | |
Will Deacon | 1cd076b | 2014-08-27 14:40:58 +0100 | [diff] [blame^] | 28 | static inline void of_iommu_set_ops(struct device_node *np, |
| 29 | const struct iommu_ops *ops) |
| 30 | { |
| 31 | np->data = (struct iommu_ops *)ops; |
| 32 | } |
| 33 | |
| 34 | static inline struct iommu_ops *of_iommu_get_ops(struct device_node *np) |
| 35 | { |
| 36 | return np->data; |
| 37 | } |
| 38 | |
| 39 | extern struct of_device_id __iommu_of_table; |
| 40 | |
| 41 | typedef int (*of_iommu_init_fn)(struct device_node *); |
| 42 | |
| 43 | #define IOMMU_OF_DECLARE(name, compat, fn) \ |
| 44 | _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn) |
| 45 | |
Hiroshi Doyu | 4e0ee78 | 2012-06-25 14:23:54 +0300 | [diff] [blame] | 46 | #endif /* __OF_IOMMU_H */ |