Commit f7b71d0d authored by Yong Wu's avatar Yong Wu Committed by Joerg Roedel
Browse files

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: default avatarYong Wu <yong.wu@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/20220503071427.2285-19-yong.wu@mediatek.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent d2e9a110
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -834,7 +834,7 @@ static const struct component_master_ops mtk_iommu_com_ops = {
static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **match,
				  struct mtk_iommu_data *data)
{
	struct device_node *larbnode, *smicomm_node;
	struct device_node *larbnode, *smicomm_node, *smi_subcomm_node;
	struct platform_device *plarbdev;
	struct device_link *link;
	int i, larb_nr, ret;
@@ -874,11 +874,21 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m
					    component_compare_of, larbnode);
	}

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

	/*
	 * It may have two level smi-common. the node is smi-sub-common if it
	 * has a new mediatek,smi property. otherwise it is smi-commmon.
	 */
	smicomm_node = of_parse_phandle(smi_subcomm_node, "mediatek,smi", 0);
	if (smicomm_node)
		of_node_put(smi_subcomm_node);
	else
		smicomm_node = smi_subcomm_node;

	plarbdev = of_find_device_by_node(smicomm_node);
	of_node_put(smicomm_node);
	data->smicomm_dev = &plarbdev->dev;