blob: cddfaff4d0b70ff112e72bc9125d2c2b45dc5fd2 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03002#ifndef __OF_IOMMU_H
3#define __OF_IOMMU_H
4
Will Deacon7eba1d52014-08-27 16:20:32 +01005#include <linux/device.h>
Will Deacon1cd076b2014-08-27 14:40:58 +01006#include <linux/iommu.h>
7#include <linux/of.h>
8
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +03009#ifdef CONFIG_OF_IOMMU
10
11extern int of_get_dma_window(struct device_node *dn, const char *prefix,
12 int index, unsigned long *busno, dma_addr_t *addr,
13 size_t *size);
14
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
Robin Murphy53c92d72016-04-07 18:42:05 +010027static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
Murali Karicheried748622015-03-03 12:52:08 -050028 struct device_node *master_np)
Will Deacon7eba1d52014-08-27 16:20:32 +010029{
30 return NULL;
31}
Will Deacon1cd076b2014-08-27 14:40:58 +010032
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030033#endif /* CONFIG_OF_IOMMU */
34
Will Deacon1cd076b2014-08-27 14:40:58 +010035extern struct of_device_id __iommu_of_table;
36
37typedef int (*of_iommu_init_fn)(struct device_node *);
38
39#define IOMMU_OF_DECLARE(name, compat, fn) \
40 _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn)
41
Hiroshi Doyu4e0ee782012-06-25 14:23:54 +030042#endif /* __OF_IOMMU_H */