From: Flora Fu <flora.fu@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Yong Wu <yong.wu@mediatek.com>,
Pi-Cheng Chen <pi-cheng.chen@mediatek.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>,
Flora Fu <flora.fu@mediatek.com>, JB Tsai <jb.tsai@mediatek.com>
Subject: [PATCH 07/17] iommu/mediatek: Support APU iommu and config data for mt8192
Date: Sat, 11 Dec 2021 01:25:55 +0800 [thread overview]
Message-ID: <20211210172605.30618-8-flora.fu@mediatek.com> (raw)
In-Reply-To: <20211210172605.30618-1-flora.fu@mediatek.com>
APU IOMMU is a new iommu HW. it uses a new pagetable.
Add support for mt8192 apu iommu.
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Signed-off-by: Flora Fu <flora.fu@mediatek.com>
---
drivers/iommu/mtk_iommu.c | 45 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 8377f3c37283..4bc7c76062e6 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -133,6 +133,7 @@
/* 2 bits: iommu type */
#define MTK_IOMMU_TYPE_MM (0x0 << 13)
#define MTK_IOMMU_TYPE_INFRA (0x1 << 13)
+#define MTK_IOMMU_TYPE_APU (0x2 << 13)
#define MTK_IOMMU_TYPE_MASK (0x3 << 13)
#define IFA_IOMMU_PCIe_SUPPORT BIT(15)
@@ -185,6 +186,7 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data, unsigned int ban
#define MTK_IOMMU_4GB_MODE_REMAP_BASE 0x140000000UL
static LIST_HEAD(m4ulist); /* List all the M4U HWs */
+static LIST_HEAD(apulist); /* List the apu iommu HWs */
#define for_each_m4u(data, head) list_for_each_entry(data, head, list)
@@ -209,6 +211,13 @@ static const struct mtk_iommu_iova_region mt8192_multi_dom[] = {
#endif
};
+static const struct mtk_iommu_iova_region mt8192_multi_dom_apu[] = {
+ { .iova_base = 0x0, .size = SZ_4G}, /* APU DATA */
+ { .iova_base = 0x4000000ULL, .size = 0x4000000}, /* APU VLM */
+ { .iova_base = 0x10000000ULL, .size = 0x10000000}, /* APU VPU */
+ { .iova_base = 0x70000000ULL, .size = 0x12600000}, /* APU REG */
+};
+
/* If 2 M4U share a domain(use the same hwlist), Put the corresponding info in first data.*/
static struct mtk_iommu_data *mtk_iommu_get_frst_data(struct list_head *hwlist)
{
@@ -638,24 +647,45 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
{
+ unsigned int flag = DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS;
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
- struct mtk_iommu_data *data;
+ struct mtk_iommu_data *data, *curdata;
+ struct device_link *link;
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
return ERR_PTR(-ENODEV); /* Not a iommu client device */
data = dev_iommu_priv_get(dev);
+ if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_APU)) {
+ /*
+ * The APU IOMMU HWs must work together. The consumer device
+ * must connect with all the apu iommu HWs at the same time.
+ */
+ for_each_m4u(curdata, data->hw_list) {
+ link = device_link_add(dev, curdata->dev, flag);
+ if (!link)
+ dev_err(dev, "Unable to link %s\n", dev_name(curdata->dev));
+ }
+ }
return &data->iommu;
}
static void mtk_iommu_release_device(struct device *dev)
{
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
+ struct mtk_iommu_data *data;
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
return;
+ data = dev_iommu_priv_get(dev);
+ if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_APU)) {
+ struct list_head *head = data->hw_list;
+
+ for_each_m4u(data, head)
+ device_link_remove(dev, data->dev);
+ }
iommu_fwspec_free(dev);
}
@@ -1270,6 +1300,18 @@ static const struct mtk_iommu_plat_data mt8192_data = {
{0, 14, 16}, {0, 13, 18, 17}},
};
+static const struct mtk_iommu_plat_data mt8192_data_apu = {
+ .m4u_plat = M4U_MT8192,
+ .flags = DCM_DISABLE | MTK_IOMMU_TYPE_APU |
+ SHARE_PGTABLE,
+ .inv_sel_reg = REG_MMU_INV_SEL_GEN2,
+ .hw_list = &apulist,
+ .bank_nr = 1,
+ .bank_enable = {true},
+ .iova_region = mt8192_multi_dom_apu,
+ .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom_apu),
+};
+
static const struct mtk_iommu_plat_data mt8195_data_infra = {
.m4u_plat = M4U_MT8195,
.flags = WR_THROT_EN | DCM_DISABLE |
@@ -1325,6 +1367,7 @@ static const struct of_device_id mtk_iommu_of_ids[] = {
{ .compatible = "mediatek,mt8173-m4u", .data = &mt8173_data},
{ .compatible = "mediatek,mt8183-m4u", .data = &mt8183_data},
{ .compatible = "mediatek,mt8192-m4u", .data = &mt8192_data},
+ { .compatible = "mediatek,mt8192-iommu-apu", .data = &mt8192_data_apu},
{ .compatible = "mediatek,mt8195-iommu-infra", .data = &mt8195_data_infra},
{ .compatible = "mediatek,mt8195-iommu-vdo", .data = &mt8195_data_vdo},
{ .compatible = "mediatek,mt8195-iommu-vpp", .data = &mt8195_data_vpp},
--
2.18.0
next prev parent reply other threads:[~2021-12-10 17:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 17:25 [PATCH 00/17] MediaTek MT8192 APU Flora Fu
2021-12-10 17:25 ` [PATCH 01/17] dt-bindings: mailbox: mediatek: Add APU mailbox compatible Flora Fu
2021-12-10 17:25 ` [PATCH 02/17] dt-bindings: memory: mediatek: Add MT8192 apu iommu bindings Flora Fu
2021-12-10 17:25 ` [PATCH 03/17] dt-bindings: remoteproc: mediatek: Add APU rproc compatible Flora Fu
2021-12-10 17:25 ` [PATCH 04/17] dt-bindings: soc: mediatek: apu: Add APU power compatible Flora Fu
2021-12-10 17:25 ` [PATCH 05/17] dt-bindings: soc: mediatek: apu: Add apu logger compatible Flora Fu
2021-12-10 17:25 ` [PATCH 06/17] mailbox: mediatek: add mtk-apu-mailbox driver Flora Fu
2021-12-10 17:25 ` Flora Fu [this message]
2021-12-10 17:25 ` [PATCH 08/17] remoteproc: mediatek: Add APU remoteproc driver Flora Fu
2021-12-10 17:25 ` [PATCH 09/17] soc: mediatek: apu: Add Apu power driver Flora Fu
2021-12-10 17:25 ` [PATCH 10/17] soc: mediatek: apu: Add APU software logger dirver Flora Fu
2021-12-10 17:25 ` [PATCH 11/17] soc: mediatek: apu: Add middleware driver Flora Fu
2021-12-10 17:26 ` [PATCH 12/17] arm64: dts: mt8192: Add APU mtk-apu-mailbox node Flora Fu
2021-12-10 17:26 ` [PATCH 13/17] arm64: dts: mt8192: Add APU-IOMMU nodes Flora Fu
2021-12-10 17:26 ` [PATCH 14/17] arm64: dts: mt8192: Add apu tinysys node Flora Fu
2021-12-10 17:26 ` [PATCH 15/17] arm64: dts: mt8192: Add APU power nodes Flora Fu
2021-12-10 17:26 ` [PATCH 16/17] arm64: dts: mt8192: Add apu-sw-logger node Flora Fu
2021-12-10 17:26 ` [PATCH 17/17] arm64: dts: mt8192: Set up regulators for APU subsys Flora Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211210172605.30618-8-flora.fu@mediatek.com \
--to=flora.fu@mediatek.com \
--cc=broonie@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jb.tsai@mediatek.com \
--cc=lgirdwood@gmail.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=pi-cheng.chen@mediatek.com \
--cc=sumit.semwal@linaro.org \
--cc=yong.wu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®