iommu/pamu: Add support for generic iommu-device

This patch adds a global iommu-handle to the pamu driver and
initializes it at probe time. Also link devices added to the
iommu to this handle.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
Joerg Roedel
2017-08-09 16:36:00 +02:00
parent 07eb6fdf49
commit 68a17f0be6
4 changed files with 26 additions and 1 deletions

View File

@@ -44,6 +44,8 @@ static struct paace *spaact;
static bool probed; /* Has PAMU been probed? */
struct iommu_device pamu_iommu; /* IOMMU core code handle */
/*
* Table for matching compatible strings, for device tree
* guts node, for QorIQ SOCs.
@@ -1154,6 +1156,18 @@ static int fsl_pamu_probe(struct platform_device *pdev)
if (ret)
goto error_genpool;
ret = iommu_device_sysfs_add(&pamu_iommu, dev, NULL, "iommu0");
if (ret)
goto error_genpool;
iommu_device_set_ops(&pamu_iommu, &fsl_pamu_ops);
ret = iommu_device_register(&pamu_iommu);
if (ret) {
dev_err(dev, "Can't register iommu device\n");
goto error_sysfs;
}
pamubypenr = in_be32(&guts_regs->pamubypenr);
for (pamu_reg_off = 0, pamu_counter = 0x80000000; pamu_reg_off < size;
@@ -1181,6 +1195,9 @@ static int fsl_pamu_probe(struct platform_device *pdev)
return 0;
error_sysfs:
iommu_device_sysfs_remove(&pamu_iommu);
error_genpool:
gen_pool_destroy(spaace_pool);