EDMA Notes

Table of Contents

Overview

TMS320C6000 DSP Enhanced Direct Memory Access (EDMA) Controller Reference Guide pdf

Forum

Which DMA (EDMA or QDMA) channels are used by the Codec Engine and Codec Server in DM6467T DVSDK 3.10?

Note from TI81XX EDMA Driver User Guide

Introduction

The EDMA3 controller consists of two principal blocks:

  • EDMA3 channel controller (EDMA3CC)
  • EDMA3 transfer controller(s) (EDMA3TC

How to reserve different EDMA3 resources (DMA channels, TCCs, PaRAM Sets) on ARM side

The resource allocation in EDMA3 is based on a pre-aligned static configuration.

DMA Channels

In the source file arch\arm\mach-omap2\devices.c, array ti816x_dma_rsv_chans[][2] is used to reserve various DMA channels to the shadow regions of all other masters other than ARM.

static const s16 ti816x_dma_rsv_chans[][2] = {
        /* (offset, number) */
        {0, 4},
        {26, 6},
        {48, 4},
        {56, 8},
        {-1, -1}
};

The first entry means 4 channels from channel '0' i.e. channels '0-3' will be reserved for usage of other masters (for eg. DSP).

TCCs (i.e Interrupt channels)

It is assumed that if a particular channel number x is reserved for a particular master then the TCC x is also reserved for that same master. All drivers and applications running on all masters must keep this in mind and be programmed.

PaRAM Sets

In the source file arch\arm\mach-omap2\devices.c, array ti816x_dma_rsv_slots[][2] is used to reserve various PARAM sets (slot) to the shadow regions of all other masters other than ARM.

static const s16 ti816x_dma_rsv_slots[][2] = {
        /* (offset, number) */
        {0, 4},
        {26, 6},
        {48, 4},
        {56, 8},
        {64, 127},
        {-1, -1}
};

The first entry means 4 slots from slot '0' i.e. slots '0-3' will be reserved for usage of other masters (for eg. DSP).

Note 1: DMA channels and PaRAM Sets are one-to-one mapped, meaning thereby DMA channel X can ONLY use PaRAM Set X for its working.

Note 2: A DMA/QDMA channel also require a TCC for correct functioning. By default, DMA channels and TCCs are one-to-one mapped, meaning thereby DMA channel Y can ONLY use TCC Y for its working. (No such constraint is there for QDMA channels.)

How to change various other global settings

How to change default event queue (or Transfer Controller, TC) priorities?

Array ti816x_queue_priority_mapping[][2] can be used to change the default event queue priorities. This array is an array of structures having the first structure member as the event queue number and the second structure member as the priority. '0' is the highest priority, '1' is the second highest and so on.

static const s8 ti816x_queue_priority_mapping[][2] = {
        /* {event queue no, Priority} */
        {0, 0},
        {1, 1},
        {2, 2},
        {3, 3},
        {-1, -1}
};

Present configuration of EDMA3 resources on DM816X platform:

DMA816x

EDMA3 Resource ARM DSP
DMA Channel 4-25, 32-47, 52-55 0-3, 26-31, 48-51, 56-63
QDMA Channel 0,1 2-7
TCC 4-25, 32-47, 52-55 0-3, 26-31, 48-51, 56-63
PaRAM Set 4-25, 32-47, 52-55, 64-127 0-3, 26-31, 48-51, 56-63, 128-511

Sample test application for EDMA Driver

EDMA sample test application http://processors.wiki.ti.com/index.php/EDMA_sample_test_application

Copy this sample application file in a location (preferably not inside the kernel source code) and build it as a kernel module using a make file similar to one shown below

obj-m = edma_test.o
KDIR = "../linux-kernel"
all:
        make -C $(KDIR) M=$(PWD) modules
clean:
        make -C $(KDIR) M=$(PWD) clean

Note from Programming the EDMA3 using the Low-Level Driver (LLD)

Abstract

It consists of three (3) libraries:

  1. EDMA3 Resource Manager (RM library)
  2. EDMA3 Driver (DRV library)
  3. Chip-specific configuration files (Sample library)

EDMA3 Low Level Driver: http://processors.wiki.ti.com/images/5/5e/EDMA3_LLD.pdf

Brief Overview of EDMA3

DMA transfers can be triggered 3 different ways: (1) a manual START; (2) via a sync event from a peripheral; (3) via a chained event - i.e. the completion of channel x can kick off channel y to start.

A basic transfer requires the source address, destination address and a count value (how much to copy). Source and destination addresses are fairly obvious. The count value, however, is three-dimensional - ACNT, BCNT and CCNT.

  • ACNT specifies the number of bytes in an "element". For example, for 16-bit audio data, ACNT would be 2 bytes. This is the "minimum" transfer size.
  • BCNT specifies the number of "elements" in a "frame" or "line".
  • CCNT specifies the "block" size or the number of frames in the block. Each of these count values max out at 64K. So, the max transfer is 64K*64K*64K.

For more advanced transfers, the EDMA offers indexing between transfers for both the source and destination addresses. For example, if you'd like to bump the src address 4 bytes after each element transfer, you can set 'BIDX to 4. After the EDMA transfers the first element, the src address will be indexed 4 bytes (plus or minus) prior to the next transfer. The destination address has similar indexing capabilities. Also, 'CIDX can be employed to bump the src or dst addresses after a "frame" or "line" is transfered. A combination of these indexes can automatically perform "channel sorting" on incoming or outgoing data "free of charge" - with no time penalty.

The EDMA3 also allows for "linking" and "chaining" capabilities. Linking is the process of "reloading" a channel's peripheral configuration registers (or buffer descriptor) with another set after the first transfer is done. For example, when channel X is complete, maybe you'd like to transfer the same thing again. Extra "Reload" parameter sets are available to hold another configuration that can be "reloaded" automatically into Channel X's registers upon completion of a transfer. This does NOT start a transfer - it only configures the channel for the next transfer. "Chaining" is the ability for one channel's completion to trigger another transfer. For example, if channel X is chained to channel Y, when channel X completes, it triggers channel Y to start transferring.

Getting to know LLD by example – 9 to show the way

The EDMA LLD itself can be downloaded at: EDMA3 LLD Download Site

You can access the code examples at TI's external Gforge site:

Note from TMS320DM816x DaVinci Video Processors (sprugx8.pdf)1

5.7 Setting Up a Transfer

Initiating a DMA/QDMA channel

(a) Determine the type of channel (QDMA or DMA) to be used.

(b) Channel mapping

(i) If using a QDMA channel, program the DQCHMAP with the parameter set number to which the channel maps and the trigger word.

(ii) If using a DMA channel, program the DCHMAP with the parameter set number to which the channel maps.

(c) If the channel is being used in the context of a shadow region, ensure the DRAE/DRAEH for the region is properly set up to allow read write accesses to bits in the event registers and interrupt registers in the Shadow region memory map. The subsequent steps in this process should be done using the respective shadow region registers.

(d) Determine the type of triggering used.

(i) If external events are used for triggering (DMA channels), enable the respective event in EER/EERH by writing into EESR/EESRH.

(ii) If QDMA Channel is used, enable the channel in QEER by writing into QEESR.

(e) Queue setup

(i) If a QDMA channel is used, set up the QDMAQNUM to map the channel to the respective event queue.

(ii) If a DMA channel is used, set up the DMAQNUM to map the event to the respective eventqueue.

Parameter set setup

(a) Program the PaRAM set number associated with the channel. Note that if it is a QDMA channel, the PaRAM entry that is configured as trigger word is written to last. Alternatively, enable the QDMA channel (step 1-b-ii above) just before the write to the trigger word. See Section 5.3 for parameter set field setups for different types of transfers. See the sections on chaining and interrupt completion on how to set up final/intermediate completion chaining and/or interrupts.

Interrupt setup

(a) Enable the interrupt in the IER/IERH by writing into IESR/IESRH.

(b) Ensure that the EDMA3CC completion interrupt (either the global or the shadow region interrupt) is enabled properly in the device interrupt controller.

(c) Ensure the EDMA3CC completion interrupt (this refers to either the Global interrupt or the shadow region interrupt) is enabled properly in the Device Interrupt controller.

(d) Set up the interrupt controller properly to receive the expected EDMA3 interrupt.

Initiate transfer

(a) This step is highly dependent on the event trigger source:

(i) If the source is an external event coming from a peripheral, the peripheral will be enabled to start generating relevant EDMA3 events that can be latched to the ER transfer.

(ii) For QDMA events, writes to the trigger word (step 2-a above) will initiate the transfer.

(iii) Manually triggered transfers will be initiated by writes to the Event Set Registers (ESR/ESRH).

(iv) Chained-trigger events initiate when a previous transfer returns a transfer completion code equal to the chained channel number.

Wait for completion

(a) If the interrupts are enabled as mentioned in step 3 above, then the EDMA3CC will generate a completion interrupt to the CPU whenever transfer completion results in setting the corresponding bits in the interrupt pending register (IPR/IPRH). The set bits must be cleared in the IPR\IPRH by writing to corresponding bit in ICR\ICRH.

(b) If polling for completion (interrupts not enabled in the device controller), then the application code can wait on the expected bits to be set in the IPR\IPRH. Again, the set bits in the IPR\IPRH must be manually cleared via ICR\ICRH before the next set of transfers is performed for the same transfer completion code values.

Footnotes:

Author: Shi Shougang

Created: 2015-03-05 Thu 23:20

Emacs 24.3.1 (Org mode 8.2.10)

Validate