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>
20 #include "iommu-priv.h"
28 if (!of_device_is_available(iommu_spec->np)) in of_iommu_xlate()
29 return -ENODEV; in of_iommu_xlate()
31 ret = iommu_fwspec_init(dev, of_fwnode_handle(iommu_spec->np)); in of_iommu_xlate()
35 ops = iommu_ops_from_fwnode(&iommu_spec->np->fwnode); in of_iommu_xlate()
36 if (!ops->of_xlate || !try_module_get(ops->owner)) in of_iommu_xlate()
37 return -ENODEV; in of_iommu_xlate()
39 ret = ops->of_xlate(dev, iommu_spec); in of_iommu_xlate()
40 module_put(ops->owner); in of_iommu_xlate()
51 err = of_map_id(master_np, *id, "iommu-map", in of_iommu_configure_dev_id()
52 "iommu-map-mask", &iommu_spec.np, in of_iommu_configure_dev_id()
66 int err = -ENODEV, idx = 0; in of_iommu_configure_dev()
69 "#iommu-cells", in of_iommu_configure_dev()
91 return of_iommu_configure_dev_id(info->np, info->dev, &input_id); in of_pci_iommu_init()
105 if (fwspec && of_property_read_bool(np, "ats-supported")) in of_pci_check_device_ats()
106 fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; in of_pci_check_device_ats()
111 * 0 on success, an iommu was configured
112 * -ENODEV if the device does not have any IOMMU
113 * -EPROBEDEFER if probing should be tried again
114 * -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()
132 * We don't currently walk up the tree looking for a parent IOMMU. in of_iommu_configure()
134 * Documentation/devicetree/bindings/iommu/iommu.txt in of_iommu_configure()
154 if (!err && dev->bus) in of_iommu_configure()
157 if (err && err != -EPROBE_DEFER) in of_iommu_configure()
158 dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); in of_iommu_configure()
168 phys_addr_t end = start + length - 1; in iommu_resv_region_get_type()
171 * IOMMU regions without an associated physical region cannot be in iommu_resv_region_get_type()
174 if (phys->start >= phys->end) in iommu_resv_region_get_type()
178 if (start == phys->start && end == phys->end) in iommu_resv_region_get_type()
181 dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", phys, in iommu_resv_region_get_type()
187 * of_iommu_get_resv_regions - reserved region driver helper for device tree
191 * IOMMU drivers can use this to implement their .get_resv_regions() callback
192 * for memory regions attached to a device tree node. See the reserved-memory
195 * Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
203 of_for_each_phandle(&it, err, dev->of_node, "memory-region", NULL, 0) { in of_iommu_get_resv_regions()
211 * The "reg" property is optional and can be omitted by reserved-memory regions in of_iommu_get_resv_regions()
224 maps = of_get_property(it.node, "iommu-addresses", &size); in of_iommu_get_resv_regions()
237 if (np == dev->of_node) { in of_iommu_get_resv_regions()
244 if (of_dma_is_coherent(dev->of_node)) in of_iommu_get_resv_regions()
257 list_add_tail(&region->list, list); in of_iommu_get_resv_regions()