iommu: msm: Make regulators optional
Do not error out if regulators aren't specified in the device tree
node for an IOMMU. This allows IOMMU drivers to be used in simulation
environment and for early bringup of hardware.
Change-Id: I9bb6c3faa7ba5aed482bdad6612197497f7a849d
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/Documentation/devicetree/bindings/iommu/msm_iommu_v1.txt b/Documentation/devicetree/bindings/iommu/msm_iommu_v1.txt
index b3f1aef..26a119c 100644
--- a/Documentation/devicetree/bindings/iommu/msm_iommu_v1.txt
+++ b/Documentation/devicetree/bindings/iommu/msm_iommu_v1.txt
@@ -13,6 +13,7 @@
- qcom,iommu-secure-id : Secure identifier for the IOMMU block
- qcom,secure-context : boolean indicating that a context is secure and
programmed by the secure environment.
+- qcom,vdd-supply: Regulator needed to access IOMMU
- qcom,alt-vdd-supply : Alternative regulator needed to access IOMMU
configuration registers.
- interrupts : should contain the performance monitor overflow interrupt number.
diff --git a/drivers/iommu/msm_iommu-v1.c b/drivers/iommu/msm_iommu-v1.c
index 5ee8794..7c57b67 100644
--- a/drivers/iommu/msm_iommu-v1.c
+++ b/drivers/iommu/msm_iommu-v1.c
@@ -42,15 +42,18 @@
static int __enable_regulators(struct msm_iommu_drvdata *drvdata)
{
- int ret = regulator_enable(drvdata->gdsc);
- if (ret)
- goto fail;
+ int ret = 0;
+ if (drvdata->gdsc) {
+ ret = regulator_enable(drvdata->gdsc);
+ if (ret)
+ goto fail;
- if (drvdata->alt_gdsc)
- ret = regulator_enable(drvdata->alt_gdsc);
+ if (drvdata->alt_gdsc)
+ ret = regulator_enable(drvdata->alt_gdsc);
- if (ret)
- regulator_disable(drvdata->gdsc);
+ if (ret)
+ regulator_disable(drvdata->gdsc);
+ }
fail:
return ret;
}
@@ -60,7 +63,8 @@
if (drvdata->alt_gdsc)
regulator_disable(drvdata->alt_gdsc);
- regulator_disable(drvdata->gdsc);
+ if (drvdata->gdsc)
+ regulator_disable(drvdata->gdsc);
}
static int apply_bus_vote(struct msm_iommu_drvdata *drvdata, unsigned int vote)
diff --git a/drivers/iommu/msm_iommu_dev-v1.c b/drivers/iommu/msm_iommu_dev-v1.c
index 958b7b1..11f43ae 100644
--- a/drivers/iommu/msm_iommu_dev-v1.c
+++ b/drivers/iommu/msm_iommu_dev-v1.c
@@ -263,13 +263,19 @@
drvdata->glb_base = drvdata->base;
- drvdata->gdsc = devm_regulator_get(&pdev->dev, "vdd");
- if (IS_ERR(drvdata->gdsc))
- return PTR_ERR(drvdata->gdsc);
+ if (of_get_property(pdev->dev.of_node, "vdd-supply", NULL)) {
- drvdata->alt_gdsc = devm_regulator_get(&pdev->dev, "qcom,alt-vdd");
- if (IS_ERR(drvdata->alt_gdsc))
- drvdata->alt_gdsc = NULL;
+ drvdata->gdsc = devm_regulator_get(&pdev->dev, "vdd");
+ if (IS_ERR(drvdata->gdsc))
+ return PTR_ERR(drvdata->gdsc);
+
+ drvdata->alt_gdsc = devm_regulator_get(&pdev->dev,
+ "qcom,alt-vdd");
+ if (IS_ERR(drvdata->alt_gdsc))
+ drvdata->alt_gdsc = NULL;
+ } else {
+ pr_debug("Warning: No regulator specified for IOMMU\n");
+ }
drvdata->pclk = devm_clk_get(&pdev->dev, "iface_clk");
if (IS_ERR(drvdata->pclk))