From patchwork Fri Jul 13 16:27:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thor Thayer X-Patchwork-Id: 10523819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A2B4602A0 for ; Fri, 13 Jul 2018 16:27:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB02B29D77 for ; Fri, 13 Jul 2018 16:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD43829D91; Fri, 13 Jul 2018 16:27:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 926AA29D77 for ; Fri, 13 Jul 2018 16:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4QHqv3NkUNtA1K4lnQSftAJqgDftO2ua66Hu8zgsaP8=; b=nFf3Yv9wQjxn5LZyfdQBTXs6No E0gPdyQT87m8sd4oKg0b5q/bVbIwPvXkyx0nFkdpGWfqZ4p9O34/nORrCtDgWm06annLIUWWuJ3E/ OL6gC+3luB/qzUETbOo8o3sJfHj+9KZAd9y2WueFQZt6kbYqDX829nKPPRGydqn7lMCRTi+/xMVgd ppqzU7eFjAm1p0HF8up40QtGDMm7HNWt03tg595LjEmUnrmBIP3BzbdjUiztHPqEnP9lNTwxEnjZL iV7INfz2e0MgJ27FJJn96mvtBPT78MqpxaAWIryKNM0wh1liYMXJfsBtC9gtQ0mQDgZt4AHlH1JRP fZdWdl1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe0uy-0004cc-Sk; Fri, 13 Jul 2018 16:27:40 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe0uw-0003Kl-3p for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2018 16:27:39 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 09:25:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,348,1526367600"; d="scan'208";a="56665381" Received: from tthayer-hp-z620-workstation.an.intel.com ([10.122.105.144]) by orsmga008.jf.intel.com with ESMTP; 13 Jul 2018 09:25:27 -0700 From: thor.thayer@linux.intel.com To: dinguyen@kernel.org, robh+dt@kernel.org, joro@8bytes.org, mark.rutland@arm.com, robin.murphy@arm.com Subject: [PATCH 2/3] iommu/arm-smmu: Add optional SMMU clock Date: Fri, 13 Jul 2018 11:27:57 -0500 Message-Id: <1531499278-32132-3-git-send-email-thor.thayer@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531499278-32132-1-git-send-email-thor.thayer@linux.intel.com> References: <1531499278-32132-1-git-send-email-thor.thayer@linux.intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180713_092738_171563_028E46B3 X-CRM114-Status: GOOD ( 13.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Thor Thayer , catalin.marinas@arm.com, will.deacon@arm.com, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thor Thayer 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 --- 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; }