From patchwork Thu Aug 8 09:39:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 2840970 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC1A3BF535 for ; Thu, 8 Aug 2013 10:28:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85957204B2 for ; Thu, 8 Aug 2013 10:28:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72FFC20480 for ; Thu, 8 Aug 2013 10:28:35 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7MhY-0002Ei-Q6; Thu, 08 Aug 2013 09:40:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Mgl-00053t-OF; Thu, 08 Aug 2013 09:39:23 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Mgb-0004zr-4i for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2013 09:39:13 +0000 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MR7006ZVHGWJSG0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2013 18:39:06 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.48]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 82.F3.17404.A3763025; Thu, 08 Aug 2013 18:39:06 +0900 (KST) X-AuditID: cbfee68d-b7f096d0000043fc-78-5203673a2f1b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 84.58.32250.93763025; Thu, 08 Aug 2013 18:39:06 +0900 (KST) Received: from DOPULLIPCHO07 ([12.23.118.94]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MR700152HH5POA0@mmp1.samsung.com>; Thu, 08 Aug 2013 18:39:05 +0900 (KST) From: Cho KyongHo To: 'Linux ARM Kernel' , 'Linux IOMMU' , 'Linux Kernel' , 'Linux Samsung SOC' , devicetree@vger.kernel.org Subject: [PATCH v9 08/16] iommu/exynos: gating clocks of master H/W Date: Thu, 08 Aug 2013 18:39:05 +0900 Message-id: <002c01ce941b$1fd0ab80$5f720280$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac6UF463hy6MY5CQQ4e4jS9YdPDSWw== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42I5/e+Zga5VOnOQwYrzXBZ37p5jtZh/BEi8 OvKDyWLBfmuLztkb2C16F1xls/h46ji7xabH11gtLu+aw2Yx4/w+JosLKzayW0xZdJjV4uSf XkaLluu9TA58Hk8OzmPymN1wkcXjzrU9bB7nN61h9ti8pN5j8o3ljB59W1YxenzeJOdx5egZ pgDOKC6blNSczLLUIn27BK6MU113WQp2KVf0bZrG3MB4Q6aLkZNDQsBEovnhHUYIW0ziwr31 bF2MXBxCAssYJTYvf8gIU3Tl0zc2EFtIYBGjRNfsPIiiv4wSv7cuAytiE9CSWD33OCNIQkTg N6PErWdzWEEcZoH/TBJbbzexdzFycAgLOEvs7IsBaWAR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3jJDXKQgsePsa7DFIgJ6Eq/6TzFC1IhI7HvxjnEC o8AsJKNmIRk1C8moWUhaFjCyrGIUTS1ILihOSs811CtOzC0uzUvXS87P3cQITizPpHYwrmyw OMQowMGoxMPbEcAUJMSaWFZcmXuIUYKDWUmE92IxUIg3JbGyKrUoP76oNCe1+BBjMtCnE5ml RJPzgUkvryTe0NjEzMjSyMzCyMTcnDRhJXHeA63WgUIC6YklqdmpqQWpRTBbmDg4pRoYF9VP XfbyUd9TgeWLAuIP9V06Fefa4t36zeqM9gE2x3557phjPya/qJu9xlK7bfmX26L6/BN+nP2n foT1Iu8l6a8WRdxZShx/56bue/L8zy2+qfliHuJTa5zSby9nYjDNFjDeG3/k4h/9c3d3Kv57 uW0Tq4bVAb70+3bHdMV/lbCKXrjeGSo7QYmlOCPRUIu5qDgRAJppZCZwAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130808_053913_396483_C2EACCA6 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -5.1 (-----) Cc: 'Kukjin Kim' , 'Prathyush' , 'Grant Grundler' , 'Joerg Roedel' , 'Subash Patel' , 'Sachin Kamat' , 'Antonios Motakis' , kvmarm@lists.cs.columbia.edu, 'Rahul Sharma' X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch gates clocks of master H/W as well as clocks of System MMU if master clocks are specified. Some Exynos SoCs (i.e. GScalers in Exynos5250) have dependencies in the gating clocks of master H/W and its System MMU. If a H/W is the case, accessing control registers of System MMU is prohibited unless both of the gating clocks of System MMU and its master H/W. Signed-off-by: Cho KyongHo Reviewed-by: Tomasz Figa --- drivers/iommu/exynos-iommu.c | 38 ++++++++++++++++++++++++++++++++++---- 1 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 0ee73e8..005a7ed 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -173,6 +173,7 @@ struct sysmmu_drvdata { struct device *dev; /* Owner of system MMU */ int nsfrs; struct clk *clk; + struct clk *clk_master; int activations; rwlock_t lock; struct iommu_domain *domain; @@ -263,6 +264,8 @@ void exynos_sysmmu_set_prefbuf(struct device *dev, if (!is_sysmmu_active(data)) goto finish; + clk_enable(data->clk_master); + for (i = 0; i < data->nsfrs; i++) { if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { if (!sysmmu_block(data->sfrbases[i])) @@ -288,6 +291,8 @@ void exynos_sysmmu_set_prefbuf(struct device *dev, sysmmu_unblock(data->sfrbases[i]); } } + + clk_disable(data->clk_master); finish: read_unlock_irqrestore(&data->lock, flags); } @@ -358,6 +363,8 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) break; } + clk_enable(data->clk_master); + if (i == pdev->num_resources) { itype = SYSMMU_FAULT_UNKNOWN; } else { @@ -391,6 +398,8 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) if (itype != SYSMMU_FAULT_UNKNOWN) sysmmu_unblock(data->sfrbases[i]); + clk_disable(data->clk_master); + read_unlock(&data->lock); return IRQ_HANDLED; @@ -407,11 +416,14 @@ static bool __exynos_sysmmu_disable(struct sysmmu_drvdata *data) if (!set_sysmmu_inactive(data)) goto finish; + clk_enable(data->clk_master); + for (i = 0; i < data->nsfrs; i++) __raw_writel(CTRL_DISABLE, data->sfrbases[i] + REG_MMU_CTRL); - if (data->clk) - clk_disable(data->clk); + clk_disable(data->clk_master); + + clk_disable(data->clk); disabled = true; data->pgtable = 0; @@ -454,11 +466,12 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, goto finish; } - if (data->clk) - clk_enable(data->clk); + clk_enable(data->clk); data->pgtable = pgtable; + clk_enable(data->clk_master); + for (i = 0; i < data->nsfrs; i++) { __sysmmu_set_ptbase(data->sfrbases[i], pgtable); @@ -473,6 +486,8 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, __raw_writel(CTRL_ENABLE, data->sfrbases[i] + REG_MMU_CTRL); } + clk_disable(data->clk_master); + data->domain = domain; dev_dbg(data->sysmmu, "Enabled\n"); @@ -528,6 +543,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova) if (is_sysmmu_active(data)) { int i; + clk_enable(data->clk_master); for (i = 0; i < data->nsfrs; i++) { if (sysmmu_block(data->sfrbases[i])) { __sysmmu_tlb_invalidate_entry( @@ -535,6 +551,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova) sysmmu_unblock(data->sfrbases[i]); } } + clk_disable(data->clk_master); } else { dev_dbg(data->sysmmu, "Disabled. Skipping invalidating TLB.\n"); } @@ -551,12 +568,14 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) if (is_sysmmu_active(data)) { int i; + clk_enable(data->clk_master); for (i = 0; i < data->nsfrs; i++) { if (sysmmu_block(data->sfrbases[i])) { __sysmmu_tlb_invalidate(data->sfrbases[i]); sysmmu_unblock(data->sfrbases[i]); } } + clk_disable(data->clk_master); } else { dev_dbg(data->sysmmu, "Disabled. Skipping invalidating TLB.\n"); } @@ -637,6 +656,17 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) return ret; } + data->clk_master = devm_clk_get(dev, "master"); + if (IS_ERR(data->clk_master)) + data->clk_master = NULL; + + ret = clk_prepare(data->clk_master); + if (ret) { + clk_unprepare(data->clk); + dev_err(dev, "Failed to prepare master's clk\n"); + return ret; + } + rwlock_init(&data->lock); INIT_LIST_HEAD(&data->node);