# include/dmac/dma_controller.h File Reference

DMA Controller Interface. More...

`#include <dma.h>`
`#include <slist.h>`
`#include <types.h>`
`#include <buffer.h>`
`#include <chip/dma_controller.h>`

Include dependency graph for dma_controller.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | dmac_request
| Asynchronous DMA request. More...
struct | dmac_channel
| A DMA Controller Channel. More...
struct | dma_controller
| A DMA Controller. More...
## Enumerations
enum | dmac_reg_width { DMAC_REG_WIDTH_8BIT = 0, DMAC_REG_WIDTH_16BIT = 1, DMAC_REG_WIDTH_32BIT = 2 }
| Peripheral register width. More...
enum | dmac_burst_length { DMAC_BURST_LENGTH_1 = 0, DMAC_BURST_LENGTH_4 = 1, DMAC_BURST_LENGTH_8 = 2, DMAC_BURST_LENGTH_16 = 3, DMAC_BURST_LENGTH_32 = 4 }
| Transaction burst length. More...
## Functions
static struct dmac_channel * | dmac_alloc_channel (struct dma_controller *dmac, enum dmac_periph_id rx_periph, enum dmac_periph_id tx_periph, phys_addr_t rx_reg_addr, phys_addr_t tx_reg_addr)
| Allocate a channel on a given DMA Controller.
static void | dmac_free_channel (struct dma_controller *dmac, struct dmac_channel *chan)
| Free a previously allocated DMA Controller channel.
static void | dmac_chan_submit_request (struct dmac_channel *chan, struct dmac_request *req)
| Submit a DMA transfer request.
static void | dmac_chan_reset (struct dmac_channel *chan)
| Reset a DMA channel.
static void | dmac_req_init (struct dmac_request *req)
| Initialize a DMA request.
static void | dmac_req_add_buffer (struct dmac_request *req, struct buffer *buf)
| Assign the buffer buf to the DMA request req.

## Detailed Description

DMA Controller Interface.

A DMA Controller (DMAC) is a device capable of doing data transfers between memory and a peripheral device without CPU intervention. Some controllers also support memory-to-memory transfers.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file dma_controller.h.

## Enumeration Type Documentation

enum dmac_burst_length

Transaction burst length.

Enumerator:

  DMAC_BURST_LENGTH_1 | 1 item
  DMAC_BURST_LENGTH_4 | 4 items
  DMAC_BURST_LENGTH_8 | 8 items
  DMAC_BURST_LENGTH_16 | 16 items
  DMAC_BURST_LENGTH_32 | 32 items

Definition at line 71 of file dma_controller.h.

enum dmac_reg_width

Peripheral register width.

Enumerator:

  DMAC_REG_WIDTH_8BIT | 8 bits
  DMAC_REG_WIDTH_16BIT | 16 bits
  DMAC_REG_WIDTH_32BIT | 32 bits

Definition at line 62 of file dma_controller.h.

## Function Documentation

static struct dmac_channel* dmac_alloc_channel | ( | struct dma_controller * | dmac,
|  | enum dmac_periph_id | rx_periph,
|  | enum dmac_periph_id | tx_periph,
|  | phys_addr_t | rx_reg_addr,
|  | phys_addr_t | tx_reg_addr |
| ) |  |  | `[static, read]`

Allocate a channel on a given DMA Controller.

Parameters:

  | dmac | The DMA Controller on which to allocate a channel
  | rx_periph | Perpiheral ID to use when receiving data, or DMAC_PERIPH_NONE if the channel is to be used for TX only.
  | tx_periph | Perpiheral ID to use when transmitting data, or DMAC_PERIPH_NONE if the channel is to be used for RX only.
  | rx_reg_addr | Physical address of the Receive Data Register
  | tx_reg_addr | Physical address of the Transmit Data Register

Returns:
  A DMA channel object which can be used to submit DMA transfer requests, or NULL if no channels are available.

Definition at line 146 of file dma_controller.h.

References dma_controller::alloc_chan.

static void dmac_chan_reset | ( | struct dmac_channel * | chan | ) | `[inline, static]`

Reset a DMA channel.

This function stops the DMA Controller and terminates all pending requests.

Parameters:

  | chan | The Channel to be reset

Definition at line 191 of file dma_controller.h.

References dmac_channel::reset.

static void dmac_chan_submit_request | ( | struct dmac_channel * | chan,
|  | struct dmac_request * | req |
| ) |  |  | `[inline, static]`

Submit a DMA transfer request.

This function does not return any value indicating if the request was successful; set up a req_done() callback and check dmac_request::status to verify the status of the request.

Parameters:

  | chan | The channel on which to submit the request
  | req | The request to be submitted

Definition at line 178 of file dma_controller.h.

References dmac_channel::submit_req.

Referenced by aes_submit_request(), and sdmmc_mcihost_load_data().

static void dmac_free_channel | ( | struct dma_controller * | dmac,
|  | struct dmac_channel * | chan |
| ) |  |  | `[inline, static]`

Free a previously allocated DMA Controller channel.

Parameters:

  | dmac | The DMA Controller from which the channel was allocated
  | chan | The Channel to be freed

Definition at line 162 of file dma_controller.h.

References dma_controller::free_chan.

static void dmac_req_add_buffer | ( | struct dmac_request * | req,
|  | struct buffer * | buf |
| ) |  |  | `[inline, static]`

Assign the buffer buf to the DMA request req.

buf will be transfered after any previously assigned buffers.

Definition at line 210 of file dma_controller.h.

References dmac_request::buf_list, buffer::node, and slist_insert_tail().

Here is the call graph for this function:

static void dmac_req_init | ( | struct dmac_request * | req | ) | `[inline, static]`

Initialize a DMA request.

Parameters:

  | req | The request to be initialized

Definition at line 200 of file dma_controller.h.

References dmac_request::buf_list, and slist_init().

Referenced by sdmmc_mcihost_init().

Here is the call graph for this function: