Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1449231ybl; Fri, 23 Aug 2019 20:45:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9ZSz9ScX1FEHejU4VPXl6DTIymtHiyDLgcyIaqtd+rGMm4vQeOPWM71AJFGgxBOTNj03F X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11mr8138246plb.93.1566618324230; Fri, 23 Aug 2019 20:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566618324; cv=none; d=google.com; s=arc-20160816; b=Balz09THIXWai4/SRuXrbpBezdc6c/xILGHP34b1Pmc6v/DYp8iBJtqkac3fzdWzOD K6moW5ZQIcr20whx94um3Hl2Dda//H6z0FP/Da3ujRiEjGV7CWRGdDgbYPjUlgjX2z5o Cp+Gvmh2HhfI4ryS5RufnnyaU1juI7r8Ez9JKc5B+DCcEbj8o8xtfdW2974dVo9bu6Va uYePy8QMN+x1IxOLZQWY6AGSJ82/x95y1GdHXr+taEUNP5CNmCp/U/FaECYYXNn5vdvv jw4BfOucJdQ/E0BfqgZ/3K3UknPoE9HWMsGDIiUsxBbIwTEoKhD8ZVSnDUiFUwGA6FLd fEUw== 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=u02uu1zRaryxSD2AmJp4axUqs2QvzkJnM0pwFoEIc5AX9kSeldAblUKH2FmsQ55F9c 5KaVTlZpFQOXIiDlu66/kM5ibI6obZsq4f/l7iE5R8gztPkcaD/QuiEQIFI07x6Oi6+7 v+dnEWqZjajTzWfGC7RCHjgyKjJPfSbmoCjc7Z/9IIKDx+KKVhCXOkqhhTERnruV7/MR wQdQM9Gh4Qe+nQtPCEGuBZmQ3wsso1aIUprtgjfNT6olyaqq5TsX+rEL9xzLzs39m2rR CJRxbDK2pgx4IjLCzkNHQwGyyd6wXlF1TnCoupLEYle5mU42hMZq5j8AsGExSukob9aA 1llw== 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 b6si4144015pfd.29.2019.08.23.20.45.09; Fri, 23 Aug 2019 20:45:24 -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 S1727168AbfHXDn7 (ORCPT + 99 others); Fri, 23 Aug 2019 23:43:59 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:35950 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726436AbfHXDnp (ORCPT ); Fri, 23 Aug 2019 23:43:45 -0400 X-UUID: fbc101e3f394400c904322ae2216d8a9-20190824 X-UUID: fbc101e3f394400c904322ae2216d8a9-20190824 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 740457057; Sat, 24 Aug 2019 11:05:23 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 24 Aug 2019 11:05:15 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sat, 24 Aug 2019 11:05:14 +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 v11 13/23] iommu/mediatek: Refine protect memory definition Date: Sat, 24 Aug 2019 11:01:58 +0800 Message-ID: <1566615728-26388-14-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566615728-26388-1-git-send-email-yong.wu@mediatek.com> References: <1566615728-26388-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