blob: 5762cdc8effe4e9f9583a980273890a4c2c1130a [file] [log] [blame]
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03001#ifndef __OF_IOMMU_H
2#define __OF_IOMMU_H
3
Will Deacon1cd076b2014-08-27 14:40:58 +01004#include <linux/iommu.h>
5#include <linux/of.h>
6
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03007#ifdef CONFIG_OF_IOMMU
8
9extern 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 Deacon1cd076b2014-08-27 14:40:58 +010013extern void of_iommu_init(void);
14
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030015#else
16
17static 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 Deacon1cd076b2014-08-27 14:40:58 +010024static inline void of_iommu_init(void) { }
25
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030026#endif /* CONFIG_OF_IOMMU */
27
Will Deacon1cd076b2014-08-27 14:40:58 +010028static 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
34static inline struct iommu_ops *of_iommu_get_ops(struct device_node *np)
35{
36 return np->data;
37}
38
39extern struct of_device_id __iommu_of_table;
40
41typedef 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 Doyu4e0ee782012-06-25 14:23:54 +030046#endif /* __OF_IOMMU_H */