Skip to content

Commit fa0656b

Browse files
nipungupta87joergroedel
authored andcommitted
iommu/of: support iommu configuration for fsl-mc devices
With of_pci_map_rid available for all the busses, use the function for configuration of devices on fsl-mc bus Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 2a6db71 commit fa0656b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/iommu/of_iommu.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/of_iommu.h>
2525
#include <linux/of_pci.h>
2626
#include <linux/slab.h>
27+
#include <linux/fsl/mc.h>
2728

2829
#define NO_IOMMU 1
2930

@@ -142,6 +143,23 @@ static int of_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
142143
return err;
143144
}
144145

146+
static int of_fsl_mc_iommu_init(struct fsl_mc_device *mc_dev,
147+
struct device_node *master_np)
148+
{
149+
struct of_phandle_args iommu_spec = { .args_count = 1 };
150+
int err;
151+
152+
err = of_map_rid(master_np, mc_dev->icid, "iommu-map",
153+
"iommu-map-mask", &iommu_spec.np,
154+
iommu_spec.args);
155+
if (err)
156+
return err == -ENODEV ? NO_IOMMU : err;
157+
158+
err = of_iommu_xlate(&mc_dev->dev, &iommu_spec);
159+
of_node_put(iommu_spec.np);
160+
return err;
161+
}
162+
145163
const struct iommu_ops *of_iommu_configure(struct device *dev,
146164
struct device_node *master_np)
147165
{
@@ -173,6 +191,8 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
173191

174192
err = pci_for_each_dma_alias(to_pci_dev(dev),
175193
of_pci_iommu_init, &info);
194+
} else if (dev_is_fsl_mc(dev)) {
195+
err = of_fsl_mc_iommu_init(to_fsl_mc_device(dev), master_np);
176196
} else {
177197
struct of_phandle_args iommu_spec;
178198
int idx = 0;

0 commit comments

Comments
 (0)