All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sricharan R <sricharan@codeaurora.org>
To: linux-arm-kernel@lists.infradead.org,
	iommu@lists.linux-foundation.org, will.deacon@arm.com,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	mitchelh@codeaurora.org
Cc: sricharan@codeaurora.org
Subject: [RFC PATCH 4/4] iommu/arm-smmu: Add support for specifying regulators
Date: Fri, 17 Jul 2015 22:23:25 +0530	[thread overview]
Message-ID: <1437152005-25092-5-git-send-email-sricharan@codeaurora.org> (raw)
In-Reply-To: <1437152005-25092-1-git-send-email-sricharan@codeaurora.org>

From: Mitchel Humpherys <mitchelh@codeaurora.org>

This adds the support to turn on the regulators required
for SMMUs. It is turned on during the SMMU probe and remains
'on' till the device exists.

Signed-off-by: Sricharan R <sricharan@codeaurora.org>
---
 .../devicetree/bindings/iommu/arm,smmu.txt         |  3 ++
 drivers/iommu/arm-smmu.c                           | 48 +++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index c2cf4fe..433d778 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -60,6 +60,9 @@ conditions.
 		  Documentation/devicetree/bindings/clock/clock-bindings.txt
 		  for more info.
 
+- vdd-supply    : Phandle of the regulator that should be powered on during
+                  SMMU register access.
+
 Example:
 
         smmu {
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 80d56f0a..c92de50 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -326,6 +326,8 @@ struct arm_smmu_device {
 
 	int				num_clocks;
 	struct clk			**clocks;
+
+	struct regulator		*regulator;
 };
 
 struct arm_smmu_cfg {
@@ -559,6 +561,22 @@ static void __arm_smmu_free_bitmap(unsigned long *map, int idx)
 	clear_bit(idx, map);
 }
 
+static int arm_smmu_enable_regulators(struct arm_smmu_device *smmu)
+{
+	if (!smmu->regulator)
+		return 0;
+
+	return regulator_enable(smmu->regulator);
+}
+
+static int arm_smmu_disable_regulators(struct arm_smmu_device *smmu)
+{
+	if (!smmu->regulator)
+		return 0;
+
+	return regulator_disable(smmu->regulator);
+}
+
 /* Wait for any pending TLB invalidations to complete */
 static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu)
 {
@@ -1583,6 +1601,20 @@ static int arm_smmu_id_size_to_bits(int size)
 	}
 }
 
+static int arm_smmu_init_regulators(struct arm_smmu_device *smmu)
+{
+	struct device *dev = smmu->dev;
+
+	if (!of_get_property(dev->of_node, "vdd-supply", NULL))
+		return 0;
+
+	smmu->regulator = devm_regulator_get(dev, "vdd");
+	if (IS_ERR(smmu->regulator))
+		return PTR_ERR(smmu->regulator);
+
+	return 0;
+}
+
 static int arm_smmu_init_clocks(struct arm_smmu_device *smmu)
 {
 	const char *cname;
@@ -1841,11 +1873,21 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 		smmu->irqs[i] = irq;
 	}
 
+	err = arm_smmu_init_regulators(smmu);
+	if (err)
+		goto out_put_masters;
+
 	err = arm_smmu_init_clocks(smmu);
 	if (err)
 		goto out_put_masters;
 
-	arm_smmu_enable_clocks(smmu);
+	err = arm_smmu_enable_regulators(smmu);
+	if (err)
+		goto out_put_masters;
+
+	err = arm_smmu_enable_clocks(smmu);
+	if (err)
+		goto out_disable_regulators;
 
 	err = arm_smmu_device_cfg_probe(smmu);
 	if (err)
@@ -1908,6 +1950,9 @@ out_free_irqs:
 out_disable_clocks:
 	arm_smmu_disable_clocks(smmu);
 
+out_disable_regulators:
+	arm_smmu_disable_regulators(smmu);
+
 out_put_masters:
 	for (node = rb_first(&smmu->masters); node; node = rb_next(node)) {
 		struct arm_smmu_master *master
@@ -1953,6 +1998,7 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
 	/* Turn the thing off */
 	writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
 	arm_smmu_disable_clocks(smmu);
+	arm_smmu_disable_regulators(smmu);
 
 	return 0;
 }
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

WARNING: multiple messages have this Message-ID (diff)
From: sricharan@codeaurora.org (Sricharan R)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 4/4] iommu/arm-smmu: Add support for specifying regulators
Date: Fri, 17 Jul 2015 22:23:25 +0530	[thread overview]
Message-ID: <1437152005-25092-5-git-send-email-sricharan@codeaurora.org> (raw)
In-Reply-To: <1437152005-25092-1-git-send-email-sricharan@codeaurora.org>

From: Mitchel Humpherys <mitchelh@codeaurora.org>

This adds the support to turn on the regulators required
for SMMUs. It is turned on during the SMMU probe and remains
'on' till the device exists.

Signed-off-by: Sricharan R <sricharan@codeaurora.org>
---
 .../devicetree/bindings/iommu/arm,smmu.txt         |  3 ++
 drivers/iommu/arm-smmu.c                           | 48 +++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index c2cf4fe..433d778 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -60,6 +60,9 @@ conditions.
 		  Documentation/devicetree/bindings/clock/clock-bindings.txt
 		  for more info.
 
+- vdd-supply    : Phandle of the regulator that should be powered on during
+                  SMMU register access.
+
 Example:
 
         smmu {
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 80d56f0a..c92de50 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -326,6 +326,8 @@ struct arm_smmu_device {
 
 	int				num_clocks;
 	struct clk			**clocks;
+
+	struct regulator		*regulator;
 };
 
 struct arm_smmu_cfg {
@@ -559,6 +561,22 @@ static void __arm_smmu_free_bitmap(unsigned long *map, int idx)
 	clear_bit(idx, map);
 }
 
+static int arm_smmu_enable_regulators(struct arm_smmu_device *smmu)
+{
+	if (!smmu->regulator)
+		return 0;
+
+	return regulator_enable(smmu->regulator);
+}
+
+static int arm_smmu_disable_regulators(struct arm_smmu_device *smmu)
+{
+	if (!smmu->regulator)
+		return 0;
+
+	return regulator_disable(smmu->regulator);
+}
+
 /* Wait for any pending TLB invalidations to complete */
 static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu)
 {
@@ -1583,6 +1601,20 @@ static int arm_smmu_id_size_to_bits(int size)
 	}
 }
 
+static int arm_smmu_init_regulators(struct arm_smmu_device *smmu)
+{
+	struct device *dev = smmu->dev;
+
+	if (!of_get_property(dev->of_node, "vdd-supply", NULL))
+		return 0;
+
+	smmu->regulator = devm_regulator_get(dev, "vdd");
+	if (IS_ERR(smmu->regulator))
+		return PTR_ERR(smmu->regulator);
+
+	return 0;
+}
+
 static int arm_smmu_init_clocks(struct arm_smmu_device *smmu)
 {
 	const char *cname;
@@ -1841,11 +1873,21 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 		smmu->irqs[i] = irq;
 	}
 
+	err = arm_smmu_init_regulators(smmu);
+	if (err)
+		goto out_put_masters;
+
 	err = arm_smmu_init_clocks(smmu);
 	if (err)
 		goto out_put_masters;
 
-	arm_smmu_enable_clocks(smmu);
+	err = arm_smmu_enable_regulators(smmu);
+	if (err)
+		goto out_put_masters;
+
+	err = arm_smmu_enable_clocks(smmu);
+	if (err)
+		goto out_disable_regulators;
 
 	err = arm_smmu_device_cfg_probe(smmu);
 	if (err)
@@ -1908,6 +1950,9 @@ out_free_irqs:
 out_disable_clocks:
 	arm_smmu_disable_clocks(smmu);
 
+out_disable_regulators:
+	arm_smmu_disable_regulators(smmu);
+
 out_put_masters:
 	for (node = rb_first(&smmu->masters); node; node = rb_next(node)) {
 		struct arm_smmu_master *master
@@ -1953,6 +1998,7 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
 	/* Turn the thing off */
 	writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
 	arm_smmu_disable_clocks(smmu);
+	arm_smmu_disable_regulators(smmu);
 
 	return 0;
 }
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

  parent reply	other threads:[~2015-07-17 16:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 16:53 [RFC PATCH 0/4] iommu/arm-smmu: Add support for adding masters/clocks using generic bindings Sricharan R
2015-07-17 16:53 ` Sricharan R
2015-07-17 16:53 ` [RFC PATCH 1/4] iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE Sricharan R
2015-07-17 16:53   ` Sricharan R
     [not found]   ` <1437152005-25092-2-git-send-email-sricharan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-07-21 15:03     ` Will Deacon
2015-07-21 15:03       ` Will Deacon
2015-07-22 11:08       ` Sricharan
2015-07-22 11:08         ` Sricharan
     [not found] ` <1437152005-25092-1-git-send-email-sricharan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-07-17 16:53   ` [RFC PATCH 2/4] iommu/arm-smmu: Add xlate callback for initializing master devices from dt Sricharan R
2015-07-17 16:53     ` Sricharan R
2015-07-17 16:53 ` [RFC PATCH 3/4] iommu/arm-smmu: Add support for specifying clocks Sricharan R
2015-07-17 16:53   ` Sricharan R
     [not found]   ` <1437152005-25092-4-git-send-email-sricharan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-07-21 15:01     ` Will Deacon
2015-07-21 15:01       ` Will Deacon
     [not found]       ` <20150721150122.GH31095-5wv7dgnIgG8@public.gmane.org>
2015-07-24 12:26         ` Sricharan
2015-07-24 12:26           ` Sricharan
2015-07-17 16:53 ` Sricharan R [this message]
2015-07-17 16:53   ` [RFC PATCH 4/4] iommu/arm-smmu: Add support for specifying regulators Sricharan R
     [not found]   ` <1437152005-25092-5-git-send-email-sricharan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-07-21 18:17     ` Stephen Boyd
2015-07-21 18:17       ` Stephen Boyd
2015-07-24 12:28       ` Sricharan
2015-07-24 12:28         ` Sricharan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437152005-25092-5-git-send-email-sricharan@codeaurora.org \
    --to=sricharan@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=mitchelh@codeaurora.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.