Lines Matching +full:iommu +full:- +full:map +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-only
3 * OF helpers for IOMMU
9 #include <linux/iommu.h>
24 struct fwnode_handle *fwnode = &iommu_spec->np->fwnode; in of_iommu_xlate()
28 if ((ops && !ops->of_xlate) || in of_iommu_xlate()
29 !of_device_is_available(iommu_spec->np)) in of_iommu_xlate()
30 return -ENODEV; in of_iommu_xlate()
32 ret = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops); in of_iommu_xlate()
36 * The otherwise-empty fwspec handily serves to indicate the specific in of_iommu_xlate()
37 * IOMMU device we're waiting for, which will be useful if we ever get in of_iommu_xlate()
38 * a proper probe-ordering dependency mechanism in future. in of_iommu_xlate()
43 if (!try_module_get(ops->owner)) in of_iommu_xlate()
44 return -ENODEV; in of_iommu_xlate()
46 ret = ops->of_xlate(dev, iommu_spec); in of_iommu_xlate()
47 module_put(ops->owner); in of_iommu_xlate()
58 err = of_map_id(master_np, *id, "iommu-map", in of_iommu_configure_dev_id()
59 "iommu-map-mask", &iommu_spec.np, in of_iommu_configure_dev_id()
73 int err = -ENODEV, idx = 0; in of_iommu_configure_dev()
76 "#iommu-cells", in of_iommu_configure_dev()
98 return of_iommu_configure_dev_id(info->np, info->dev, &input_id); in of_pci_iommu_init()
110 * 0 on success, an iommu was configured
111 * -ENODEV if the device does not have any IOMMU
112 * -EPROBEDEFER if probing should be tried again
113 * -errno fatal errors
122 return -ENODEV; in of_iommu_configure()
124 /* Serialise to make dev->iommu stable under our potential fwspec */ in of_iommu_configure()
128 if (fwspec->ops) { in of_iommu_configure()
137 * We don't currently walk up the tree looking for a parent IOMMU. in of_iommu_configure()
139 * Documentation/devicetree/bindings/iommu/iommu.txt in of_iommu_configure()
155 if (err == -ENODEV || err == -EPROBE_DEFER) in of_iommu_configure()
166 dev_dbg(dev, "Adding to IOMMU failed: %pe\n", ERR_PTR(err)); in of_iommu_configure()
175 phys_addr_t end = start + length - 1; in iommu_resv_region_get_type()
178 * IOMMU regions without an associated physical region cannot be in iommu_resv_region_get_type()
181 if (phys->start >= phys->end) in iommu_resv_region_get_type()
185 if (start == phys->start && end == phys->end) in iommu_resv_region_get_type()
188 dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", phys, in iommu_resv_region_get_type()
194 * of_iommu_get_resv_regions - reserved region driver helper for device tree
198 * IOMMU drivers can use this to implement their .get_resv_regions() callback
199 * for memory regions attached to a device tree node. See the reserved-memory
202 * Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
210 of_for_each_phandle(&it, err, dev->of_node, "memory-region", NULL, 0) { in of_iommu_get_resv_regions()
218 * The "reg" property is optional and can be omitted by reserved-memory regions in of_iommu_get_resv_regions()
231 maps = of_get_property(it.node, "iommu-addresses", &size); in of_iommu_get_resv_regions()
244 if (np == dev->of_node) { in of_iommu_get_resv_regions()
251 if (of_dma_is_coherent(dev->of_node)) in of_iommu_get_resv_regions()
264 list_add_tail(®ion->list, list); in of_iommu_get_resv_regions()