msm: iommu: Do not register API on unsupported SoC versions
In addition to not registering IOMMU devices, do not
register the IOMMU API on SoC versions which do not support
it. This will allow iommu_found to work properly.
Change-Id: I103fc4ff910bee3eb4039e19de52f36cd1778861
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
diff --git a/arch/arm/mach-msm/devices-iommu.c b/arch/arm/mach-msm/devices-iommu.c
index 397fdea..3d2d2e7 100644
--- a/arch/arm/mach-msm/devices-iommu.c
+++ b/arch/arm/mach-msm/devices-iommu.c
@@ -1057,11 +1057,7 @@
static int __init iommu_init(void)
{
int ret;
- if ((cpu_is_msm8960() &&
- SOCINFO_VERSION_MAJOR(socinfo_get_version()) < 2) ||
- (cpu_is_msm8x60() &&
- (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2 ||
- SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1))) {
+ if (!msm_soc_version_supports_iommu()) {
pr_err("IOMMU is not supported on this SoC version.\n");
return -ENODEV;
}
diff --git a/arch/arm/mach-msm/include/mach/iommu.h b/arch/arm/mach-msm/include/mach/iommu.h
index 5542ff4..9405459 100644
--- a/arch/arm/mach-msm/include/mach/iommu.h
+++ b/arch/arm/mach-msm/include/mach/iommu.h
@@ -15,6 +15,7 @@
#include <linux/interrupt.h>
#include <linux/clk.h>
+#include <mach/socinfo.h>
/* Sharability attributes of MSM IOMMU mappings */
#define MSM_IOMMU_ATTR_NON_SH 0x0
@@ -121,3 +122,17 @@
#endif
#endif
+
+static inline int msm_soc_version_supports_iommu(void)
+{
+ if (cpu_is_msm8960() &&
+ SOCINFO_VERSION_MAJOR(socinfo_get_version()) < 2)
+ return 0;
+
+ if (cpu_is_msm8x60() &&
+ (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2 ||
+ SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1)) {
+ return 0;
+ }
+ return 1;
+}
diff --git a/arch/arm/mach-msm/iommu.c b/arch/arm/mach-msm/iommu.c
index 0a77781..442a1b4 100644
--- a/arch/arm/mach-msm/iommu.c
+++ b/arch/arm/mach-msm/iommu.c
@@ -1006,6 +1006,9 @@
static int __init msm_iommu_init(void)
{
+ if (!msm_soc_version_supports_iommu())
+ return -ENODEV;
+
setup_iommu_tex_classes();
register_iommu(&msm_iommu_ops);
return 0;