Lines Matching +full:dma +full:- +full:coherent

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 *node, *of_node = dev->of_node; in of_dma_set_restricted_buffer()
44 count = of_property_count_elems_of_size(of_node, "memory-region", in of_dma_set_restricted_buffer()
47 * If dev->of_node doesn't exist or doesn't contain memory-region, try in of_dma_set_restricted_buffer()
48 * the OF node having DMA configuration. in of_dma_set_restricted_buffer()
53 of_node, "memory-region", sizeof(u32)); in of_dma_set_restricted_buffer()
57 node = of_parse_phandle(of_node, "memory-region", i); in of_dma_set_restricted_buffer()
60 * restricted-dma-pool region is allowed. in of_dma_set_restricted_buffer()
62 if (of_device_is_compatible(node, "restricted-dma-pool") && in of_dma_set_restricted_buffer()
71 * Attempt to initialize a restricted-dma-pool region if one was found. in of_dma_set_restricted_buffer()
75 dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n"); in of_dma_set_restricted_buffer()
79 * of_dma_configure_id - Setup DMA configuration
80 * @dev: Device to apply DMA configuration
81 * @np: Pointer to OF node having DMA configuration
83 * DMA capability is not explicitly described by firmware.
86 * Try to get devices's DMA configuration from DT and update it
89 * If platform code needs to use its own special DMA configuration, it
91 * to fix up DMA configuration.
99 bool coherent, set_map = false; in of_dma_configure_id() local
102 if (np == dev->of_node) in of_dma_configure_id()
112 * DMA configuration regardless of whether "dma-ranges" is in of_dma_configure_id()
116 return ret == -ENODEV ? 0 : ret; in of_dma_configure_id()
118 /* Determine the overall bounds of all DMA regions */ in of_dma_configure_id()
124 * If @dev is expected to be DMA-capable then the bus code that created in of_dma_configure_id()
127 * coherent mask if not, but we'll no longer do so quietly. in of_dma_configure_id()
129 if (!dev->dma_mask) { in of_dma_configure_id()
130 dev_warn(dev, "DMA mask not set\n"); in of_dma_configure_id()
131 dev->dma_mask = &dev->coherent_dma_mask; in of_dma_configure_id()
134 if (!end && dev->coherent_dma_mask) in of_dma_configure_id()
135 end = dev->coherent_dma_mask; in of_dma_configure_id()
137 end = (1ULL << 32) - 1; in of_dma_configure_id()
140 * Limit coherent and dma mask based on size and default mask in of_dma_configure_id()
144 dev->coherent_dma_mask &= mask; in of_dma_configure_id()
145 *dev->dma_mask &= mask; in of_dma_configure_id()
146 /* ...but only set bus limit and range map if we found valid dma-ranges earlier */ in of_dma_configure_id()
148 dev->bus_dma_limit = end; in of_dma_configure_id()
149 dev->dma_range_map = map; in of_dma_configure_id()
152 coherent = of_dma_is_coherent(np); in of_dma_configure_id()
153 dev_dbg(dev, "device is%sdma coherent\n", in of_dma_configure_id()
154 coherent ? " " : " not "); in of_dma_configure_id()
157 if (ret == -EPROBE_DEFER) { in of_dma_configure_id()
158 /* Don't touch range map if it wasn't set from a valid dma-ranges */ in of_dma_configure_id()
160 dev->dma_range_map = NULL; in of_dma_configure_id()
162 return -EPROBE_DEFER; in of_dma_configure_id()
168 arch_setup_dma_ops(dev, coherent); in of_dma_configure_id()
181 match = of_match_device(dev->driver->of_match_table, dev); in of_device_get_match_data()
185 return match->data; in of_device_get_match_data()
190 * of_device_modalias - Fill buffer with newline terminated modalias string
199 if (!dev || !dev->of_node || dev->of_node_reused) in of_device_modalias()
200 return -ENODEV; in of_device_modalias()
202 sl = of_modalias(dev->of_node, str, len - 2); in of_device_modalias()
205 if (sl > len - 2) in of_device_modalias()
206 return -ENOMEM; in of_device_modalias()
215 * of_device_uevent - Display OF related uevent information
226 if ((!dev) || (!dev->of_node)) in of_device_uevent()
229 add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); in of_device_uevent()
230 add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); in of_device_uevent()
231 type = of_node_get_device_type(dev->of_node); in of_device_uevent()
238 of_property_for_each_string(dev->of_node, "compatible", p, compat) { in of_device_uevent()
247 if (dev->of_node == app->np) { in of_device_uevent()
249 app->alias); in of_device_uevent()
261 if ((!dev) || (!dev->of_node) || dev->of_node_reused) in of_device_uevent_modalias()
262 return -ENODEV; in of_device_uevent_modalias()
266 return -ENOMEM; in of_device_uevent_modalias()
268 sl = of_modalias(dev->of_node, &env->buf[env->buflen-1], in of_device_uevent_modalias()
269 sizeof(env->buf) - env->buflen); in of_device_uevent_modalias()
272 if (sl >= (sizeof(env->buf) - env->buflen)) in of_device_uevent_modalias()
273 return -ENOMEM; in of_device_uevent_modalias()
274 env->buflen += sl; in of_device_uevent_modalias()
281 * of_device_make_bus_id - Use the device node data to assign a unique name
290 struct device_node *node = dev->of_node; in of_device_make_bus_id()
296 while (node->parent) { in of_device_make_bus_id()
305 addr, ffs(mask) - 1, node, dev_name(dev)); in of_device_make_bus_id()
315 kbasename(node->full_name), dev_name(dev)); in of_device_make_bus_id()
316 node = node->parent; in of_device_make_bus_id()