feat(esp_driver_dma): add dw_gdma backend for async_memcpy

This commit is contained in:
morris
2026-08-10 16:16:53 +08:00
parent a063a8440f
commit eec76a070e
29 changed files with 1144 additions and 340 deletions
@@ -423,31 +423,31 @@ static inline void dw_gdma_ll_channel_set_dst_master_port(dw_gdma_dev_t *dev, ui
}
/**
* @brief Enable the source address burst mode
* @brief Set the source address increment mode
*
* @note Increase the source address by the data width after each transfer
* @note Controls whether the source address is increased by the data width after each transfer
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param mode Address burst mode
* @param mode Address increment mode
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_src_burst_mode(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_mode_t mode)
static inline void dw_gdma_ll_channel_set_src_addr_inc_mode(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_addr_inc_mode_t mode)
{
dev->ch[channel].ctl0.sinc = mode;
}
/**
* @brief Enable the destination address burst mode
* @brief Set the destination address increment mode
*
* @note Increase the destination address by the data width after each transfer
* @note Controls whether the destination address is increased by the data width after each transfer
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param mode Address burst mode
* @param mode Address increment mode
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_dst_burst_mode(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_mode_t mode)
static inline void dw_gdma_ll_channel_set_dst_addr_inc_mode(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_addr_inc_mode_t mode)
{
dev->ch[channel].ctl0.dinc = mode;
}
@@ -483,12 +483,12 @@ static inline void dw_gdma_ll_channel_set_dst_trans_width(dw_gdma_dev_t *dev, ui
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param items Number of data items
* @param size Burst size (number of data items)
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_src_burst_items(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_items_t items)
static inline void dw_gdma_ll_channel_set_src_burst_size(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_size_t size)
{
dev->ch[channel].ctl0.src_msize = items;
dev->ch[channel].ctl0.src_msize = size;
}
/**
@@ -496,39 +496,39 @@ static inline void dw_gdma_ll_channel_set_src_burst_items(dw_gdma_dev_t *dev, ui
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param items Number of data items
* @param size Burst size (number of data items)
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_dst_burst_items(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_items_t items)
static inline void dw_gdma_ll_channel_set_dst_burst_size(dw_gdma_dev_t *dev, uint8_t channel, dw_gdma_burst_size_t size)
{
dev->ch[channel].ctl0.dst_msize = items;
dev->ch[channel].ctl0.dst_msize = size;
}
/**
* @brief Set the source burst length
* @brief Set the source AXI burst length
*
* @note This controls how many times the DMA controller will ask for data from the source device in a single burst transaction.
* @note This controls how many times the DMA controller will ask for data from the source device in a single AXI burst transaction.
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param len Burst length
* @param len AXI burst length
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_src_burst_len(dw_gdma_dev_t *dev, uint8_t channel, uint8_t len)
static inline void dw_gdma_ll_channel_set_src_axi_burst_len(dw_gdma_dev_t *dev, uint8_t channel, uint8_t len)
{
dev->ch[channel].ctl1.arlen_en = len > 0;
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->ch[channel].ctl1, arlen, len);
}
/**
* @brief Set the destination burst length
* @brief Set the destination AXI burst length
*
* @param dev Pointer to the DW_GDMA registers
* @param channel Channel number
* @param len Burst length
* @param len AXI burst length
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_channel_set_dst_burst_len(dw_gdma_dev_t *dev, uint8_t channel, uint8_t len)
static inline void dw_gdma_ll_channel_set_dst_axi_burst_len(dw_gdma_dev_t *dev, uint8_t channel, uint8_t len)
{
dev->ch[channel].ctl1.awlen_en = len > 0;
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->ch[channel].ctl1, awlen, len);
@@ -1072,80 +1072,80 @@ static inline void dw_gdma_ll_lli_set_trans_block_size(dw_gdma_link_list_item_t
}
/**
* @brief Enable the source address burst mode
* @brief Set the source address increment mode
*
* @note Increase the source address by the data width after each transfer
* @note Controls whether the source address is increased by the data width after each transfer
*
* @param lli Link list item
* @param mode Address burst mode
* @param mode Address increment mode
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_src_burst_mode(dw_gdma_link_list_item_t *lli, dw_gdma_burst_mode_t mode)
static inline void dw_gdma_ll_lli_set_src_addr_inc_mode(dw_gdma_link_list_item_t *lli, dw_gdma_addr_inc_mode_t mode)
{
lli->ctrl_lo.sinc = mode;
}
/**
* @brief Enable the destination address burst mode
* @brief Set the destination address increment mode
*
* @note Increase the destination address by the data width after each transfer
* @note Controls whether the destination address is increased by the data width after each transfer
*
* @param lli Link list item
* @param mode Address burst mode
* @param mode Address increment mode
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_dst_burst_mode(dw_gdma_link_list_item_t *lli, dw_gdma_burst_mode_t mode)
static inline void dw_gdma_ll_lli_set_dst_addr_inc_mode(dw_gdma_link_list_item_t *lli, dw_gdma_addr_inc_mode_t mode)
{
lli->ctrl_lo.dinc = mode;
}
/**
* @brief Set the number of data items that can be transferred in a single burst transaction for the source master port
* @brief Set the burst size for the source master port
*
* @param lli Link list item
* @param items Number of data items
* @param size Burst size (number of data items)
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_src_burst_items(dw_gdma_link_list_item_t *lli, dw_gdma_burst_items_t items)
static inline void dw_gdma_ll_lli_set_src_burst_size(dw_gdma_link_list_item_t *lli, dw_gdma_burst_size_t size)
{
lli->ctrl_lo.src_msize = items;
lli->ctrl_lo.src_msize = size;
}
/**
* @brief Set the number of data items that can be transferred in a single burst transaction for the destination master port
* @brief Set the burst size for the destination master port
*
* @param lli Link list item
* @param items Number of data items
* @param size Burst size (number of data items)
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_dst_burst_items(dw_gdma_link_list_item_t *lli, dw_gdma_burst_items_t items)
static inline void dw_gdma_ll_lli_set_dst_burst_size(dw_gdma_link_list_item_t *lli, dw_gdma_burst_size_t size)
{
lli->ctrl_lo.dst_msize = items;
lli->ctrl_lo.dst_msize = size;
}
/**
* @brief Set the source burst length
* @brief Set the source AXI burst length
*
* @note This controls how many times the DMA controller will ask for data from the source device in a single burst transaction.
* @note This controls how many times the DMA controller will ask for data from the source device in a single AXI burst transaction.
*
* @param lli Link list item
* @param len Burst length
* @param len AXI burst length
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_src_burst_len(dw_gdma_link_list_item_t *lli, uint8_t len)
static inline void dw_gdma_ll_lli_set_src_axi_burst_len(dw_gdma_link_list_item_t *lli, uint8_t len)
{
lli->ctrl_hi.arlen_en = len > 0;
HAL_FORCE_MODIFY_U32_REG_FIELD(lli->ctrl_hi, arlen, len);
}
/**
* @brief Set the destination burst length
* @brief Set the destination AXI burst length
*
* @param lli Link list item
* @param len Burst length
* @param len AXI burst length
*/
__attribute__((always_inline))
static inline void dw_gdma_ll_lli_set_dst_burst_len(dw_gdma_link_list_item_t *lli, uint8_t len)
static inline void dw_gdma_ll_lli_set_dst_axi_burst_len(dw_gdma_link_list_item_t *lli, uint8_t len)
{
lli->ctrl_hi.awlen_en = len > 0;
HAL_FORCE_MODIFY_U32_REG_FIELD(lli->ctrl_hi, awlen, len);
@@ -69,30 +69,32 @@ typedef enum {
} dw_gdma_transfer_width_t;
/**
* @brief DW_GDMA burst mode
* @brief DW_GDMA address increment mode
*/
typedef enum {
DW_GDMA_BURST_MODE_INCREMENT, /*!< The address is increased after each transfer */
DW_GDMA_BURST_MODE_FIXED, /*!< The address remains the same after each transfer */
} dw_gdma_burst_mode_t;
DW_GDMA_ADDR_INC_MODE_INCREMENT, /*!< The address is increased by the data width after each data item */
DW_GDMA_ADDR_INC_MODE_FIXED, /*!< The address remains the same after each data item (e.g. FIFO/peripheral target) */
} dw_gdma_addr_inc_mode_t;
/**
* @brief Number of data items that are contained in one burst transaction
* @brief DW_GDMA burst size: number of data items contained in one (core-level) burst transaction
*
* @note One item's bit width is set by `dw_gdma_transfer_width_t`
* @note This maps to the DW_GDMA `MSIZE` field. It is the coarse, usually power-of-two, size of a
* single burst request. One item's bit width is set by `dw_gdma_transfer_width_t`.
* @note This is different from `axi_burst_len`, which is the fine-grained AXI burst length.
*/
typedef enum {
DW_GDMA_BURST_ITEMS_1, /*!< 1 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_4, /*!< 4 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_8, /*!< 8 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_16, /*!< 16 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_32, /*!< 32 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_64, /*!< 64 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_128, /*!< 128 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_256, /*!< 256 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_512, /*!< 512 data items in a burst transaction */
DW_GDMA_BURST_ITEMS_1024, /*!< 1024 data items in a burst transaction */
} dw_gdma_burst_items_t;
DW_GDMA_BURST_SIZE_1, /*!< 1 data item in a burst transaction */
DW_GDMA_BURST_SIZE_4, /*!< 4 data items in a burst transaction */
DW_GDMA_BURST_SIZE_8, /*!< 8 data items in a burst transaction */
DW_GDMA_BURST_SIZE_16, /*!< 16 data items in a burst transaction */
DW_GDMA_BURST_SIZE_32, /*!< 32 data items in a burst transaction */
DW_GDMA_BURST_SIZE_64, /*!< 64 data items in a burst transaction */
DW_GDMA_BURST_SIZE_128, /*!< 128 data items in a burst transaction */
DW_GDMA_BURST_SIZE_256, /*!< 256 data items in a burst transaction */
DW_GDMA_BURST_SIZE_512, /*!< 512 data items in a burst transaction */
DW_GDMA_BURST_SIZE_1024, /*!< 1024 data items in a burst transaction */
} dw_gdma_burst_size_t;
#ifdef __cplusplus
}