Skip to content

Commit aa759fd

Browse files
mszyprowjoergroedel
authored andcommitted
iommu/exynos: Add callback for initializing devices from device tree
This patch adds implementation of of_xlate callback, which prepares masters device for attaching to IOMMU. This callback is called during creating devices from device tree. Signed-off-by: Marek Szyprowski <[email protected]> Tested-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8ed55c8 commit aa759fd

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

drivers/iommu/exynos-iommu.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,33 @@ static void exynos_iommu_remove_device(struct device *dev)
11461146
iommu_group_remove_device(dev);
11471147
}
11481148

1149+
static int exynos_iommu_of_xlate(struct device *dev,
1150+
struct of_phandle_args *spec)
1151+
{
1152+
struct exynos_iommu_owner *owner = dev->archdata.iommu;
1153+
struct platform_device *sysmmu = of_find_device_by_node(spec->np);
1154+
struct sysmmu_drvdata *data;
1155+
1156+
if (!sysmmu)
1157+
return -ENODEV;
1158+
1159+
data = platform_get_drvdata(sysmmu);
1160+
if (!data)
1161+
return -ENODEV;
1162+
1163+
if (!owner) {
1164+
owner = kzalloc(sizeof(*owner), GFP_KERNEL);
1165+
if (!owner)
1166+
return -ENOMEM;
1167+
1168+
INIT_LIST_HEAD(&owner->controllers);
1169+
dev->archdata.iommu = owner;
1170+
}
1171+
1172+
list_add_tail(&data->owner_node, &owner->controllers);
1173+
return 0;
1174+
}
1175+
11491176
static struct iommu_ops exynos_iommu_ops = {
11501177
.domain_alloc = exynos_iommu_domain_alloc,
11511178
.domain_free = exynos_iommu_domain_free,
@@ -1158,6 +1185,7 @@ static struct iommu_ops exynos_iommu_ops = {
11581185
.add_device = exynos_iommu_add_device,
11591186
.remove_device = exynos_iommu_remove_device,
11601187
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
1188+
.of_xlate = exynos_iommu_of_xlate,
11611189
};
11621190

11631191
static bool init_done;

0 commit comments

Comments
 (0)