devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
To: dinguyen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	robin.murphy-5wv7dgnIgG8@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Thor Thayer <thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	catalin.marinas-5wv7dgnIgG8@public.gmane.org,
	will.deacon-5wv7dgnIgG8@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 2/3] iommu/arm-smmu: Add optional SMMU clock
Date: Fri, 13 Jul 2018 11:27:57 -0500	[thread overview]
Message-ID: <1531499278-32132-3-git-send-email-thor.thayer@linux.intel.com> (raw)
In-Reply-To: <1531499278-32132-1-git-send-email-thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

From: Thor Thayer <thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Add a clock to the SMMU structure. In the device tree case,
check for a clock handle and enable the clock if found.

Signed-off-by: Thor Thayer <thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iommu/arm-smmu.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 69e7c60792a8..0e6dd5019c23 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -212,6 +212,7 @@ struct arm_smmu_device {
 
 	/* IOMMU core code handle */
 	struct iommu_device		iommu;
+	struct clk			*clk;
 };
 
 enum arm_smmu_context_fmt {
@@ -1992,6 +1993,15 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
 	struct device *dev = &pdev->dev;
 	bool legacy_binding;
 
+	/* If a clock is declared, enable it */
+	smmu->clk = devm_clk_get(smmu->dev, NULL);
+	if (IS_ERR(smmu->clk)) {
+		smmu->clk = NULL;
+		dev_dbg(dev, "cannot get smmu clock\n");
+	} else {
+		clk_prepare_enable(smmu->clk);
+	}
+
 	if (of_property_read_u32(dev->of_node, "#global-interrupts",
 				 &smmu->num_global_irqs)) {
 		dev_err(dev, "missing #global-interrupts property\n");
@@ -2181,6 +2191,10 @@ 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);
+
+	if (smmu->clk)
+		clk_disable_unprepare(smmu->clk);
+
 	return 0;
 }
 
@@ -2193,6 +2207,9 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 {
 	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
 
+	if (smmu->clk)
+		clk_prepare_enable(smmu->clk);
+
 	arm_smmu_device_reset(smmu);
 	return 0;
 }
-- 
2.7.4

  parent reply	other threads:[~2018-07-13 16:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 16:27 [PATCH 0/3] SOCFPGA Stratix10 SMMU Support thor.thayer-VuQAYsv1563Yd54FQh9/CA
     [not found] ` <1531499278-32132-1-git-send-email-thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-07-13 16:27   ` [PATCH 1/3] Docs: dt: arm-smmu: Add optional clock parameter thor.thayer-VuQAYsv1563Yd54FQh9/CA
     [not found]     ` <1531499278-32132-2-git-send-email-thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-07-20 16:15       ` Rob Herring
2018-07-24 22:25         ` Thor Thayer
2018-07-13 16:27   ` thor.thayer-VuQAYsv1563Yd54FQh9/CA [this message]
2018-07-13 16:27 ` [PATCH 3/3] arm64: dts: stratix10: Add SMMU Node thor.thayer
     [not found]   ` <1531499278-32132-4-git-send-email-thor.thayer-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-07-13 18:09     ` Robin Murphy
     [not found]       ` <2d17b3b1-96a1-8a0a-521e-134de9df72d0-5wv7dgnIgG8@public.gmane.org>
2018-07-16 18:56         ` Thor Thayer
     [not found]           ` <847f8f94-5108-47a3-bb08-c5f50b64e6e6-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-07-25 13:34             ` Robin Murphy
2018-07-13 17:05 ` [PATCH 0/3] SOCFPGA Stratix10 SMMU Support Robin Murphy

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=1531499278-32132-3-git-send-email-thor.thayer@linux.intel.com \
    --to=thor.thayer-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dinguyen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).