RTEMS 6.1-rc4
Loading...
Searching...
No Matches
Macros | Functions | Variables
fsl-edma.c File Reference

Freescale / NXP Enhanced Direct Memory Access (eDMA). More...

#include <fsl/edma.h>
#include <fsl/regs-edma.h>
#include <assert.h>
#include <bsp.h>
#include <bsp/fatal.h>
#include <bsp/irq.h>

Macros

#define EDMA_CHANNELS_PER_GROUP   32U
 
#define EDMA_GROUP_COUNT   ((EDMA_CHANNEL_COUNT + 31U) / 32U)
 
#define EDMA_GROUP_INDEX(channel)   ((channel) / EDMA_CHANNELS_PER_GROUP)
 
#define EDMA_GROUP_BIT(channel)   (1U << ((channel) % EDMA_CHANNELS_PER_GROUP))
 
#define EDMA_MODULE_INDEX(channel)   ((channel) / EDMA_CHANNELS_PER_MODULE)
 

Functions

unsigned fsl_edma_channel_index_of_tcd (volatile struct fsl_edma_tcd *edma_tcd)
 
volatile struct fsl_edma_tcd * fsl_edma_tcd_of_channel_index (unsigned index)
 
void fsl_edma_init (void)
 
rtems_status_code fsl_edma_obtain_channel_by_tcd (volatile struct fsl_edma_tcd *edma_tcd)
 Obtains an eDMA channel.
 
void fsl_edma_release_channel_by_tcd (volatile struct fsl_edma_tcd *edma_tcd)
 
rtems_status_code fsl_edma_obtain_channel (fsl_edma_channel_context *ctx, unsigned irq_priority)
 Obtains a specific eDMA channel and registers the channel context.
 
rtems_status_code fsl_edma_obtain_next_free_channel (fsl_edma_channel_context *ctx)
 Obtains a free eDMA channel and registers the channel context.
 
void fsl_edma_release_channel (fsl_edma_channel_context *ctx)
 
void fsl_edma_copy (volatile struct fsl_edma_tcd *edma_tcd, const struct fsl_edma_tcd *source_tcd)
 Copies a source TCD to an eDMA TCD.
 
void fsl_edma_copy_and_enable_hardware_requests (volatile struct fsl_edma_tcd *edma_tcd, const struct fsl_edma_tcd *source_tcd)
 Copies a source TCD to an eDMA TCD and enables hardware requests.
 
void fsl_edma_sg_link (volatile struct fsl_edma_tcd *edma_tcd, const struct fsl_edma_tcd *source_tcd)
 

Variables

volatile struct fsl_edmaedma_inst [EDMA_MODULE_COUNT]
 

Detailed Description

Freescale / NXP Enhanced Direct Memory Access (eDMA).

Function Documentation

◆ fsl_edma_copy()

void fsl_edma_copy ( volatile struct fsl_edma_tcd *  edma_tcd,
const struct fsl_edma_tcd *  source_tcd 
)

Copies a source TCD to an eDMA TCD.

The DONE flag of the eDMA TCD is cleared before the actual copy operation. This enables the setting of channel link or scatter/gather options.

This function can be used to start the channel if the START flags is set in the source TCD.

◆ fsl_edma_copy_and_enable_hardware_requests()

void fsl_edma_copy_and_enable_hardware_requests ( volatile struct fsl_edma_tcd *  edma_tcd,
const struct fsl_edma_tcd *  source_tcd 
)

Copies a source TCD to an eDMA TCD and enables hardware requests.

The DONE flag of the eDMA TCD is cleared before the actual copy operation. This enables the setting of channel link or scatter/gather options.

◆ fsl_edma_obtain_channel()

rtems_status_code fsl_edma_obtain_channel ( fsl_edma_channel_context ctx,
unsigned  irq_priority 
)

Obtains a specific eDMA channel and registers the channel context.

Tries to obtain the channel specified in the ctx.

irq_priority will be ignored on all targets but MPC55xx based ones.

The done handler of the channel context will be called

  • during minor or major loop completions if interrupts are enabled in the corresponding TCD, or
  • in case a channel error occurs.

An error status value not equal to zero indicates an error.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_RESOURCE_IN_USEThe channel is already in use.
RTEMS_IO_ERRORUnable to install interrupt handler for this channel.

◆ fsl_edma_obtain_channel_by_tcd()

rtems_status_code fsl_edma_obtain_channel_by_tcd ( volatile struct fsl_edma_tcd *  edma_tcd)

Obtains an eDMA channel.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_RESOURCE_IN_USEThe channel is already in use.

◆ fsl_edma_obtain_next_free_channel()

rtems_status_code fsl_edma_obtain_next_free_channel ( fsl_edma_channel_context ctx)

Obtains a free eDMA channel and registers the channel context.

Tries to obtain the next free DMA channel. The tcd field of ctx will be set accordingly.

The done handler of the channel context will be called

  • during minor or major loop completions if interrupts are enabled in the corresponding TCD, or
  • in case a channel error occurs.

An error status value not equal to zero indicates an error.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_RESOURCE_IN_USENo channels left.
RTEMS_IO_ERRORUnable to install interrupt handler.

Variable Documentation

◆ edma_inst

volatile struct fsl_edma* edma_inst[EDMA_MODULE_COUNT]
Initial value:
= {
}