aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/dma-mapping.h12
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/arm/mm/dma-mapping.c83
-rw-r--r--drivers/iommu/Kconfig2
-rw-r--r--drivers/iommu/iommu.c2
-rw-r--r--drivers/iommu/of_iommu.c89
-rw-r--r--drivers/of/platform.c50
-rw-r--r--include/asm-generic/vmlinux.lds.h2
-rw-r--r--include/linux/dma-mapping.h13
-rw-r--r--include/linux/iommu.h8
-rw-r--r--include/linux/of_iommu.h23
11 files changed, 242 insertions, 44 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 85738b200023..9410b7e548fc 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -121,12 +121,12 @@ static inline unsigned long dma_max_pfn(struct device *dev)
121} 121}
122#define dma_max_pfn(dev) dma_max_pfn(dev) 122#define dma_max_pfn(dev) dma_max_pfn(dev)
123 123
124static inline int set_arch_dma_coherent_ops(struct device *dev) 124#define arch_setup_dma_ops arch_setup_dma_ops
125{ 125extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
126 set_dma_ops(dev, &arm_coherent_dma_ops); 126 struct iommu_ops *iommu, bool coherent);
127 return 0; 127
128} 128#define arch_teardown_dma_ops arch_teardown_dma_ops
129#define set_arch_dma_coherent_ops(dev) set_arch_dma_coherent_ops(dev) 129extern void arch_teardown_dma_ops(struct device *dev);
130 130
131static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 131static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
132{ 132{
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index c03106378b49..1cfc94aa7fa2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -18,6 +18,7 @@
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/screen_info.h> 20#include <linux/screen_info.h>
21#include <linux/of_iommu.h>
21#include <linux/of_platform.h> 22#include <linux/of_platform.h>
22#include <linux/init.h> 23#include <linux/init.h>
23#include <linux/kexec.h> 24#include <linux/kexec.h>
@@ -806,6 +807,7 @@ static int __init customize_machine(void)
806 * machine from the device tree, if no callback is provided, 807 * machine from the device tree, if no callback is provided,
807 * otherwise we would always need an init_machine callback. 808 * otherwise we would always need an init_machine callback.
808 */ 809 */
810 of_iommu_init();
809 if (machine_desc->init_machine) 811 if (machine_desc->init_machine)
810 machine_desc->init_machine(); 812 machine_desc->init_machine();
811#ifdef CONFIG_OF 813#ifdef CONFIG_OF
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index e8907117861e..09645f00bd17 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1947,9 +1947,8 @@ EXPORT_SYMBOL_GPL(arm_iommu_release_mapping);
1947 * arm_iommu_create_mapping) 1947 * arm_iommu_create_mapping)
1948 * 1948 *
1949 * Attaches specified io address space mapping to the provided device, 1949 * Attaches specified io address space mapping to the provided device,
1950 * this replaces the dma operations (dma_map_ops pointer) with the 1950 * More than one client might be attached to the same io address space
1951 * IOMMU aware version. More than one client might be attached to 1951 * mapping.
1952 * the same io address space mapping.
1953 */ 1952 */
1954int arm_iommu_attach_device(struct device *dev, 1953int arm_iommu_attach_device(struct device *dev,
1955 struct dma_iommu_mapping *mapping) 1954 struct dma_iommu_mapping *mapping)
@@ -1962,7 +1961,6 @@ int arm_iommu_attach_device(struct device *dev,
1962 1961
1963 kref_get(&mapping->kref); 1962 kref_get(&mapping->kref);
1964 dev->archdata.mapping = mapping; 1963 dev->archdata.mapping = mapping;
1965 set_dma_ops(dev, &iommu_ops);
1966 1964
1967 pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev)); 1965 pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev));
1968 return 0; 1966 return 0;
@@ -1974,7 +1972,6 @@ EXPORT_SYMBOL_GPL(arm_iommu_attach_device);
1974 * @dev: valid struct device pointer 1972 * @dev: valid struct device pointer
1975 * 1973 *
1976 * Detaches the provided device from a previously attached map. 1974 * Detaches the provided device from a previously attached map.
1977 * This voids the dma operations (dma_map_ops pointer)
1978 */ 1975 */
1979void arm_iommu_detach_device(struct device *dev) 1976void arm_iommu_detach_device(struct device *dev)
1980{ 1977{
@@ -1989,10 +1986,82 @@ void arm_iommu_detach_device(struct device *dev)
1989 iommu_detach_device(mapping->domain, dev); 1986 iommu_detach_device(mapping->domain, dev);
1990 kref_put(&mapping->kref, release_iommu_mapping); 1987 kref_put(&mapping->kref, release_iommu_mapping);
1991 dev->archdata.mapping = NULL; 1988 dev->archdata.mapping = NULL;
1992 set_dma_ops(dev, NULL);
1993 1989
1994 pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev)); 1990 pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
1995} 1991}
1996EXPORT_SYMBOL_GPL(arm_iommu_detach_device); 1992EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
1997 1993
1998#endif 1994static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
1995{
1996 return coherent ? &iommu_coherent_ops : &iommu_ops;
1997}
1998
1999static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
2000 struct iommu_ops *iommu)
2001{
2002 struct dma_iommu_mapping *mapping;
2003
2004 if (!iommu)
2005 return false;
2006
2007 mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
2008 if (IS_ERR(mapping)) {
2009 pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
2010 size, dev_name(dev));
2011 return false;
2012 }
2013
2014 if (arm_iommu_attach_device(dev, mapping)) {
2015 pr_warn("Failed to attached device %s to IOMMU_mapping\n",
2016 dev_name(dev));
2017 arm_iommu_release_mapping(mapping);
2018 return false;
2019 }
2020
2021 return true;
2022}
2023
2024static void arm_teardown_iommu_dma_ops(struct device *dev)
2025{
2026 struct dma_iommu_mapping *mapping = dev->archdata.mapping;
2027
2028 arm_iommu_detach_device(dev);
2029 arm_iommu_release_mapping(mapping);
2030}
2031
2032#else
2033
2034static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
2035 struct iommu_ops *iommu)
2036{
2037 return false;
2038}
2039
2040static void arm_teardown_iommu_dma_ops(struct device *dev) { }
2041
2042#define arm_get_iommu_dma_map_ops arm_get_dma_map_ops
2043
2044#endif /* CONFIG_ARM_DMA_USE_IOMMU */
2045
2046static struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2047{
2048 return coherent ? &arm_coherent_dma_ops : &arm_dma_ops;
2049}
2050
2051void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
2052 struct iommu_ops *iommu, bool coherent)
2053{
2054 struct dma_map_ops *dma_ops;
2055
2056 if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu))
2057 dma_ops = arm_get_iommu_dma_map_ops(coherent);
2058 else
2059 dma_ops = arm_get_dma_map_ops(coherent);
2060
2061 set_dma_ops(dev, dma_ops);
2062}
2063
2064void arch_teardown_dma_ops(struct device *dev)
2065{
2066 arm_teardown_iommu_dma_ops(dev);
2067}
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index dd5112265cc9..6d13f962f156 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -15,7 +15,7 @@ if IOMMU_SUPPORT
15 15
16config OF_IOMMU 16config OF_IOMMU
17 def_bool y 17 def_bool y
18 depends on OF 18 depends on OF && IOMMU_API
19 19
20config FSL_PAMU 20config FSL_PAMU
21 bool "Freescale IOMMU support" 21 bool "Freescale IOMMU support"
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ed8b04867b1f..02f798b7e295 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -737,7 +737,7 @@ static int add_iommu_group(struct device *dev, void *data)
737 const struct iommu_ops *ops = cb->ops; 737 const struct iommu_ops *ops = cb->ops;
738 738
739 if (!ops->add_device) 739 if (!ops->add_device)
740 return -ENODEV; 740 return 0;
741 741
742 WARN_ON(dev->iommu_group); 742 WARN_ON(dev->iommu_group);
743 743
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index e550ccb7634e..af1dc6a1c0a1 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -18,9 +18,14 @@
18 */ 18 */
19 19
20#include <linux/export.h> 20#include <linux/export.h>
21#include <linux/iommu.h>
21#include <linux/limits.h> 22#include <linux/limits.h>
22#include <linux/of.h> 23#include <linux/of.h>
23#include <linux/of_iommu.h> 24#include <linux/of_iommu.h>
25#include <linux/slab.h>
26
27static const struct of_device_id __iommu_of_table_sentinel
28 __used __section(__iommu_of_table_end);
24 29
25/** 30/**
26 * of_get_dma_window - Parse *dma-window property and returns 0 if found. 31 * of_get_dma_window - Parse *dma-window property and returns 0 if found.
@@ -89,3 +94,87 @@ int of_get_dma_window(struct device_node *dn, const char *prefix, int index,
89 return 0; 94 return 0;
90} 95}
91EXPORT_SYMBOL_GPL(of_get_dma_window); 96EXPORT_SYMBOL_GPL(of_get_dma_window);
97
98struct of_iommu_node {
99 struct list_head list;
100 struct device_node *np;
101 struct iommu_ops *ops;
102};
103static LIST_HEAD(of_iommu_list);
104static DEFINE_SPINLOCK(of_iommu_lock);
105
106void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops)
107{
108 struct of_iommu_node *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
109
110 if (WARN_ON(!iommu))
111 return;
112
113 INIT_LIST_HEAD(&iommu->list);
114 iommu->np = np;
115 iommu->ops = ops;
116 spin_lock(&of_iommu_lock);
117 list_add_tail(&iommu->list, &of_iommu_list);
118 spin_unlock(&of_iommu_lock);
119}
120
121struct iommu_ops *of_iommu_get_ops(struct device_node *np)
122{
123 struct of_iommu_node *node;
124 struct iommu_ops *ops = NULL;
125
126 spin_lock(&of_iommu_lock);
127 list_for_each_entry(node, &of_iommu_list, list)
128 if (node->np == np) {
129 ops = node->ops;
130 break;
131 }
132 spin_unlock(&of_iommu_lock);
133 return ops;
134}
135
136struct iommu_ops *of_iommu_configure(struct device *dev)
137{
138 struct of_phandle_args iommu_spec;
139 struct device_node *np;
140 struct iommu_ops *ops = NULL;
141 int idx = 0;
142
143 /*
144 * We don't currently walk up the tree looking for a parent IOMMU.
145 * See the `Notes:' section of
146 * Documentation/devicetree/bindings/iommu/iommu.txt
147 */
148 while (!of_parse_phandle_with_args(dev->of_node, "iommus",
149 "#iommu-cells", idx,
150 &iommu_spec)) {
151 np = iommu_spec.np;
152 ops = of_iommu_get_ops(np);
153
154 if (!ops || !ops->of_xlate || ops->of_xlate(dev, &iommu_spec))
155 goto err_put_node;
156
157 of_node_put(np);
158 idx++;
159 }
160
161 return ops;
162
163err_put_node:
164 of_node_put(np);
165 return NULL;
166}
167
168void __init of_iommu_init(void)
169{
170 struct device_node *np;
171 const struct of_device_id *match, *matches = &__iommu_of_table;
172
173 for_each_matching_node_and_match(np, matches, &match) {
174 const of_iommu_init_fn init_fn = match->data;
175
176 if (init_fn(np))
177 pr_err("Failed to initialise IOMMU %s\n",
178 of_node_full_name(np));
179 }
180}
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 3b64d0bf5bba..b89caf8c7586 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -19,6 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/of_address.h> 20#include <linux/of_address.h>
21#include <linux/of_device.h> 21#include <linux/of_device.h>
22#include <linux/of_iommu.h>
22#include <linux/of_irq.h> 23#include <linux/of_irq.h>
23#include <linux/of_platform.h> 24#include <linux/of_platform.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
@@ -164,6 +165,9 @@ static void of_dma_configure(struct device *dev)
164{ 165{
165 u64 dma_addr, paddr, size; 166 u64 dma_addr, paddr, size;
166 int ret; 167 int ret;
168 bool coherent;
169 unsigned long offset;
170 struct iommu_ops *iommu;
167 171
168 /* 172 /*
169 * Set default dma-mask to 32 bit. Drivers are expected to setup 173 * Set default dma-mask to 32 bit. Drivers are expected to setup
@@ -178,28 +182,30 @@ static void of_dma_configure(struct device *dev)
178 if (!dev->dma_mask) 182 if (!dev->dma_mask)
179 dev->dma_mask = &dev->coherent_dma_mask; 183 dev->dma_mask = &dev->coherent_dma_mask;
180 184
181 /*
182 * if dma-coherent property exist, call arch hook to setup
183 * dma coherent operations.
184 */
185 if (of_dma_is_coherent(dev->of_node)) {
186 set_arch_dma_coherent_ops(dev);
187 dev_dbg(dev, "device is dma coherent\n");
188 }
189
190 /*
191 * if dma-ranges property doesn't exist - just return else
192 * setup the dma offset
193 */
194 ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); 185 ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size);
195 if (ret < 0) { 186 if (ret < 0) {
196 dev_dbg(dev, "no dma range information to setup\n"); 187 dma_addr = offset = 0;
197 return; 188 size = dev->coherent_dma_mask;
189 } else {
190 offset = PFN_DOWN(paddr - dma_addr);
191 dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset);
198 } 192 }
193 dev->dma_pfn_offset = offset;
194
195 coherent = of_dma_is_coherent(dev->of_node);
196 dev_dbg(dev, "device is%sdma coherent\n",
197 coherent ? " " : " not ");
198
199 iommu = of_iommu_configure(dev);
200 dev_dbg(dev, "device is%sbehind an iommu\n",
201 iommu ? " " : " not ");
199 202
200 /* DMA ranges found. Calculate and set dma_pfn_offset */ 203 arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
201 dev->dma_pfn_offset = PFN_DOWN(paddr - dma_addr); 204}
202 dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); 205
206static void of_dma_deconfigure(struct device *dev)
207{
208 arch_teardown_dma_ops(dev);
203} 209}
204 210
205/** 211/**
@@ -228,16 +234,12 @@ static struct platform_device *of_platform_device_create_pdata(
228 if (!dev) 234 if (!dev)
229 goto err_clear_flag; 235 goto err_clear_flag;
230 236
231 of_dma_configure(&dev->dev);
232 dev->dev.bus = &platform_bus_type; 237 dev->dev.bus = &platform_bus_type;
233 dev->dev.platform_data = platform_data; 238 dev->dev.platform_data = platform_data;
234 239 of_dma_configure(&dev->dev);
235 /* We do not fill the DMA ops for platform devices by default.
236 * This is currently the responsibility of the platform code
237 * to do such, possibly using a device notifier
238 */
239 240
240 if (of_device_add(dev) != 0) { 241 if (of_device_add(dev) != 0) {
242 of_dma_deconfigure(&dev->dev);
241 platform_device_put(dev); 243 platform_device_put(dev);
242 goto err_clear_flag; 244 goto err_clear_flag;
243 } 245 }
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index aa70cbda327c..bee5d683074d 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -164,6 +164,7 @@
164#define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) 164#define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
165#define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) 165#define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
166#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 166#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
167#define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu)
167#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 168#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
168#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 169#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
169#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) 170#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
@@ -497,6 +498,7 @@
497 CLK_OF_TABLES() \ 498 CLK_OF_TABLES() \
498 RESERVEDMEM_OF_TABLES() \ 499 RESERVEDMEM_OF_TABLES() \
499 CLKSRC_OF_TABLES() \ 500 CLKSRC_OF_TABLES() \
501 IOMMU_OF_TABLES() \
500 CPU_METHOD_OF_TABLES() \ 502 CPU_METHOD_OF_TABLES() \
501 KERNEL_DTB() \ 503 KERNEL_DTB() \
502 IRQCHIP_OF_MATCH_TABLE() \ 504 IRQCHIP_OF_MATCH_TABLE() \
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index d5d388160f42..c3007cb4bfa6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -129,11 +129,14 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
129 129
130extern u64 dma_get_required_mask(struct device *dev); 130extern u64 dma_get_required_mask(struct device *dev);
131 131
132#ifndef set_arch_dma_coherent_ops 132#ifndef arch_setup_dma_ops
133static inline int set_arch_dma_coherent_ops(struct device *dev) 133static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
134{ 134 u64 size, struct iommu_ops *iommu,
135 return 0; 135 bool coherent) { }
136} 136#endif
137
138#ifndef arch_teardown_dma_ops
139static inline void arch_teardown_dma_ops(struct device *dev) { }
137#endif 140#endif
138 141
139static inline unsigned int dma_get_max_seg_size(struct device *dev) 142static inline unsigned int dma_get_max_seg_size(struct device *dev)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index e6a7c9ff72f2..415c7613d02c 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/of.h>
24#include <linux/types.h> 25#include <linux/types.h>
25#include <trace/events/iommu.h> 26#include <trace/events/iommu.h>
26 27
@@ -102,7 +103,9 @@ enum iommu_attr {
102 * @remove_device: remove device from iommu grouping 103 * @remove_device: remove device from iommu grouping
103 * @domain_get_attr: Query domain attributes 104 * @domain_get_attr: Query domain attributes
104 * @domain_set_attr: Change domain attributes 105 * @domain_set_attr: Change domain attributes
106 * @of_xlate: add OF master IDs to iommu grouping
105 * @pgsize_bitmap: bitmap of supported page sizes 107 * @pgsize_bitmap: bitmap of supported page sizes
108 * @priv: per-instance data private to the iommu driver
106 */ 109 */
107struct iommu_ops { 110struct iommu_ops {
108 bool (*capable)(enum iommu_cap); 111 bool (*capable)(enum iommu_cap);
@@ -132,7 +135,12 @@ struct iommu_ops {
132 /* Get the numer of window per domain */ 135 /* Get the numer of window per domain */
133 u32 (*domain_get_windows)(struct iommu_domain *domain); 136 u32 (*domain_get_windows)(struct iommu_domain *domain);
134 137
138#ifdef CONFIG_OF_IOMMU
139 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
140#endif
141
135 unsigned long pgsize_bitmap; 142 unsigned long pgsize_bitmap;
143 void *priv;
136}; 144};
137 145
138#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */ 146#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h
index 51a560f34bca..16c75547d725 100644
--- a/include/linux/of_iommu.h
+++ b/include/linux/of_iommu.h
@@ -1,12 +1,19 @@
1#ifndef __OF_IOMMU_H 1#ifndef __OF_IOMMU_H
2#define __OF_IOMMU_H 2#define __OF_IOMMU_H
3 3
4#include <linux/device.h>
5#include <linux/iommu.h>
6#include <linux/of.h>
7
4#ifdef CONFIG_OF_IOMMU 8#ifdef CONFIG_OF_IOMMU
5 9
6extern int of_get_dma_window(struct device_node *dn, const char *prefix, 10extern int of_get_dma_window(struct device_node *dn, const char *prefix,
7 int index, unsigned long *busno, dma_addr_t *addr, 11 int index, unsigned long *busno, dma_addr_t *addr,
8 size_t *size); 12 size_t *size);
9 13
14extern void of_iommu_init(void);
15extern struct iommu_ops *of_iommu_configure(struct device *dev);
16
10#else 17#else
11 18
12static inline int of_get_dma_window(struct device_node *dn, const char *prefix, 19static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
@@ -16,6 +23,22 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
16 return -EINVAL; 23 return -EINVAL;
17} 24}
18 25
26static inline void of_iommu_init(void) { }
27static inline struct iommu_ops *of_iommu_configure(struct device *dev)
28{
29 return NULL;
30}
31
19#endif /* CONFIG_OF_IOMMU */ 32#endif /* CONFIG_OF_IOMMU */
20 33
34void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops);
35struct iommu_ops *of_iommu_get_ops(struct device_node *np);
36
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
21#endif /* __OF_IOMMU_H */ 44#endif /* __OF_IOMMU_H */