Lines Matching +full:dma +full:- +full:buffer +full:- +full:size

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
34 * @brief DMA channel direction
56 * This and higher values are dma controller or soc specific.
57 * Refer to the specified dma driver header file.
68 * @brief DMA address adjustment
82 * @brief DMA channel attributes
85 DMA_CHANNEL_NORMAL, /* normal DMA channel */
90 * @brief DMA attributes
101 * @brief DMA block configuration structure.
103 * Aside from source address, destination address, and block size many of these options are hardware
137 * - 0b00 increment
138 * - 0b01 decrement
139 * - 0b10 no change
145 * - 0b00 increment
146 * - 0b01 decrement
147 * - 0b10 no change
159 * - 0b0 source request service upon data availability
160 * - 0b1 source request postponed until destination request happens
167 /** The DMA callback event has occurred at the completion of a transfer list */
169 /** The DMA callback has occurred at the completion of a single transfer block in a transfer list */
174 * @brief Callback function for DMA transfer completion
178 * In circular mode, @p status indicates that the DMA device has reached either
179 * the end of the buffer (DMA_STATUS_COMPLETE) or a water mark (DMA_STATUS_BLOCK).
181 * @param dev Pointer to the DMA device calling the callback.
185 * - DMA_STATUS_COMPLETE buffer fully consumed
186 * - DMA_STATUS_BLOCK buffer consumption reached a configured block
188 * - A negative errno otherwise
195 * @brief DMA configuration structure.
203 * - 0b000 memory to memory,
204 * - 0b001 memory to peripheral,
205 * - 0b010 peripheral to memory,
206 * - 0b011 peripheral to peripheral,
207 * - 0b100 host to memory
208 * - 0b101 memory to host
209 * - others hardware specific
215 * - 0b0 callback invoked at transfer list completion only
216 * - 0b1 callback invoked at completion of each block
222 * - 0b0 error callback enabled
223 * - 0b1 error callback disabled
229 * - 0b0 HW
230 * - 0b1 SW
236 * - 0b0 HW
237 * - 0b1 SW
273 * DMA runtime status structure
276 /** Is the current DMA transfer busy or idle */
284 /** Write position in circular DMA buffer, HW specific */
286 /** Read position in circular DMA buffer, HW specific */
293 * DMA context structure
295 * of DMA client driver Data, got by dev->data
300 /** number of dma channels */
320 uint64_t src, uint64_t dst, size_t size);
323 uint32_t src, uint32_t dst, size_t size);
343 * filter function that is used to find the matched internal dma channel
346 * @param dev Pointer to the DMA device instance
363 * @param dev Pointer to the DMA device instance
386 * @brief Configure individual channel for DMA transfer.
400 (const struct dma_driver_api *)dev->api;
402 return api->config(dev, channel, config);
406 * @brief Reload buffer(s) for a DMA channel
411 * @param src source address for the DMA transfer
412 * @param dst destination address for the DMA transfer
413 * @param size size of DMA transfer
420 uint64_t src, uint64_t dst, size_t size)
423 uint32_t src, uint32_t dst, size_t size)
427 (const struct dma_driver_api *)dev->api;
429 if (api->reload) {
430 return api->reload(dev, channel, src, dst, size);
433 return -ENOSYS;
437 * @brief Enables DMA channel and starts the transfer, the channel must be
441 * return -EINVAL if it is invalid.
460 (const struct dma_driver_api *)dev->api;
462 return api->start(dev, channel);
466 * @brief Stops the DMA transfer and disables the channel.
469 * return -EINVAL if it is invalid.
488 (const struct dma_driver_api *)dev->api;
490 return api->stop(dev, channel);
495 * @brief Suspend a DMA channel transfer
498 * in and return -EINVAL if either are invalid.
506 * @retval -ENOSYS If not implemented.
507 * @retval -EINVAL If invalid channel id or state.
508 * @retval -errno Other negative errno code failure.
514 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api;
516 if (api->suspend == NULL) {
517 return -ENOSYS;
519 return api->suspend(dev, channel);
523 * @brief Resume a DMA channel transfer
526 * in and return -EINVAL if either are invalid.
534 * @retval -ENOSYS If not implemented
535 * @retval -EINVAL If invalid channel id or state.
536 * @retval -errno Other negative errno code failure.
542 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api;
544 if (api->resume == NULL) {
545 return -ENOSYS;
547 return api->resume(dev, channel);
551 * @brief request DMA channel.
553 * request DMA channel resources
554 * return -EINVAL if there is no valid channel available.
563 * @retval dma channel if successful.
573 int channel = -EINVAL;
575 (const struct dma_driver_api *)dev->api;
577 struct dma_context *dma_ctx = (struct dma_context *)dev->data;
579 if (dma_ctx->magic != DMA_MAGIC) {
583 for (i = 0; i < dma_ctx->dma_channels; i++) {
584 if (!atomic_test_and_set_bit(dma_ctx->atomic, i)) {
585 if (api->chan_filter &&
586 !api->chan_filter(dev, i, filter_param)) {
587 atomic_clear_bit(dma_ctx->atomic, i);
599 * @brief release DMA channel.
601 * release DMA channel resources
618 (const struct dma_driver_api *)dev->api;
619 struct dma_context *dma_ctx = (struct dma_context *)dev->data;
621 if (dma_ctx->magic != DMA_MAGIC) {
625 if ((int)channel < dma_ctx->dma_channels) {
626 if (api->chan_release) {
627 api->chan_release(dev, channel);
630 atomic_clear_bit(dma_ctx->atomic, channel);
636 * @brief DMA channel filter.
654 (const struct dma_driver_api *)dev->api;
656 if (api->chan_filter) {
657 return api->chan_filter(dev, channel, filter_param);
660 return -ENOSYS;
664 * @brief get current runtime status of DMA transfer
667 * return -EINVAL if it is invalid or -ENOSYS if not supported.
674 * @param stat a non-NULL dma_status object for storing DMA status
676 * @retval non-negative if successful.
683 (const struct dma_driver_api *)dev->api;
685 if (api->get_status) {
686 return api->get_status(dev, channel, stat);
689 return -ENOSYS;
693 * @brief get attribute of a dma controller
696 * and size alignment of a buffer.
698 * return -EINVAL if it is invalid or -ENOSYS if not supported.
704 * @param value A non-NULL pointer to the variable where the read value is to be placed
706 * @retval non-negative if successful.
711 const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api;
713 if (api->get_attribute) {
714 return api->get_attribute(dev, type, value);
717 return -ENOSYS;
721 * @brief Look-up generic width index to be used in registers
723 * @warning This look-up works for most controllers, but *may* not work for
727 * your own look-up inside the controller driver.
729 * @param size: width of bus (in bytes)
731 * @retval common DMA index to be placed into registers.
733 static inline uint32_t dma_width_index(uint32_t size)
736 if (size < 1 || size > 32) {
740 /* Ensure size is a power of 2 */
741 if (!is_power_of_two(size)) {
746 return find_msb_set(size);
750 * @brief Look-up generic burst index to be used in registers
752 * @warning This look-up works for most controllers, but *may* not work for
756 * your own look-up inside the controller driver.
760 * @retval common DMA index to be placed into registers.
770 if (!(burst & (burst - 1))) {
779 * @brief Get the device tree property describing the buffer address alignment
781 * Useful when statically defining or allocating buffers for DMA usage where
785 * @return alignment Memory byte alignment required for DMA buffers
790 * @brief Get the device tree property describing the buffer size alignment
792 * Useful when statically defining or allocating buffers for DMA usage where
796 * @return alignment Memory byte alignment required for DMA buffers
816 #include <zephyr/syscalls/dma.h>