Skip to content

Commit f7b71d0

Browse files
YongWu-HFjoergroedel
authored andcommitted
iommu/mediatek: Adjust device link when it is sub-common
For MM IOMMU, We always add device link between smi-common and IOMMU HW. In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still need find again to get smi-common, then do device link. Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Link: https://lore.kernel.org/r/20220503071427.2285-19-yong.wu@mediatek.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent d2e9a11 commit f7b71d0

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/iommu/mtk_iommu.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ static const struct component_master_ops mtk_iommu_com_ops = {
834834
static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **match,
835835
struct mtk_iommu_data *data)
836836
{
837-
struct device_node *larbnode, *smicomm_node;
837+
struct device_node *larbnode, *smicomm_node, *smi_subcomm_node;
838838
struct platform_device *plarbdev;
839839
struct device_link *link;
840840
int i, larb_nr, ret;
@@ -874,11 +874,21 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m
874874
component_compare_of, larbnode);
875875
}
876876

877-
/* Get smi-common dev from the last larb. */
878-
smicomm_node = of_parse_phandle(larbnode, "mediatek,smi", 0);
879-
if (!smicomm_node)
877+
/* Get smi-(sub)-common dev from the last larb. */
878+
smi_subcomm_node = of_parse_phandle(larbnode, "mediatek,smi", 0);
879+
if (!smi_subcomm_node)
880880
return -EINVAL;
881881

882+
/*
883+
* It may have two level smi-common. the node is smi-sub-common if it
884+
* has a new mediatek,smi property. otherwise it is smi-commmon.
885+
*/
886+
smicomm_node = of_parse_phandle(smi_subcomm_node, "mediatek,smi", 0);
887+
if (smicomm_node)
888+
of_node_put(smi_subcomm_node);
889+
else
890+
smicomm_node = smi_subcomm_node;
891+
882892
plarbdev = of_find_device_by_node(smicomm_node);
883893
of_node_put(smicomm_node);
884894
data->smicomm_dev = &plarbdev->dev;

0 commit comments

Comments
 (0)