# DMA
[PLATFORM]

DMA utility functions. More...

Collaboration diagram for DMA:

## Data Structures
struct | dma_desc
| Element in the pool of TX DMA bridge descriptors. More...
struct | dma_env_tag
| Structure describing the DMA driver environment. More...
## Defines
#define | IPC_DMA_LLI_TX_MASK 0x001F
| Mask of the DMA LLI IRQs status bits that are assigned for TX.
#define | IPC_DMA_LLI_CFM_MASK 0x0100
| Mask of the DMA LLI IRQs status bits that are assigned for CFM.
#define | IPC_DMA_LLI_RX_MASK 0x0020
| Mask of the DMA LLI IRQs status bits that are assigned for RX.
#define | IPC_DMA_LLI_COUNTER_EN 0x0010
| Indicate that an LLI counter must be incremented at the end of the LLI process.
#define | IPC_DMA_LLI_COUNTER_MASK 0x000F
| Mask of the LLI counter index to increment at the end of the LLI process.
#define | IPC_DMA_LLI_COUNTER_POS 0
| Bit position of the LLI counter index.
#define | IPC_DMA_LLI_IRQ_EN 0x1000
| Indicate that an IRQ must be generated at the end of the LLI process.
#define | IPC_DMA_LLI_IRQ_MASK 0x0F00
| Mask of the LLI IRQ index to generate at the end of the LLI process.
#define | IPC_DMA_LLI_IRQ_POS 8
| Bit position of the LLI IRQ index.
## Enumerations
enum | { IPC_DMA_CHANNEL_CTRL_RX, IPC_DMA_CHANNEL_DATA_RX, IPC_DMA_CHANNEL_CTRL_TX, IPC_DMA_CHANNEL_DATA_TX, IPC_DMA_CHANNEL_INTERNAL, IPC_DMA_CHANNEL_MAX }
| DMA channel indexes. More...
enum | { IPC_DMA_LLI_DATA_AC0_TX, IPC_DMA_LLI_DATA_AC1_TX, IPC_DMA_LLI_DATA_AC2_TX, IPC_DMA_LLI_DATA_AC3_TX, IPC_DMA_LLI_DATA_BCN_TX, IPC_DMA_LLI_DATA_RX0, IPC_DMA_LLI_MSG, IPC_DMA_LLI_DBG, IPC_DMA_LLI_CFM_TX, IPC_DMA_LLI_GP_DL, IPC_DMA_LLI_DBG_DUMP, IPC_DMA_LLI_GP_UL, IPC_DMA_LLI_MAX }
| DMA LLI assignment. More...
## Functions
void | dma_init (void)
| Initialize the bridge DMA registers.
void | dma_push (struct dma_desc *first, struct dma_desc *last, int channel_idx)
| Chains a chained list of descriptors in the DMA.
void | dma_buserr_isr (void)
| Interrupt service routine when a bus error is detected while in a DMA transfer.
__INLINE void | dma_lli_disable (int lli)
| Disable an LLI IRQ.
__INLINE void | dma_lli_enable (int lli)
| Enable an LLI IRQ.
__INLINE void | dma_lli_poll (int lli)
| Poll for an LLI IRQ.
## Variables
struct dma_env_tag | dma_env
| DMA environment structure.

## Detailed Description

DMA utility functions.

## Enumeration Type Documentation

anonymous enum

DMA channel indexes.

Enumerator:

  IPC_DMA_CHANNEL_CTRL_RX | Upload control channel.
  IPC_DMA_CHANNEL_DATA_RX | Upload data channel.
  IPC_DMA_CHANNEL_CTRL_TX | Download control channel.
  IPC_DMA_CHANNEL_DATA_TX | Download data channel.
  IPC_DMA_CHANNEL_INTERNAL | Internal transfer channel.
  IPC_DMA_CHANNEL_MAX | Number of DMA channels.

Definition at line 42 of file dma.h.

anonymous enum

DMA LLI assignment.

This mapping is more important than it looks because of the way the interrupts are mapped on the reference IP interrupt controller:

- LLI0 to 3 are mapped to a single interrupt and therefore the handler of the TX can be called directly since the interrupt controller is indexed
- LLI4 to 7 are mapped to a single interrupt and therefore the handler of the RX can be called directly since the interrupt controller is indexed

Enumerator:

  IPC_DMA_LLI_DATA_AC0_TX | LLI for BK TX queue downloads.
  IPC_DMA_LLI_DATA_AC1_TX | LLI for BE TX queue downloads.
  IPC_DMA_LLI_DATA_AC2_TX | LLI for VI TX queue downloads.
  IPC_DMA_LLI_DATA_AC3_TX | LLI for VO TX queue downloads.
  IPC_DMA_LLI_DATA_BCN_TX | LLI for BCN TX queue downloads.
  IPC_DMA_LLI_DATA_RX0 | LLI for RX transfers.
  IPC_DMA_LLI_MSG | LLI for kernel messages upload.
  IPC_DMA_LLI_DBG | LLI for debug messages upload.
  IPC_DMA_LLI_CFM_TX | LLI for BK TX queue confirmation uploads.
  IPC_DMA_LLI_GP_DL | LLI for general purpose DMA downloads.
  IPC_DMA_LLI_DBG_DUMP | LLI for debug dump uploads.
  IPC_DMA_LLI_GP_UL | LLI for general purpose DMA uploads.
  IPC_DMA_LLI_MAX | Number of LLI used.

Definition at line 65 of file dma.h.

## Function Documentation

void dma_buserr_isr | ( | void |  | ) |

Interrupt service routine when a bus error is detected while in a DMA transfer.

This error is considered as fatal and triggers a non-recoverable assertion.

Definition at line 85 of file dma.c.

References ASSERT_ERR.

void dma_init | ( | void |  | ) |

Initialize the bridge DMA registers.

Definition at line 27 of file dma.c.

References dma_env, and dma_env_tag::last_dma.

__INLINE void dma_lli_disable | ( | int | lli | ) |

Disable an LLI IRQ.

Parameters:

  `[in]` | lli | LLI IRQ index (must be in range 0..15)

Definition at line 190 of file dma.h.

References CO_BIT.

__INLINE void dma_lli_enable | ( | int | lli | ) |

Enable an LLI IRQ.

Parameters:

  `[in]` | lli | LLI IRQ index (must be in range 0..15)

Definition at line 203 of file dma.h.

References CO_BIT.

__INLINE void dma_lli_poll | ( | int | lli | ) |

Poll for an LLI IRQ.

Parameters:

  `[in]` | lli | LLI IRQ index (must be in range 0..15)

Definition at line 217 of file dma.h.

References CO_BIT.

Referenced by macif_tx_cfm_done().

void dma_push | ( | struct dma_desc * | first,
|  | struct dma_desc * | last,
|  | int | channel_idx |
| ) |  |  |

Chains a chained list of descriptors in the DMA.

Parameters:

  `[in]` | first | First DMA descriptor of the list (filled by the caller)
  `[in]` | last | last DMA descriptor of the list (filled by the caller)
  `[in]` | channel_idx | Channel index

Definition at line 38 of file dma.c.

References ASSERT_ERR, CPU2HW, dma_env, GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, IPC_DMA_CHANNEL_INTERNAL, dma_env_tag::last_dma, and dma_desc::next.

Referenced by macif_rx_desc_upload(), macif_tx_cfm_done(), rxl_mpdu_transfer(), rxl_payload_transfer(), and txl_int_fake_transfer().