Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1247830imj; Sun, 17 Feb 2019 01:15:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYyq31jeLm44nXALumygE26XyzmZKIPjf+kiR37QWLcR72w9yY8eoUbYZnmdJUT5W/20yot X-Received: by 2002:a17:902:bd96:: with SMTP id q22mr8150551pls.7.1550394952718; Sun, 17 Feb 2019 01:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550394952; cv=none; d=google.com; s=arc-20160816; b=EBA+YsmmWcEF/7qnc4Dg/cALQS2bEeFcqOog28Hxce+L/SdTnu0IF6Dcx9a3YVVUXF KZy67fr93CpDqX9RD69u+9ZwzEeyrjQSdb+CFv3ktXEdL5SxdV9XmAcZEfSh9WNbiICg QeZ1YKaarOkpIDojukuwxk559E9Xa5prno+fZEn2fXgbMBBYS+f7hlOQX22dZqQX4lFA utbpPdj558SVbV7BZvwEyAmcvpmOIlzRIBoZO5QCpjhIJph+KptHMTfLpLkxlzClfiO9 VFlaRwYB97ijK5VsHG5vb43ttb9ZMV54g8Lrw09LgTiRCuyqsxX88m0szj1BNZegqG1K 4Q+g== 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=elMV7dpuyQg8lezRIGUOUOp3qSnglz/O/ZLuTyqh5WU=; b=1GyODv7zx7pIbyMIL1gBUVnuyRwALHt+9O/XBT38jYlBJMxbOK/rzn8B/wLLqJ1zsD /4XedaC5VqsyxEZa5J285ZfPo1eoOODlwQu0B68oj84Tk0+5IVYKzsnaSEDgUvoNZ28y hk8tW8HdgwXK6s1UUfj+rzS5dWwRVgLIYR+eYVjorjAul2Y4PPRwbyfjYiUhteC0a8XX lXPpLz/7V1q+67jZZFaD+StbArGxGXP1gcnkQ3gXbwGMEnhpEVC+fuy8MsMajxRmUqp1 8OmxZwDnKwScrTmr919eI1zuy3QPvh224KNKCKMr7czhP7tdI2cxB+2gqosoij2flz7K 3kww== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si4036396pla.52.2019.02.17.01.15.36; Sun, 17 Feb 2019 01:15:52 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfBQJIF (ORCPT + 99 others); Sun, 17 Feb 2019 04:08:05 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:25678 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727383AbfBQJIF (ORCPT ); Sun, 17 Feb 2019 04:08:05 -0500 X-UUID: eefc20b932dd4443b2d06391cccbdc40-20190217 X-UUID: eefc20b932dd4443b2d06391cccbdc40-20190217 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1893071995; Sun, 17 Feb 2019 17:07:58 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 17 Feb 2019 17:07:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sun, 17 Feb 2019 17:07:55 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Evan Green , Tomasz Figa , Will Deacon , , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke Subject: [PATCH v6 09/22] iommu/mediatek: Refine protect memory definition Date: Sun, 17 Feb 2019 17:04:47 +0800 Message-ID: <1550394300-17420-10-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550394300-17420-1-git-send-email-yong.wu@mediatek.com> References: <1550394300-17420-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 --- 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 3bf7b76..483f6e8 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -52,12 +52,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 @@ -519,9 +516,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