Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp879993ybl; Wed, 21 Aug 2019 06:59:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg9i1at5d1rDq38ilLiKSksNIeTTqqQpdIp9nMwu66wqtXIZSgXdF51M/bcNAv+51mYbMR X-Received: by 2002:a17:902:2b81:: with SMTP id l1mr21453892plb.107.1566395960288; Wed, 21 Aug 2019 06:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566395960; cv=none; d=google.com; s=arc-20160816; b=Pj5W7Axd8l9Yo1IEYcxKFjL+UBE64aX9gfGVNmJX7Qhlte4h2xiyWC44RF0nfiSoci 28F0yzhaGdezHrDZkIu93Bs32yGeLSCKKYghdg9kiu/Y4F9Uxmd0+3grOIK5MkDVX0V6 f8RAej71Dc23LhxSfnu0x7Bulpg6v2u5WYtnn2vSeWkq099VJvur5sUa0YHmKHKX7AWI Vgn4H0ocaYKT3Dp0YJ47RXsCZkKfa9TSNhXHgnaZwGH+WrChH+z8qYH6+7MJTiGaFHV8 4AZqZuW6ixvEVxAFbd+/C7GschrBrSyesrJ533XWwGjnw9atwfZHlJC1PjSMqqrBvVG3 yCaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=8A9wcTOzNhVjihrX9dvwVUPH6tAFzk0UnIOosnnRBR8=; b=NWeXvQZSouMcmWbDZJI+UNYvwdSgN5jOalCZ7cZ3mtiMiiMmxbaBgRQJQvqFAEQ1s+ lidVUsfAyGLGoP/L1m0qiGWrN/hXg6y+0YKeQSVTjKSsuMyabSOU1ZxtyIK7lN0GxuqN zCBhztcsZ65pw4hyNVWcNaYVVIlrA4gv5KGdzqoHZHE7X8FTlslQmYCRsh95ymZWHWiv 71BRVJI8RLtKlwxTAWhIV5+olTucMDwMpR3J3ZjgZDVqQcabhOYL0dSFrru+aN/70vY9 IHbtqG0R8CFbbAM7gOsHQCXnogIoi+IpINWBigyZvfFAmFSK9DDixu+B/0/FdBkpw72C xpjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si29390pjn.101.2019.08.21.06.59.03; Wed, 21 Aug 2019 06:59:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729249AbfHUN4Z (ORCPT + 99 others); Wed, 21 Aug 2019 09:56:25 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:64102 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728980AbfHUN4Y (ORCPT ); Wed, 21 Aug 2019 09:56:24 -0400 X-UUID: 57919c60339b419581b9eca804351e33-20190821 X-UUID: 57919c60339b419581b9eca804351e33-20190821 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 2050667781; Wed, 21 Aug 2019 21:56:15 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Aug 2019 21:56:12 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 21 Aug 2019 21:56:11 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Will Deacon CC: Rob Herring , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke , , , Subject: [PATCH v10 13/23] iommu/mediatek: Refine protect memory definition Date: Wed, 21 Aug 2019 21:53:16 +0800 Message-ID: <1566395606-7975-14-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> References: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The protect memory setting is a little different in the different SoCs. In the register REG_MMU_CTRL_REG(0x110), the TF_PROT(translation fault protect) shift bit is normally 4 while it shift 5 bits only in the mt8173. This patch delete the complex MACRO and use a common if-else instead. Signed-off-by: Yong Wu Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 34f0203..947a8c6b8 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -44,12 +44,9 @@ #define REG_MMU_DCM_DIS 0x050 #define REG_MMU_CTRL_REG 0x110 +#define F_MMU_TF_PROT_TO_PROGRAM_ADDR (2 << 4) #define F_MMU_PREFETCH_RT_REPLACE_MOD BIT(4) -#define F_MMU_TF_PROTECT_SEL_SHIFT(data) \ - ((data)->plat_data->m4u_plat == M4U_MT2712 ? 4 : 5) -/* It's named by F_MMU_TF_PROT_SEL in mt2712. */ -#define F_MMU_TF_PROTECT_SEL(prot, data) \ - (((prot) & 0x3) << F_MMU_TF_PROTECT_SEL_SHIFT(data)) +#define F_MMU_TF_PROT_TO_PROGRAM_ADDR_MT8173 (2 << 5) #define REG_MMU_IVRP_PADDR 0x114 @@ -539,9 +536,11 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data) return ret; } - regval = F_MMU_TF_PROTECT_SEL(2, data); if (data->plat_data->m4u_plat == M4U_MT8173) - regval |= F_MMU_PREFETCH_RT_REPLACE_MOD; + regval = F_MMU_PREFETCH_RT_REPLACE_MOD | + F_MMU_TF_PROT_TO_PROGRAM_ADDR_MT8173; + else + regval = F_MMU_TF_PROT_TO_PROGRAM_ADDR; writel_relaxed(regval, data->base + REG_MMU_CTRL_REG); regval = F_L2_MULIT_HIT_EN | -- 1.9.1