Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3795194pxu; Wed, 9 Dec 2020 00:12:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+LrLJdljJuLMaUfRkyMp4NXG9TnGGc2QOmyttO2vZkRIgTjDC2Tl6NyFFJnVxYrqnK2pZ X-Received: by 2002:a17:906:5c53:: with SMTP id c19mr1077187ejr.31.1607501525492; Wed, 09 Dec 2020 00:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607501525; cv=none; d=google.com; s=arc-20160816; b=0nuzG9CZTcg9ZWI53VrCIk/Nm+76AI2C6js0FQYH30olZUJeyrw+g/n5hKEoZLjQw4 z5Vzm1t5VSIAuePPATAuuxA55/dsxFdF4083807IazRohNqouKjJ8O6Qc2BQUN1jC6zn yHcYyWJNuHJnqF8A9CW9kZlUuG3C3fYZzbhnxstMioeT6YPqj6JtGbP2XUbtnUiNi+9D 0GAD8DA2cYSwulqVFkjUwk1KZx+bSu1J4ol+oSU3iq2N2bsGl0R0DldLaUuzgoqxqOLP aTS/7UpTNu+lh7958OpRZNwfcuZyxTzYvWXOm2wdaCSbwSTtacmv3vVV+MVg9jDSfUOa 38gA== 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=f8+uVbNihiyhIQw+ya6wWKLVrkVBwFzZL4ApG8CTjpQ=; b=sGOtCKl3jbBKtjytocuj9jqmNvwQEirxtdVAD7tm8lTKPXRctCSMNztDXd4cPqyMvi Azq2DVLluAIopj9/85OLI9UNyOouEgaHnq+fxUtlTXEgDQna6Jana9jORr66MJIXWXw7 9uJdJzJlkx96PMiTfPDp0I8Fvv2w+RGhUcRK2TSy9sm1qq39fdmonF/10rW/N0dMPVNj lk4y/6lyCN2v5cf4M5aCScbmX+yKoFmbSdMpLuKFYCq1OOqKu4joq8LAnlFCMFkaC4QE UCK7YfOdFYlw+IrTeirubCP6Tm2dxuzjbTGAapCTMAxj1yrIGsoAcqF2jjbu3K5Du+o3 yxvA== 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 m64si472315ede.159.2020.12.09.00.11.43; Wed, 09 Dec 2020 00:12:05 -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 S1728897AbgLIIGV (ORCPT + 99 others); Wed, 9 Dec 2020 03:06:21 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:47650 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728860AbgLIIGC (ORCPT ); Wed, 9 Dec 2020 03:06:02 -0500 X-UUID: 98d6b5e88fc4486ea459ffa97c9c8ccf-20201209 X-UUID: 98d6b5e88fc4486ea459ffa97c9c8ccf-20201209 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2117350880; Wed, 09 Dec 2020 16:05:20 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 16:05:18 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 16:05:18 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v5 26/27] iommu/mediatek: Add mt8192 support Date: Wed, 9 Dec 2020 16:01:01 +0800 Message-ID: <20201209080102.26626-27-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201209080102.26626-1-yong.wu@mediatek.com> References: <20201209080102.26626-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 mt8192 iommu support. For multi domain, Add 1M gap for the vdec domain size. That is because vdec HW has a end address register which require (start_addr + len) rather than (start_addr + len - 1). Take a example, if the start_addr is 0xfff00000, size is 0x100000, then the end_address is 0xfff00000 + 0x100000 = 0x1 0000 0000. but the register only is 32bit. thus HW will get the end address is 0. To avoid this issue, I add 1M gap for this. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 22 ++++++++++++++++++++++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 92c1e2f0af89..799adf7b39d3 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -174,6 +174,16 @@ static const struct mtk_iommu_iova_region single_domain[] = { {.iova_base = 0, .size = SZ_4G}, }; +static const struct mtk_iommu_iova_region mt8192_multi_dom[] = { + { .iova_base = 0x0, .size = SZ_4G}, /* disp: 0 ~ 4G */ + #if IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) + { .iova_base = SZ_4G, .size = SZ_4G - SZ_1M}, /* vdec: 4G ~ 8G gap: 1M */ + { .iova_base = SZ_4G * 2, .size = SZ_4G - SZ_1M}, /* CAM/MDP: 8G ~ 12G */ + { .iova_base = 0x240000000ULL, .size = 0x4000000}, /* CCU0 */ + { .iova_base = 0x244000000ULL, .size = 0x4000000}, /* CCU1 */ + #endif +}; + /* * There may be 1 or 2 M4U HWs, But we always expect they are in the same domain * for the performance. @@ -1035,12 +1045,24 @@ static const struct mtk_iommu_plat_data mt8183_data = { .larbid_remap = {{0}, {4}, {5}, {6}, {7}, {2}, {3}, {1}}, }; +static const struct mtk_iommu_plat_data mt8192_data = { + .m4u_plat = M4U_MT8192, + .flags = HAS_BCLK | HAS_SUB_COMM | OUT_ORDER_WR_EN | + WR_THROT_EN | IOVA_34_EN, + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, + .iova_region = mt8192_multi_dom, + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .larbid_remap = {{0}, {1}, {4, 5}, {7}, {2}, {9, 11, 19, 20}, + {0, 14, 16}, {0, 13, 18, 17}}, +}; + static const struct of_device_id mtk_iommu_of_ids[] = { { .compatible = "mediatek,mt2712-m4u", .data = &mt2712_data}, { .compatible = "mediatek,mt6779-m4u", .data = &mt6779_data}, { .compatible = "mediatek,mt8167-m4u", .data = &mt8167_data}, { .compatible = "mediatek,mt8173-m4u", .data = &mt8173_data}, { .compatible = "mediatek,mt8183-m4u", .data = &mt8183_data}, + { .compatible = "mediatek,mt8192-m4u", .data = &mt8192_data}, {} }; diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index b54862307128..e96b1b8639f4 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -43,6 +43,7 @@ enum mtk_iommu_plat { M4U_MT8167, M4U_MT8173, M4U_MT8183, + M4U_MT8192, }; struct mtk_iommu_iova_region; -- 2.18.0