Commit c9d9f239 authored by Joerg Roedel's avatar Joerg Roedel

iommu/rockchip: Make use of 'struct iommu_device'

Register hardware IOMMUs seperatly with the iommu-core code
and add a sysfs representation of the iommu topology.
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent c02ed2e7
...@@ -90,6 +90,7 @@ struct rk_iommu { ...@@ -90,6 +90,7 @@ struct rk_iommu {
void __iomem **bases; void __iomem **bases;
int num_mmu; int num_mmu;
int irq; int irq;
struct iommu_device iommu;
struct list_head node; /* entry in rk_iommu_domain.iommus */ struct list_head node; /* entry in rk_iommu_domain.iommus */
struct iommu_domain *domain; /* domain to which iommu is attached */ struct iommu_domain *domain; /* domain to which iommu is attached */
}; };
...@@ -1032,6 +1033,7 @@ static int rk_iommu_group_set_iommudata(struct iommu_group *group, ...@@ -1032,6 +1033,7 @@ static int rk_iommu_group_set_iommudata(struct iommu_group *group,
static int rk_iommu_add_device(struct device *dev) static int rk_iommu_add_device(struct device *dev)
{ {
struct iommu_group *group; struct iommu_group *group;
struct rk_iommu *iommu;
int ret; int ret;
if (!rk_iommu_is_dev_iommu_master(dev)) if (!rk_iommu_is_dev_iommu_master(dev))
...@@ -1054,6 +1056,10 @@ static int rk_iommu_add_device(struct device *dev) ...@@ -1054,6 +1056,10 @@ static int rk_iommu_add_device(struct device *dev)
if (ret) if (ret)
goto err_remove_device; goto err_remove_device;
iommu = rk_iommu_from_dev(dev);
if (iommu)
iommu_device_link(&iommu->iommu, dev);
iommu_group_put(group); iommu_group_put(group);
return 0; return 0;
...@@ -1067,9 +1073,15 @@ static int rk_iommu_add_device(struct device *dev) ...@@ -1067,9 +1073,15 @@ static int rk_iommu_add_device(struct device *dev)
static void rk_iommu_remove_device(struct device *dev) static void rk_iommu_remove_device(struct device *dev)
{ {
struct rk_iommu *iommu;
if (!rk_iommu_is_dev_iommu_master(dev)) if (!rk_iommu_is_dev_iommu_master(dev))
return; return;
iommu = rk_iommu_from_dev(dev);
if (iommu)
iommu_device_unlink(&iommu->iommu, dev);
iommu_group_remove_device(dev); iommu_group_remove_device(dev);
} }
...@@ -1117,7 +1129,7 @@ static int rk_iommu_probe(struct platform_device *pdev) ...@@ -1117,7 +1129,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
struct rk_iommu *iommu; struct rk_iommu *iommu;
struct resource *res; struct resource *res;
int num_res = pdev->num_resources; int num_res = pdev->num_resources;
int i; int err, i;
iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL); iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL);
if (!iommu) if (!iommu)
...@@ -1150,11 +1162,25 @@ static int rk_iommu_probe(struct platform_device *pdev) ...@@ -1150,11 +1162,25 @@ static int rk_iommu_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
return 0; err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
if (err)
return err;
iommu_device_set_ops(&iommu->iommu, &rk_iommu_ops);
err = iommu_device_register(&iommu->iommu);
return err;
} }
static int rk_iommu_remove(struct platform_device *pdev) static int rk_iommu_remove(struct platform_device *pdev)
{ {
struct rk_iommu *iommu = platform_get_drvdata(pdev);
if (iommu) {
iommu_device_sysfs_remove(&iommu->iommu);
iommu_device_unregister(&iommu->iommu);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment