aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/platform.c
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-08-27 11:24:20 -0400
committerWill Deacon <will.deacon@arm.com>2014-12-01 11:50:45 -0500
commit97890ba9289c66e23f2f2d431937693b6498d6f6 (patch)
treefce6fcfd86ad149adfdae5c04245cc75342d2608 /drivers/of/platform.c
parent461bfb3fe7d0cf64d9ee2190ad8507e460fab198 (diff)
dma-mapping: detect and configure IOMMU in of_dma_configure
This patch extends of_dma_configure so that it sets up the IOMMU for a device, as well as the coherent/non-coherent DMA mapping ops. Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r--drivers/of/platform.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ff1f4e9afccb..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>
@@ -166,6 +167,7 @@ static void of_dma_configure(struct device *dev)
166 int ret; 167 int ret;
167 bool coherent; 168 bool coherent;
168 unsigned long offset; 169 unsigned long offset;
170 struct iommu_ops *iommu;
169 171
170 /* 172 /*
171 * 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
@@ -194,7 +196,16 @@ static void of_dma_configure(struct device *dev)
194 dev_dbg(dev, "device is%sdma coherent\n", 196 dev_dbg(dev, "device is%sdma coherent\n",
195 coherent ? " " : " not "); 197 coherent ? " " : " not ");
196 198
197 arch_setup_dma_ops(dev, coherent); 199 iommu = of_iommu_configure(dev);
200 dev_dbg(dev, "device is%sbehind an iommu\n",
201 iommu ? " " : " not ");
202
203 arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
204}
205
206static void of_dma_deconfigure(struct device *dev)
207{
208 arch_teardown_dma_ops(dev);
198} 209}
199 210
200/** 211/**
@@ -223,16 +234,12 @@ static struct platform_device *of_platform_device_create_pdata(
223 if (!dev) 234 if (!dev)
224 goto err_clear_flag; 235 goto err_clear_flag;
225 236
226 of_dma_configure(&dev->dev);
227 dev->dev.bus = &platform_bus_type; 237 dev->dev.bus = &platform_bus_type;
228 dev->dev.platform_data = platform_data; 238 dev->dev.platform_data = platform_data;
229 239 of_dma_configure(&dev->dev);
230 /* We do not fill the DMA ops for platform devices by default.
231 * This is currently the responsibility of the platform code
232 * to do such, possibly using a device notifier
233 */
234 240
235 if (of_device_add(dev) != 0) { 241 if (of_device_add(dev) != 0) {
242 of_dma_deconfigure(&dev->dev);
236 platform_device_put(dev); 243 platform_device_put(dev);
237 goto err_clear_flag; 244 goto err_clear_flag;
238 } 245 }