blob: bd02b44902d041cf2d0841be779a0cd56c44b2c1 [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);
Robin Murphy53c92d72016-04-07 18:42:05 +010015extern const struct iommu_ops *of_iommu_configure(struct device *dev,
Murali Karicheried748622015-03-03 12:52:08 -050016 struct device_node *master_np);
Will Deacon1cd076b2014-08-27 14:40:58 +010017
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030018#else
19
20static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
21 int index, unsigned long *busno, dma_addr_t *addr,
22 size_t *size)
23{
24 return -EINVAL;
25}
26
Will Deacon1cd076b2014-08-27 14:40:58 +010027static inline void of_iommu_init(void) { }
Robin Murphy53c92d72016-04-07 18:42:05 +010028static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
Murali Karicheried748622015-03-03 12:52:08 -050029 struct device_node *master_np)
Will Deacon7eba1d52014-08-27 16:20:32 +010030{
31 return NULL;
32}
Will Deacon1cd076b2014-08-27 14:40:58 +010033
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030034#endif /* CONFIG_OF_IOMMU */
35
Robin Murphy53c92d72016-04-07 18:42:05 +010036void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops);
37const struct iommu_ops *of_iommu_get_ops(struct device_node *np);
Will Deacon1cd076b2014-08-27 14:40:58 +010038
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 */