From patchwork Thu Feb 18 14:12:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 62183 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp610687lbl; Thu, 18 Feb 2016 06:13:41 -0800 (PST) X-Received: by 10.67.24.104 with SMTP id ih8mr10420953pad.124.1455804810439; Thu, 18 Feb 2016 06:13:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si9683783pfj.137.2016.02.18.06.13.30; Thu, 18 Feb 2016 06:13:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756808AbcBRON3 (ORCPT + 4 others); Thu, 18 Feb 2016 09:13:29 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58565 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756773AbcBRON1 (ORCPT ); Thu, 18 Feb 2016 09:13:27 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2Q00HQPY6C76A0@mailout1.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 18 Feb 2016 14:13:25 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-5f-56c5d1843b47 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 12.20.21385.481D5C65; Thu, 18 Feb 2016 14:13:24 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O2Q00576Y5X95B0@eusync4.samsung.com>; Thu, 18 Feb 2016 14:13:24 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Joerg Roedel , Inki Dae , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 09/13] iommu: exynos: add support for SYSMMU controller with bogus version reg Date: Thu, 18 Feb 2016 15:12:56 +0100 Message-id: <1455804780-9616-10-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1455804780-9616-1-git-send-email-m.szyprowski@samsung.com> References: <1455804780-9616-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrILMWRmVeSWpSXmKPExsVy+t/xa7otF4+GGUzts7TYOGM9q8Wk+xNY LBbst7bonL2B3eL1C0OL/sevmS02Pb7GajHj/D4mi7VH7rI7cHo8OTiPyWPTqk42j81L6j0m 31jO6NG3ZRWjx+dNcgFsUVw2Kak5mWWpRfp2CVwZa9f3sRcs5K/4t7iTtYHxGU8XIyeHhICJ xJqutawQtpjEhXvr2boYuTiEBJYySux71cQE4TQxSZx79YwZpIpNwFCi620XG4gtIpAv8WLv XxaQImaBX4wS5zrbmUASwgLJEtNnPmcEsVkEVCWmPZ4CFucV8JA4en4tO8Q6OYn/L1eAxTmB 4ptPbQCrFxJwl/jzcCbTBEbeBYwMqxhFU0uTC4qT0nON9IoTc4tL89L1kvNzNzFCAu7rDsal x6wOMQpwMCrx8G54cSRMiDWxrLgy9xCjBAezkgjv7r1Hw4R4UxIrq1KL8uOLSnNSiw8xSnOw KInzztz1PkRIID2xJDU7NbUgtQgmy8TBKdXAeJB/UY6Ae3B7rbDHVuFmfdtKp0W9U/lua8c8 XffyY8PalfNlyvdW29u3hBl4P5uy+sB9360e4v8lU3W14iZ8vmtXudylKHrvZpFZq7V+rb2W dlGN0fMQQ7nXXOtrlyPKpzQv/qX8hHFSlc9thf06cwOzElKYm1yevM++Wm/Vx1R1u+ak0f88 JZbijERDLeai4kQA6S7wEDQCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org SYSMMU on some SoCs reports bogus values in VERSION register. Force hardware version to 1.0 for such controllers. This patch also moves reading version register to driver's probe() function. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index e42a76cc9674..8e289e2a05fb 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -284,6 +284,28 @@ static void __sysmmu_set_ptbase(struct sysmmu_drvdata *data, phys_addr_t pgd) __sysmmu_tlb_invalidate(data); } +static void __sysmmu_get_version(struct sysmmu_drvdata *data) +{ + u32 ver; + + clk_enable(data->clk_master); + clk_enable(data->clk); + + ver = __raw_readl(data->sfrbase + REG_MMU_VERSION); + + /* controllers on some SoCs don't report proper version */ + if (ver == 0x80000001u) + data->version = MAKE_MMU_VER(1, 0); + else + data->version = MMU_RAW_VER(ver); + + dev_dbg(data->sysmmu, "hardware version: %d.%d\n", + MMU_MAJ_VER(data->version), MMU_MIN_VER(data->version)); + + clk_disable(data->clk); + clk_disable(data->clk_master); +} + static void show_fault_information(struct sysmmu_drvdata *data, const struct sysmmu_fault_info *finfo, sysmmu_iova_t fault_addr) @@ -385,7 +407,6 @@ static void __sysmmu_init_config(struct sysmmu_drvdata *data) { unsigned int cfg; - data->version = MMU_RAW_VER(__raw_readl(data->sfrbase + REG_MMU_VERSION)); if (data->version <= MAKE_MMU_VER(3, 1)) cfg = CFG_LRU | CFG_QOS(15); else if (data->version <= MAKE_MMU_VER(3, 2)) @@ -551,6 +572,7 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); + __sysmmu_get_version(data); pm_runtime_enable(dev); return 0;