blob: 16c75547d7253c579a031ac5e8db83b3e1a4a81a [file] [log] [blame]
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03001#ifndef __OF_IOMMU_H
2#define __OF_IOMMU_H
3
Will Deacon7eba1d52014-08-27 16:20:32 +01004#include <linux/device.h>
Will Deacon1cd076b2014-08-27 14:40:58 +01005#include <linux/iommu.h>
6#include <linux/of.h>
7
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03008#ifdef CONFIG_OF_IOMMU
9
10extern 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
Will Deacon1cd076b2014-08-27 14:40:58 +010014extern void of_iommu_init(void);
Will Deacon7eba1d52014-08-27 16:20:32 +010015extern struct iommu_ops *of_iommu_configure(struct device *dev);
Will Deacon1cd076b2014-08-27 14:40:58 +010016
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030017#else
18
19static 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
Will Deacon1cd076b2014-08-27 14:40:58 +010026static inline void of_iommu_init(void) { }
Will Deacon7eba1d52014-08-27 16:20:32 +010027static inline struct iommu_ops *of_iommu_configure(struct device *dev)
28{
29 return NULL;
30}
Will Deacon1cd076b2014-08-27 14:40:58 +010031
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030032#endif /* CONFIG_OF_IOMMU */
33
Robin Murphya42a7a12014-12-05 13:41:02 +000034void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops);
35struct iommu_ops *of_iommu_get_ops(struct device_node *np);
Will Deacon1cd076b2014-08-27 14:40:58 +010036
37extern struct of_device_id __iommu_of_table;
38
39typedef int (*of_iommu_init_fn)(struct device_node *);
40
41#define IOMMU_OF_DECLARE(name, compat, fn) \
42 _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn)
43
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030044#endif /* __OF_IOMMU_H */