Lines Matching +full:dma +full:- +full:host
4 * @brief Public APIs for the DMA drivers.
10 * SPDX-License-Identifier: Apache-2.0
25 * @brief DMA Interface
26 * @defgroup dma_interface DMA Interface
45 * This and higher values are dma controller or soc specific.
46 * Refer to the specified dma driver header file.
65 DMA_CHANNEL_NORMAL, /* normal DMA channel */
69 /* DMA attributes */
79 * @brief DMA block configuration structure.
94 * source_gather_en [ 0 ] - 0-disable, 1-enable.
95 * dest_scatter_en [ 1 ] - 0-disable, 1-enable.
96 * source_addr_adj [ 2 : 3 ] - 00-increment, 01-decrement,
97 * 10-no change.
98 * dest_addr_adj [ 4 : 5 ] - 00-increment, 01-decrement,
99 * 10-no change.
100 * source_reload_en [ 6 ] - reload source address at the end of
102 * 0-disable, 1-enable.
103 * dest_reload_en [ 7 ] - reload destination address at the end
105 * 0-disable, 1-enable.
106 * fifo_mode_control [ 8 : 11 ] - How full of the fifo before transfer
108 * flow_control_mode [ 12 ] - 0-source request served upon data
110 * 1-source request postponed until
144 * @brief Callback function for DMA transfer completion
148 * In circular mode, @p status indicates that the DMA device has reached either
151 * @param dev Pointer to the DMA device calling the callback.
154 * @param status - 0-DMA_STATUS_COMPLETE buffer fully consumed
155 * - 1-DMA_STATUS_BLOCK buffer consumption reached a configured block
157 * - a negative errno otherwise
164 * @brief DMA configuration structure.
166 * @param dma_slot [ 0 : 7 ] - which peripheral and direction
168 * @param channel_direction [ 8 : 10 ] - 000-memory to memory,
169 * 001-memory to peripheral,
170 * 010-peripheral to memory,
171 * 011-peripheral to peripheral,
172 * 100-host to memory
173 * 101-memory to host
175 * @param complete_callback_en [ 11 ] - 0-callback invoked at completion only
176 * 1-callback invoked at completion of
178 * @param error_callback_en [ 12 ] - 0-error callback enabled
179 * 1-error callback disabled
180 * @param source_handshake [ 13 ] - 0-HW, 1-SW
181 * @param dest_handshake [ 14 ] - 0-HW, 1-SW
182 * @param channel_priority [ 15 : 18 ] - DMA channel priority
183 * @param source_chaining_en [ 19 ] - enable/disable source block chaining
184 * 0-disable, 1-enable
185 * @param dest_chaining_en [ 20 ] - enable/disable destination block
187 * 0-disable, 1-enable
188 * @param linked_channel [ 21 : 27 ] - after channel count exhaust will
191 * @param cyclic [ 28 ] - enable/disable cyclic buffer
192 * 0-disable, 1-enable
194 * @param source_data_size [ 0 : 15 ] - width of source data (in bytes)
195 * @param dest_data_size [ 16 : 31 ] - width of dest data (in bytes)
196 * @param source_burst_length [ 0 : 15 ] - number of source data units
197 * @param dest_burst_length [ 16 : 31 ] - number of destination data units
199 * depends on availability of the DMA controller.
200 * @param user_data private data from DMA client.
227 * DMA runtime status structure
229 * busy - is current DMA transfer busy or idle
230 * dir - DMA transfer direction
231 * pending_length - data length pending to be transferred in bytes
233 * free - free buffer space
234 * write_position - write position in a circular dma buffer
235 * read_position - read position in a circular dma buffer
249 * DMA context structure
251 * of DMA client driver Data, got by dev->data
253 * magic - magic code to identify the context
254 * dma_channels - dma channels
255 * atomic - driver atomic_t pointer
301 * filter function that is used to find the matched internal dma channel
304 * @param dev Pointer to the DMA device instance
329 * @brief Configure individual channel for DMA transfer.
343 (const struct dma_driver_api *)dev->api; in dma_config()
345 return api->config(dev, channel, config); in dma_config()
349 * @brief Reload buffer(s) for a DMA channel
354 * @param src source address for the DMA transfer
355 * @param dst destination address for the DMA transfer
356 * @param size size of DMA transfer
370 (const struct dma_driver_api *)dev->api; in dma_reload()
372 if (api->reload) { in dma_reload()
373 return api->reload(dev, channel, src, dst, size); in dma_reload()
376 return -ENOSYS; in dma_reload()
380 * @brief Enables DMA channel and starts the transfer, the channel must be
384 * return -EINVAL if it is invalid.
401 (const struct dma_driver_api *)dev->api; in z_impl_dma_start()
403 return api->start(dev, channel); in z_impl_dma_start()
407 * @brief Stops the DMA transfer and disables the channel.
410 * return -EINVAL if it is invalid.
427 (const struct dma_driver_api *)dev->api; in z_impl_dma_stop()
429 return api->stop(dev, channel); in z_impl_dma_stop()
434 * @brief Suspend a DMA channel transfer
437 * in and return -EINVAL if either are invalid.
443 * @retval -ENOSYS If not implemented.
444 * @retval -EINVAL If invalid channel id or state.
445 * @retval -errno Other negative errno code failure.
451 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api; in z_impl_dma_suspend()
453 if (api->suspend == NULL) { in z_impl_dma_suspend()
454 return -ENOSYS; in z_impl_dma_suspend()
456 return api->suspend(dev, channel); in z_impl_dma_suspend()
460 * @brief Resume a DMA channel transfer
463 * in and return -EINVAL if either are invalid.
469 * @retval -ENOSYS If not implemented
470 * @retval -EINVAL If invalid channel id or state.
471 * @retval -errno Other negative errno code failure.
477 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api; in z_impl_dma_resume()
479 if (api->resume == NULL) { in z_impl_dma_resume()
480 return -ENOSYS; in z_impl_dma_resume()
482 return api->resume(dev, channel); in z_impl_dma_resume()
486 * @brief request DMA channel.
488 * request DMA channel resources
489 * return -EINVAL if there is no valid channel available.
494 * @retval dma channel if successful.
504 int channel = -EINVAL; in z_impl_dma_request_channel()
506 (const struct dma_driver_api *)dev->api; in z_impl_dma_request_channel()
508 struct dma_context *dma_ctx = (struct dma_context *)dev->data; in z_impl_dma_request_channel()
510 if (dma_ctx->magic != DMA_MAGIC) { in z_impl_dma_request_channel()
514 for (i = 0; i < dma_ctx->dma_channels; i++) { in z_impl_dma_request_channel()
515 if (!atomic_test_and_set_bit(dma_ctx->atomic, i)) { in z_impl_dma_request_channel()
516 if (api->chan_filter && in z_impl_dma_request_channel()
517 !api->chan_filter(dev, i, filter_param)) { in z_impl_dma_request_channel()
518 atomic_clear_bit(dma_ctx->atomic, i); in z_impl_dma_request_channel()
530 * @brief release DMA channel.
532 * release DMA channel resources
544 struct dma_context *dma_ctx = (struct dma_context *)dev->data; in z_impl_dma_release_channel()
546 if (dma_ctx->magic != DMA_MAGIC) { in z_impl_dma_release_channel()
550 if ((int)channel < dma_ctx->dma_channels) { in z_impl_dma_release_channel()
551 atomic_clear_bit(dma_ctx->atomic, channel); in z_impl_dma_release_channel()
557 * @brief DMA channel filter.
575 (const struct dma_driver_api *)dev->api; in z_impl_dma_chan_filter()
577 if (api->chan_filter) { in z_impl_dma_chan_filter()
578 return api->chan_filter(dev, channel, filter_param); in z_impl_dma_chan_filter()
581 return -ENOSYS; in z_impl_dma_chan_filter()
585 * @brief get current runtime status of DMA transfer
588 * return -EINVAL if it is invalid or -ENOSYS if not supported.
593 * @param stat a non-NULL dma_status object for storing DMA status
595 * @retval non-negative if successful.
602 (const struct dma_driver_api *)dev->api; in dma_get_status()
604 if (api->get_status) { in dma_get_status()
605 return api->get_status(dev, channel, stat); in dma_get_status()
608 return -ENOSYS; in dma_get_status()
612 * @brief get attribute of a dma controller
617 * return -EINVAL if it is invalid or -ENOSYS if not supported.
621 * @param value A non-NULL pointer to the variable where the read value is to be placed
623 * @retval non-negative if successful.
628 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api; in dma_get_attribute()
630 if (api->get_attribute) { in dma_get_attribute()
631 return api->get_attribute(dev, type, value); in dma_get_attribute()
634 return -ENOSYS; in dma_get_attribute()
638 * @brief Look-up generic width index to be used in registers
640 * WARNING: This look-up works for most controllers, but *may* not work for
644 * your own look-up inside the controller driver.
648 * @retval common DMA index to be placed into registers.
667 * @brief Look-up generic burst index to be used in registers
669 * WARNING: This look-up works for most controllers, but *may* not work for
673 * your own look-up inside the controller driver.
677 * @retval common DMA index to be placed into registers.
687 if (!(burst & (burst - 1))) { in dma_burst_index()
698 * Useful when statically defining or allocating buffers for DMA usage where
702 * @return alignment Memory byte alignment required for DMA buffers
709 * Useful when statically defining or allocating buffers for DMA usage where
713 * @return alignment Memory byte alignment required for DMA buffers
733 #include <syscalls/dma.h>