iommu: provide early initialisation hook for IOMMU drivers
[firefly-linux-kernel-4.4.55.git] / include / linux / of_iommu.h
1 #ifndef __OF_IOMMU_H
2 #define __OF_IOMMU_H
3
4 #include <linux/iommu.h>
5 #include <linux/of.h>
6
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
13 extern void of_iommu_init(void);
14
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
24 static inline void of_iommu_init(void) { }
25
26 #endif  /* CONFIG_OF_IOMMU */
27
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
46 #endif /* __OF_IOMMU_H */