Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4169892pxb; Tue, 25 Jan 2022 05:04:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJywGSHyIuJxwyecCz2rmWkBiUz4Dj3BQSvniXKA54pwOFolojezjV97hNbubTwbyb5EjpZ7 X-Received: by 2002:a63:6707:: with SMTP id b7mr571338pgc.505.1643115869744; Tue, 25 Jan 2022 05:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643115869; cv=none; d=google.com; s=arc-20160816; b=EJOAeXCQ+UAWXmmkp/KSO+7YY7WDBLMkaUGL86SvMuk2Ag67dS7kzs+8gMCLhrR3zh 5iymCwBonQ8zlo7HOyPYqu5nMJIjRUE6tgvoINZeICrRCu35hK4nFuVT9iXwdLDG2b1o plL+NFSXJndrGYZRrqJH6aUnG9Kp2bm2e+IGZwI+s+7FMNUvyeZ1l4VdYwCm8UeBprK5 BIPG9efVaFfxko4fiAFePb/CsU6Ttqc430PkFxry1kPsGVW0WzN9upc1cuHzL4PeEii3 QRt9QWKWUUA9+q62D+Dh/aLQxp43dIeF3UA4MGRQKOkGuMV9pFRkxDYjLfOjrXvgxehi VVcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6wA9r0eKXv57SN5uwO1k/ngBFPbWbKBFA363+IYMe4E=; b=zAhGlT06tQ8lhmkFH5QdwtFBEBgM3N7TUFmqQpqtZKL9dk0WkTvXSx6wPbu1r5pCCd BD7jGqivnz7T3qKrB4KiUSx5E1+bw/NI5bJb4wo6U/d6+PvitZXVNnkgE3JlPVqieXRz 7lC8qxVquBgbmBDY5/tUUtAK9YwzxVRVzw489m6U6/28FNTZcmgHLj0Upqb7Hmt/jH0r NL2SAYgQMCYocXGVrEXY7ZWsj/s5CrIM11j9FSOiNlueriY/pEtLSlecmxYd/Sv0mm0X 6ZPS6Mue+BvS8oN16GQgpgeGGLAU6p00BBREC84RZi8eETJTyrgSwBluT8Q80unTMmaL Kazg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id t185si3369967pgd.351.2022.01.25.05.04.17; Tue, 25 Jan 2022 05:04:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1456061AbiAYJJL (ORCPT + 99 others); Tue, 25 Jan 2022 04:09:11 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:37260 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1454516AbiAYI7v (ORCPT ); Tue, 25 Jan 2022 03:59:51 -0500 X-UUID: 19dc5225e7804486a1639847a3fa5784-20220125 X-UUID: 19dc5225e7804486a1639847a3fa5784-20220125 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1122185969; Tue, 25 Jan 2022 16:59:09 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Tue, 25 Jan 2022 16:59:08 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Jan 2022 16:59:06 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , "Matthias Brugger" , Will Deacon CC: Robin Murphy , Krzysztof Kozlowski , Tomasz Figa , , , , , , , Hsin-Yi Wang , , , , , , "AngeloGioacchino Del Regno" , , , , Subject: [PATCH v4 16/35] iommu/mediatek: Add IOMMU_TYPE flag Date: Tue, 25 Jan 2022 16:56:15 +0800 Message-ID: <20220125085634.17972-17-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220125085634.17972-1-yong.wu@mediatek.com> References: <20220125085634.17972-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add IOMMU_TYPE definition. In the mt8195, we have another IOMMU_TYPE: infra iommu, also there will be another APU_IOMMU, thus, use 2bits for the IOMMU_TYPE. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 47d5f34f4db0..418ec0b7a43b 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -126,9 +126,17 @@ #define SHARE_PGTABLE BIT(10) /* 2 HW share pgtable */ #define DCM_DISABLE BIT(11) #define NOT_STD_AXI_MODE BIT(12) +/* 2 bits: iommu type */ +#define MTK_IOMMU_TYPE_MM (0x0 << 13) +#define MTK_IOMMU_TYPE_INFRA (0x1 << 13) +#define MTK_IOMMU_TYPE_MASK (0x3 << 13) -#define MTK_IOMMU_HAS_FLAG(pdata, _x) \ - ((((pdata)->flags) & (_x)) == (_x)) +#define MTK_IOMMU_HAS_FLAG(pdata, _x) (!!(((pdata)->flags) & (_x))) + +#define MTK_IOMMU_HAS_FLAG_MASK(pdata, _x, mask) \ + ((((pdata)->flags) & (mask)) == (_x)) +#define MTK_IOMMU_IS_TYPE(pdata, _x) MTK_IOMMU_HAS_FLAG_MASK(pdata, _x,\ + MTK_IOMMU_TYPE_MASK) struct mtk_iommu_domain { struct io_pgtable_cfg cfg; -- 2.18.0