1 // SPDX-License-Identifier: GPL-2.0
3 * Stub IOMMU driver which does nothing.
4 * The main purpose of it being present is to reuse generic IOMMU device tree
5 * bindings by Xen grant DMA-mapping layer.
7 * Copyright (C) 2022 EPAM Systems Inc.
10 #include <linux/iommu.h>
12 #include <linux/platform_device.h>
14 struct grant_dma_iommu_device {
16 struct iommu_device iommu;
19 /* Nothing is really needed here */
20 static const struct iommu_ops grant_dma_iommu_ops;
22 static const struct of_device_id grant_dma_iommu_of_match[] = {
23 { .compatible = "xen,grant-dma" },
27 static int grant_dma_iommu_probe(struct platform_device *pdev)
29 struct grant_dma_iommu_device *mmu;
32 mmu = devm_kzalloc(&pdev->dev, sizeof(*mmu), GFP_KERNEL);
36 mmu->dev = &pdev->dev;
38 ret = iommu_device_register(&mmu->iommu, &grant_dma_iommu_ops, &pdev->dev);
42 platform_set_drvdata(pdev, mmu);
47 static int grant_dma_iommu_remove(struct platform_device *pdev)
49 struct grant_dma_iommu_device *mmu = platform_get_drvdata(pdev);
51 platform_set_drvdata(pdev, NULL);
52 iommu_device_unregister(&mmu->iommu);
57 static struct platform_driver grant_dma_iommu_driver = {
59 .name = "grant-dma-iommu",
60 .of_match_table = grant_dma_iommu_of_match,
62 .probe = grant_dma_iommu_probe,
63 .remove = grant_dma_iommu_remove,
66 static int __init grant_dma_iommu_init(void)
68 struct device_node *iommu_np;
70 iommu_np = of_find_matching_node(NULL, grant_dma_iommu_of_match);
74 of_node_put(iommu_np);
76 return platform_driver_register(&grant_dma_iommu_driver);
78 subsys_initcall(grant_dma_iommu_init);