From patchwork Tue Sep 13 15:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12974913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E311C6FA89 for ; Tue, 13 Sep 2022 15:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=A23HCJwAKEDpdfMOBaUvcLgSEZ+QnfIpYZsLLPx7uW4=; b=Jz4WoWzfOjx6n1j778mUI4pBsf iPf/tuenbdiXXJr5qZbs3UvDLkhz6twfaXPeXaen8gL0fJxZyda9uImiE0s9wXfKs6OYrkQFgc9Tc l0N5XbR0QeI4KGexXkTRUCcFl2AV++KIgRGLS4OtYfG2L/mL1SrP2Af8LxpVZJgql85HWaFzr8xna KncYxAVNZfpyvBr3d3M1AtnPQo1KA1bVTU5p4/hZAN0MUMndjmqa7v98PsFD6FWUK0dqWBwfX5WUN NW5xy7pd3iBtk2SHbluloolQnHc3vfEO766+avjBGFTKspU5HjM2SzbBtjDd/AD+AzDxJZqMZ4rRY M7ZDss4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY7kT-00CQar-Be; Tue, 13 Sep 2022 15:22:53 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY7a2-00CFo4-H3; Tue, 13 Sep 2022 15:12:09 +0000 Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7E4C96601BF7; Tue, 13 Sep 2022 16:12:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663081925; bh=cf5hsjYOn6G7Lc7ENq6TOpInHHzZ+vJ1oGSDMkkGGoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opt4PqghLEWF31cLHWZlQ1sB9rHwqyMNSHmi1XoesYTyF2l2SAcSwq0LnS6gL57/V RPmLJ6EywqP0QH0CB9Hxjf35T9bQqIph37aqYE5cXezUPo0Cnq4FtFChrMjQ9yYq3w fRNCRzOyC9+sn+TEyZdM80Hc1S0D9v2EzDkm6g9YYLm3wyFtoyohJ82XNCZBSWE5oE kGzNJ1Q3wTL/TLhTuzS1uLn9vI3k8HKNeeROUSszwtoAbWxAo+lRkU8hkz4ehPv0YG 8LUzF9OtIaAFnUznYh6nmt0tjfMiHlq9FZvIqY3n8MfrDEUzqayyPJDdC1/m86YPDj a64xbFxWRlzFg== From: AngeloGioacchino Del Regno To: joro@8bytes.org Cc: yong.wu@mediatek.com, will@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, konrad.dybcio@somainline.org, marijn.suijten@somainline.org, martin.botka@somainline.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, paul.bouchara@somainline.org, AngeloGioacchino Del Regno Subject: [PATCH v6 2/3] iommu/mediatek: Introduce new flag TF_PORT_TO_ADDR_MT8173 Date: Tue, 13 Sep 2022 17:11:47 +0200 Message-Id: <20220913151148.412312-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220913151148.412312-1-angelogioacchino.delregno@collabora.com> References: <20220913151148.412312-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_081206_758183_6B7FCF0B X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In preparation for adding support for MT6795, add a new flag named TF_PORT_TO_ADDR_MT8173 and use that instead of checking for m4u_plat type in mtk_iommu_hw_init() to avoid seeing a long list of m4u_plat checks there in the future. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7e363b1f24df..b511359376f4 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -138,6 +138,7 @@ #define PM_CLK_AO BIT(15) #define IFA_IOMMU_PCIE_SUPPORT BIT(16) #define PGTABLE_PA_35_EN BIT(17) +#define TF_PORT_TO_ADDR_MT8173 BIT(18) #define MTK_IOMMU_HAS_FLAG_MASK(pdata, _x, mask) \ ((((pdata)->flags) & (mask)) == (_x)) @@ -955,7 +956,7 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data, unsigned int ban * Global control settings are in bank0. May re-init these global registers * since no sure if there is bank0 consumers. */ - if (data->plat_data->m4u_plat == M4U_MT8173) { + if (MTK_IOMMU_HAS_FLAG(data->plat_data, TF_PORT_TO_ADDR_MT8173)) { regval = F_MMU_PREFETCH_RT_REPLACE_MOD | F_MMU_TF_PROT_TO_PROGRAM_ADDR_MT8173; } else { @@ -1427,7 +1428,8 @@ static const struct mtk_iommu_plat_data mt8167_data = { static const struct mtk_iommu_plat_data mt8173_data = { .m4u_plat = M4U_MT8173, .flags = HAS_4GB_MODE | HAS_BCLK | RESET_AXI | - HAS_LEGACY_IVRP_PADDR | MTK_IOMMU_TYPE_MM, + HAS_LEGACY_IVRP_PADDR | MTK_IOMMU_TYPE_MM | + TF_PORT_TO_ADDR_MT8173, .inv_sel_reg = REG_MMU_INV_SEL_GEN1, .banks_num = 1, .banks_enable = {true},