Skip to content

Commit 7d748ff

Browse files
AngeloGioacchino Del Regnojoergroedel
authored andcommitted
iommu/mediatek: Lookup phandle to retrieve syscon to infracfg
This driver will get support for more SoCs and the list of infracfg compatibles is expected to grow: in order to prevent getting this situation out of control and see a long list of compatible strings, add support to retrieve a handle to infracfg's regmap through a new "mediatek,infracfg" phandle. In order to keep retrocompatibility with older devicetrees, the old way is kept in place. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Miles Chen <miles.chen@mediatek.com> Reviewed-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Link: https://lore.kernel.org/r/20220616110830.26037-3-angelogioacchino.delregno@collabora.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent d034dbb commit 7d748ff

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

drivers/iommu/mtk_iommu.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,22 +1140,32 @@ static int mtk_iommu_probe(struct platform_device *pdev)
11401140
data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
11411141

11421142
if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) {
1143-
switch (data->plat_data->m4u_plat) {
1144-
case M4U_MT2712:
1145-
p = "mediatek,mt2712-infracfg";
1146-
break;
1147-
case M4U_MT8173:
1148-
p = "mediatek,mt8173-infracfg";
1149-
break;
1150-
default:
1151-
p = NULL;
1143+
infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg");
1144+
if (IS_ERR(infracfg)) {
1145+
/*
1146+
* Legacy devicetrees will not specify a phandle to
1147+
* mediatek,infracfg: in that case, we use the older
1148+
* way to retrieve a syscon to infra.
1149+
*
1150+
* This is for retrocompatibility purposes only, hence
1151+
* no more compatibles shall be added to this.
1152+
*/
1153+
switch (data->plat_data->m4u_plat) {
1154+
case M4U_MT2712:
1155+
p = "mediatek,mt2712-infracfg";
1156+
break;
1157+
case M4U_MT8173:
1158+
p = "mediatek,mt8173-infracfg";
1159+
break;
1160+
default:
1161+
p = NULL;
1162+
}
1163+
1164+
infracfg = syscon_regmap_lookup_by_compatible(p);
1165+
if (IS_ERR(infracfg))
1166+
return PTR_ERR(infracfg);
11521167
}
11531168

1154-
infracfg = syscon_regmap_lookup_by_compatible(p);
1155-
1156-
if (IS_ERR(infracfg))
1157-
return PTR_ERR(infracfg);
1158-
11591169
ret = regmap_read(infracfg, REG_INFRA_MISC, &val);
11601170
if (ret)
11611171
return ret;

0 commit comments

Comments
 (0)