From: Matthias Brugger <matthias.bgg@gmail.com>
To: Yong Wu <yong.wu@mediatek.com>, Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Rob Herring <robh+dt@kernel.org>
Cc: Tomasz Figa <tfiga@google.com>, Will Deacon <will.deacon@arm.com>,
linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
iommu@lists.linux-foundation.org, arnd@arndb.de,
yingjoe.chen@mediatek.com, youlin.pei@mediatek.com,
Nicolas Boichat <drinkcat@chromium.org>,
Arvind Yadav <arvind.yadav.cs@gmail.com>
Subject: Re: [PATCH v4 02/18] iommu/mediatek: Use a struct as the platform data
Date: Fri, 21 Dec 2018 18:44:55 +0100 [thread overview]
Message-ID: <be32c912-359e-73c9-ca24-d0cbface47d3@gmail.com> (raw)
In-Reply-To: <1544258371-4600-3-git-send-email-yong.wu@mediatek.com>
On 08/12/2018 09:39, Yong Wu wrote:
> Use a struct as the platform special data instead of the enumeration.
> This is a prepare patch for adding mt8183 iommu support.
>
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> drivers/iommu/mtk_iommu.c | 24 ++++++++++++++++--------
> drivers/iommu/mtk_iommu.h | 6 +++++-
> 2 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 44bd5b9..9a2225b 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -54,7 +54,7 @@
> #define REG_MMU_CTRL_REG 0x110
> #define F_MMU_PREFETCH_RT_REPLACE_MOD BIT(4)
> #define F_MMU_TF_PROTECT_SEL_SHIFT(data) \
> - ((data)->m4u_plat == M4U_MT2712 ? 4 : 5)
> + ((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))
> @@ -517,7 +517,7 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
> }
>
> regval = F_MMU_TF_PROTECT_SEL(2, data);
> - if (data->m4u_plat == M4U_MT8173)
> + if (data->plat_data->m4u_plat == M4U_MT8173)
> regval |= F_MMU_PREFETCH_RT_REPLACE_MOD;
> writel_relaxed(regval, data->base + REG_MMU_CTRL_REG);
>
> @@ -538,14 +538,14 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
> F_INT_PRETETCH_TRANSATION_FIFO_FAULT;
> writel_relaxed(regval, data->base + REG_MMU_INT_MAIN_CONTROL);
>
> - if (data->m4u_plat == M4U_MT8173)
> + if (data->plat_data->m4u_plat == M4U_MT8173)
> regval = (data->protect_base >> 1) | (data->enable_4GB << 31);
> else
> regval = lower_32_bits(data->protect_base) |
> upper_32_bits(data->protect_base);
> writel_relaxed(regval, data->base + REG_MMU_IVRP_PADDR);
>
> - if (data->enable_4GB && data->m4u_plat != M4U_MT8173) {
> + if (data->enable_4GB && data->plat_data->m4u_plat != M4U_MT8173) {
> /*
> * If 4GB mode is enabled, the validate PA range is from
> * 0x1_0000_0000 to 0x1_ffff_ffff. here record bit[32:30].
> @@ -556,7 +556,7 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
> writel_relaxed(0, data->base + REG_MMU_DCM_DIS);
>
> /* It's MISC control register whose default value is ok except mt8173.*/
> - if (data->m4u_plat == M4U_MT8173)
> + if (data->plat_data->m4u_plat == M4U_MT8173)
> writel_relaxed(0, data->base + REG_MMU_STANDARD_AXI_MODE);
>
> if (devm_request_irq(data->dev, data->irq, mtk_iommu_isr, 0,
> @@ -589,7 +589,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> if (!data)
> return -ENOMEM;
> data->dev = dev;
> - data->m4u_plat = (enum mtk_iommu_plat)of_device_get_match_data(dev);
> + data->plat_data = of_device_get_match_data(dev);
>
> /* Protect memory. HW will access here while translation fault.*/
> protect = devm_kzalloc(dev, MTK_PROTECT_PA_ALIGN * 2, GFP_KERNEL);
> @@ -733,9 +733,17 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev)
> SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_iommu_suspend, mtk_iommu_resume)
> };
>
> +static const struct mtk_iommu_plat_data mt2712_data = {
> + .m4u_plat = M4U_MT2712,
> +};
> +
> +static const struct mtk_iommu_plat_data mt8173_data = {
> + .m4u_plat = M4U_MT8173,
> +};
> +
> static const struct of_device_id mtk_iommu_of_ids[] = {
> - { .compatible = "mediatek,mt2712-m4u", .data = (void *)M4U_MT2712},
> - { .compatible = "mediatek,mt8173-m4u", .data = (void *)M4U_MT8173},
> + { .compatible = "mediatek,mt2712-m4u", .data = &mt2712_data},
> + { .compatible = "mediatek,mt8173-m4u", .data = &mt8173_data},
> {}
> };
>
> diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h
> index 778498b..333a0ef 100644
> --- a/drivers/iommu/mtk_iommu.h
> +++ b/drivers/iommu/mtk_iommu.h
> @@ -41,6 +41,10 @@ enum mtk_iommu_plat {
> M4U_MT8173,
> };
>
> +struct mtk_iommu_plat_data {
> + enum mtk_iommu_plat m4u_plat;
> +};
> +
> struct mtk_iommu_domain;
>
> struct mtk_iommu_data {
> @@ -57,7 +61,7 @@ struct mtk_iommu_data {
> bool tlb_flush_active;
>
> struct iommu_device iommu;
> - enum mtk_iommu_plat m4u_plat;
> + const struct mtk_iommu_plat_data *plat_data;
>
> struct list_head list;
> };
>
next prev parent reply other threads:[~2018-12-21 17:45 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-08 8:39 [PATCH v4 00/18] MT8183 IOMMU SUPPORT Yong Wu
2018-12-08 8:39 ` [PATCH v4 01/18] dt-bindings: mediatek: Add binding for mt8183 IOMMU and SMI Yong Wu
2018-12-08 8:39 ` [PATCH v4 02/18] iommu/mediatek: Use a struct as the platform data Yong Wu
2018-12-21 17:44 ` Matthias Brugger [this message]
2018-12-08 8:39 ` [PATCH v4 03/18] memory: mtk-smi: Use a general config_port interface Yong Wu
2018-12-21 17:47 ` Matthias Brugger
2018-12-22 3:57 ` Yong Wu
2018-12-08 8:39 ` [PATCH v4 04/18] memory: mtk-smi: Use a struct for the platform data for smi-common Yong Wu
2018-12-21 17:49 ` Matthias Brugger
2018-12-08 8:39 ` [PATCH v4 05/18] iommu/io-pgtable-arm-v7s: Add paddr_to_iopte and iopte_to_paddr helpers Yong Wu
2018-12-08 8:39 ` [PATCH v4 06/18] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode Yong Wu
2018-12-08 8:39 ` [PATCH v4 07/18] iommu/mediatek: Add bclk can be supported optionally Yong Wu
2018-12-08 8:39 ` [PATCH v4 08/18] iommu/mediatek: Add larb-id remapped support Yong Wu
2018-12-21 3:35 ` Nicolas Boichat
2018-12-21 8:02 ` Yong Wu
2018-12-08 8:39 ` [PATCH v4 09/18] memory: mtk-smi: Add gals support Yong Wu
2018-12-08 8:39 ` [PATCH v4 10/18] iommu/mediatek: Add mt8183 IOMMU support Yong Wu
2018-12-21 4:43 ` Nicolas Boichat
2018-12-21 8:02 ` Yong Wu
2018-12-22 0:31 ` Nicolas Boichat
2018-12-22 3:57 ` Yong Wu
2018-12-21 18:31 ` Matthias Brugger
2018-12-22 3:58 ` Yong Wu
2018-12-08 8:39 ` [PATCH v4 11/18] iommu/mediatek: Add mmu1 support Yong Wu
2018-12-08 8:39 ` [PATCH v4 12/18] memory: mtk-smi: Invoke pm runtime_callback to enable clocks Yong Wu
2018-12-08 8:39 ` [PATCH v4 13/18] memory: mtk-smi: Add bus_sel for mt8183 Yong Wu
2018-12-21 4:47 ` Nicolas Boichat
2018-12-21 8:02 ` Yong Wu
2018-12-08 8:39 ` [PATCH v4 14/18] iommu/mediatek: Fix VLD_PA_RANGE register backup when suspend Yong Wu
2018-12-08 8:39 ` [PATCH v4 15/18] iommu/mediatek: Add shutdown callback Yong Wu
2018-12-08 8:39 ` [PATCH v4 16/18] memory: mtk-smi: Get rid of need_larbid Yong Wu
2018-12-08 8:39 ` [PATCH v4 17/18] iommu/mediatek: Constify iommu_ops Yong Wu
2018-12-08 8:39 ` [PATCH v4 18/18] iommu/mediatek: Switch to SPDX license identifier Yong Wu
2018-12-11 9:52 ` [PATCH v4 00/18] MT8183 IOMMU SUPPORT Joerg Roedel
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=be32c912-359e-73c9-ca24-d0cbface47d3@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=arnd@arndb.de \
--cc=arvind.yadav.cs@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=drinkcat@chromium.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@google.com \
--cc=will.deacon@arm.com \
--cc=yingjoe.chen@mediatek.com \
--cc=yong.wu@mediatek.com \
--cc=youlin.pei@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;
as well as URLs for NNTP newsgroup(s).