diff options
author | Hiroshi Doyu <hdoyu@nvidia.com> | 2012-03-22 16:06:27 +0200 |
---|---|---|
committer | Hiroshi Doyu <hdoyu@nvidia.com> | 2012-09-07 13:20:36 +0300 |
commit | 5688fbe0b3de2576e1f3f39e7477ebf9e5a9e49b (patch) | |
tree | 150a7933e370d843a0bac60f29ddee8666676177 /drivers/base | |
parent | 29c2fae99369dd8450d94a45a300f9fe48bff4ee (diff) |
platform: IOMMU'able platform_device w/ PLATFORM_ENABLE_IOMMU
Introduced a new kernel config option, PLATFORM_ENABLE_IOMMU. With
this, all platform devices can be converted to be IOMMU'able if
platform_bus has non-null dma_iommu_map, where H/Ws always see its IO
virtual address and virt_to_phys() doesn't work from H/W POV.
Change-Id: Iafc4cac73624cfa0bb0f513febd7d91c59954268
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/Kconfig | 4 | ||||
-rw-r--r-- | drivers/base/platform.c | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 3df339c031a8..0f45311cb520 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -308,4 +308,8 @@ config CMA_AREAS endif +config PLATFORM_ENABLE_IOMMU + bool "Make platform devices iommuable" + depends on IOMMU_API + endmenu diff --git a/drivers/base/platform.c b/drivers/base/platform.c index a1a722502587..9eae3beb26da 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -21,6 +21,8 @@ #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <asm/dma-iommu.h> + #include "base.h" #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ @@ -305,8 +307,19 @@ int platform_device_add(struct platform_device *pdev) dev_name(&pdev->dev), dev_name(pdev->dev.parent)); ret = device_add(&pdev->dev); - if (ret == 0) - return ret; + if (ret) + goto failed; + +#ifdef CONFIG_PLATFORM_ENABLE_IOMMU + if (platform_bus_type.map && !pdev->dev.archdata.mapping) { + ret = arm_iommu_attach_device(&pdev->dev, + platform_bus_type.map); + if (ret) + goto failed; + } +#endif + + return 0; failed: while (--i >= 0) { |