Lines Matching +full:iommu +full:- +full:map +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/dma-direct.h> /* for bus_dma_region */
9 #include <linux/dma-map-ops.h>
19 * of_match_device - Tell if a struct device matches an of_device_id list
29 if (!matches || !dev->of_node || dev->of_node_reused) in of_match_device()
31 return of_match_node(matches, dev->of_node); in of_match_device()
38 struct device_node *of_node = dev->of_node; in of_dma_set_restricted_buffer()
46 * If dev->of_node doesn't exist or doesn't contain memory-region, try in of_dma_set_restricted_buffer()
49 if (!of_property_present(of_node, "memory-region")) in of_dma_set_restricted_buffer()
52 of_for_each_phandle(&it, rc, of_node, "memory-region", NULL, 0) { in of_dma_set_restricted_buffer()
55 * restricted-dma-pool region is allowed. in of_dma_set_restricted_buffer()
57 if (of_device_is_compatible(it.node, "restricted-dma-pool") && in of_dma_set_restricted_buffer()
60 dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n"); in of_dma_set_restricted_buffer()
70 * of_dma_configure_id - Setup DMA configuration
87 const struct bus_dma_region *map = NULL; in of_dma_configure_id() local
89 u64 mask, end = 0; in of_dma_configure_id() local
93 if (dev->dma_range_map) { in of_dma_configure_id()
98 if (np == dev->of_node) in of_dma_configure_id()
103 ret = of_dma_get_range(bus_np, &map); in of_dma_configure_id()
108 * DMA configuration regardless of whether "dma-ranges" is in of_dma_configure_id()
112 return ret == -ENODEV ? 0 : ret; in of_dma_configure_id()
115 end = dma_range_map_max(map); in of_dma_configure_id()
120 * If @dev is expected to be DMA-capable then the bus code that created in of_dma_configure_id()
123 * coherent mask if not, but we'll no longer do so quietly. in of_dma_configure_id()
125 if (!dev->dma_mask) { in of_dma_configure_id()
126 dev_warn(dev, "DMA mask not set\n"); in of_dma_configure_id()
127 dev->dma_mask = &dev->coherent_dma_mask; in of_dma_configure_id()
130 if (!end && dev->coherent_dma_mask) in of_dma_configure_id()
131 end = dev->coherent_dma_mask; in of_dma_configure_id()
133 end = (1ULL << 32) - 1; in of_dma_configure_id()
136 * Limit coherent and dma mask based on size and default mask in of_dma_configure_id()
139 mask = DMA_BIT_MASK(ilog2(end) + 1); in of_dma_configure_id()
140 dev->coherent_dma_mask &= mask; in of_dma_configure_id()
141 *dev->dma_mask &= mask; in of_dma_configure_id()
142 /* ...but only set bus limit and range map if we found valid dma-ranges earlier */ in of_dma_configure_id()
144 dev->bus_dma_limit = end; in of_dma_configure_id()
145 dev->dma_range_map = map; in of_dma_configure_id()
153 if (ret == -EPROBE_DEFER) { in of_dma_configure_id()
154 /* Don't touch range map if it wasn't set from a valid dma-ranges */ in of_dma_configure_id()
156 dev->dma_range_map = NULL; in of_dma_configure_id()
157 kfree(map); in of_dma_configure_id()
158 return -EPROBE_DEFER; in of_dma_configure_id()
160 /* Take all other IOMMU errors to mean we'll just carry on without it */ in of_dma_configure_id()
161 dev_dbg(dev, "device is%sbehind an iommu\n", in of_dma_configure_id()
177 match = of_match_device(dev->driver->of_match_table, dev); in of_device_get_match_data()
181 return match->data; in of_device_get_match_data()
186 * of_device_modalias - Fill buffer with newline terminated modalias string
195 if (!dev || !dev->of_node || dev->of_node_reused) in of_device_modalias()
196 return -ENODEV; in of_device_modalias()
198 sl = of_modalias(dev->of_node, str, len - 2); in of_device_modalias()
201 if (sl > len - 2) in of_device_modalias()
202 return -ENOMEM; in of_device_modalias()
211 * of_device_uevent - Display OF related uevent information
222 if ((!dev) || (!dev->of_node)) in of_device_uevent()
225 add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); in of_device_uevent()
226 add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); in of_device_uevent()
227 type = of_node_get_device_type(dev->of_node); in of_device_uevent()
234 of_property_for_each_string(dev->of_node, "compatible", p, compat) { in of_device_uevent()
243 if (dev->of_node == app->np) { in of_device_uevent()
245 app->alias); in of_device_uevent()
257 if ((!dev) || (!dev->of_node) || dev->of_node_reused) in of_device_uevent_modalias()
258 return -ENODEV; in of_device_uevent_modalias()
262 return -ENOMEM; in of_device_uevent_modalias()
264 sl = of_modalias(dev->of_node, &env->buf[env->buflen-1], in of_device_uevent_modalias()
265 sizeof(env->buf) - env->buflen); in of_device_uevent_modalias()
268 if (sl >= (sizeof(env->buf) - env->buflen)) in of_device_uevent_modalias()
269 return -ENOMEM; in of_device_uevent_modalias()
270 env->buflen += sl; in of_device_uevent_modalias()
277 * of_device_make_bus_id - Use the device node data to assign a unique name
286 struct device_node *node = dev->of_node; in of_device_make_bus_id()
289 u32 mask; in of_device_make_bus_id() local
292 while (node->parent) { in of_device_make_bus_id()
299 if (!of_property_read_u32(node, "mask", &mask)) in of_device_make_bus_id()
301 addr, ffs(mask) - 1, node, dev_name(dev)); in of_device_make_bus_id()
311 kbasename(node->full_name), dev_name(dev)); in of_device_make_bus_id()
312 node = node->parent; in of_device_make_bus_id()