DMA Driver APIs DMA State Diagram Loading Driver

  • Slides: 23
Download presentation
DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes

DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading Data to a Channel Unloading Data from a Channel

DMA Driver State Diagram dma. Load. Driver() dma. Close. Channel() dma. Unload. Channel() Enabled

DMA Driver State Diagram dma. Load. Driver() dma. Close. Channel() dma. Unload. Channel() Enabled dma. Load. Channel() Idle dma. Open. Channel() dma. Disable. Channel() dma. Enable. Channel() dma. Close. Channel() Disabled

Loading DMA Driver prototype: int dma. Load. Driver(void) Returns 0 always.

Loading DMA Driver prototype: int dma. Load. Driver(void) Returns 0 always.

Opening a DMA Channel prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned

Opening a DMA Channel prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dma. Release. Type release_rtn) example: Returns Error Code rc = dma. Open. Channel ( &channel_id, DMA_FIFO_1_TX, (DMA_MEM_TO_MEM_MODE | DMA_DADDR_INCR | DMA_SADDR_INCR), 64, release. Function);

dma. Open. Channel Return Codes Possible Return Values for dma. Open. Channel() DMA_SUCCESS DMA_DRIVER_UNLOADED

dma. Open. Channel Return Codes Possible Return Values for dma. Open. Channel() DMA_SUCCESS DMA_DRIVER_UNLOADED DMA_INVALID_FLAG DMA_CHANNEL_INUSE DMA_INVALID_RING_SIZE DMA_CALLBACK_UNDEFINED MA_INVALID_STATE DMA_SYSTEM_ERROR DMA_CHANNEL_UNSUPPORTED

Channel ID prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags,

Channel ID prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, Handle for opened channel, used in various(release_rtn) DMA APIs. dma. Release. Type

Channel Type prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags,

Channel Type prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, Peripheral DMA_FIFO_1_TX DMA Memory “Fly-By Write” dma. Release. Type release_rtn) FIFO (Channel 4) DMA_FIFO_1_RX (Channel 3) Peripheral FIFO DMA Memory “Fly-By Read”

Option Flags prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags,

Option Flags prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dma. Release. Type release_rtn) These Flags Configure the DMA Channel Control Registers • DMA Operation Mode – DMA_MEM_TO_MEM • Burst Transfer Size – DMA_8_BYTE_BURST – DMA_16_BYTE_BURST • Channel Request Source – DMA_EXTERNAL_REQ • Source Address Increment – DMA_SRC_INCR • Destination Address Increment – DMA_DADDR_INC • DMA Transaction Operand Size – DMA_8_BIT – DMA_16_BIT

option_flags: DMA_Operation Mode Peripheral FIFO DMA Memory OR Peripheral FIFO DMA Memory Default Setting

option_flags: DMA_Operation Mode Peripheral FIFO DMA Memory OR Peripheral FIFO DMA Memory Default Setting “Fly-By” DMA_MEM_TO_MEM

option_flags : Burst Transfer Size BCLK Default Setting TA* DMA_8_BYTE_BURST TA* DMA_16_BYTE_BURST TA* 1

option_flags : Burst Transfer Size BCLK Default Setting TA* DMA_8_BYTE_BURST TA* DMA_16_BYTE_BURST TA* 1 Long Word (4 Bytes) 2 Long Words (8 Bytes) 4 Long Words (16 Bytes)

option_flags : Channel Request Source Net+ARM Default Setting DREQ* DACK* DONE* Peripheral Internal Fly-By

option_flags : Channel Request Source Net+ARM Default Setting DREQ* DACK* DONE* Peripheral Internal Fly-By peripheral* OR Mem-to-Mem under software control Net+ARM DREQ* DACK* DONE* Peripheral DMA_EXTERNAL_REQ *Note: Internal Fly-By hardwired to ENI RX and ENI TX

option_flags : Address Increment Applies to Memory-to-Memory DMA only. Source Memory DMA_SRC_INCR Source Range

option_flags : Address Increment Applies to Memory-to-Memory DMA only. Source Memory DMA_SRC_INCR Source Range Destination Memory DMA Source Memory Default Setting Source Location Destination Range DMA_DADDR_INC Destination Memory DMA Destination Range *Note: It never makes sense to NOT increment the destination address DMA_DADDR_INC

option_flags : DMA Transaction Operand Size 32 -bit Peripheral FIFO DMA Memory Default Setting

option_flags : DMA Transaction Operand Size 32 -bit Peripheral FIFO DMA Memory Default Setting 8 -bit Peripheral FIFO DMA Memory DMA_8_BIT 16 -bit Peripheral FIFO DMA Memory DMA_16_BIT

DMA Channel Ring Size prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned

DMA Channel Ring Size prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, Ring Size = Number of Buffer dma. Release. Type release_rtn) Descriptors: • Max 64 for Mem-to-Mem • Max 128 for Fly-By

DMA Channel ring_size DMA Channel System Memory Buffer Descriptor Pointer Buffer Descriptor Ring Area

DMA Channel ring_size DMA Channel System Memory Buffer Descriptor Pointer Buffer Descriptor Ring Area (CONTIGUOUS) dma. Open. Channel() allocates BD ring area from heap, based on int ring_size.

Release Callback prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags,

Release Callback prototype: int dma. Open. Channel( int *channel_ID, int channel_type, unsigned int option_flags, int ring_size, dma. Release. Type release_rtn) prototype: void (*dma. Release. Type) (int channel_ID, dma. Message. Type *request_msg) dma. Load. Channel() Enabled The defined callback will be called when the dma. Load. Channel() request has completed, with input parameters channel_ID and *request_msg.

Loading a Channel Loading a channel configures the previously allocated Buffer Descriptors. prototype: int

Loading a Channel Loading a channel configures the previously allocated Buffer Descriptors. prototype: int dma. Load. Channel( int channel_ID, dma. Message. Type request_msg) typedef struct dma. Message. Struct { struct dma. Message. Struct void long } dma. Message. Type; *next; *src_addr; *dst_addr; length; status; error_value; reserved[4];

Fly-By Read Loading Memory Destination Area Peripheral FIFO Set up enough dma. Message. Type’s

Fly-By Read Loading Memory Destination Area Peripheral FIFO Set up enough dma. Message. Type’s to accommodate all expected data. *next Address of next dma. Message. Type if more than 32 Kbytes needed. *src_addr Not Used *dst_addr Start of Destination (incrementing) length Up to 32 Kbytes

Fly-By Write Loading Memory Source Data Area Peripheral FIFO Set up enough dma. Message.

Fly-By Write Loading Memory Source Data Area Peripheral FIFO Set up enough dma. Message. Type’s to accommodate outgoing data. *next Address of next dma. Message. Type if more than 32 Kbytes needed. *src_addr Start of Data Buffer (incrementing) *dst_addr Not Used length Up to 32 Kbytes

Memory to Memory Loading Memory Source Data Area Memory Destination Set up enough dma.

Memory to Memory Loading Memory Source Data Area Memory Destination Set up enough dma. Message. Type’s to accommodate outgoing data. *next Address of next dma. Message. Type if more than 32 Kbytes needed. *src_addr Start of Source Data Buffer (incrementing) *dst_addr Start of Destination Buffer (incrementing) length Up to 32 Kbytes

Un. Loading a Channel Un. Loading a channel is called to remove a processed

Un. Loading a Channel Un. Loading a channel is called to remove a processed request from the DMA’s queue when no release callback is supplied. prototype: int dma. Unload. Channel( int channel_ID, dma. Message. Type *request_msg, int wait_time) DMA Channel System Memory Buffer Descriptor Pointer Buffer Descriptors Unused Unload Used Note: Each request_msg uses one buffer descriptor. Unused Used

Request Processing - no Release Callback dma. Load. Channel() dma. Unload. Channel() fills emptied

Request Processing - no Release Callback dma. Load. Channel() dma. Unload. Channel() fills emptied by DMA Channel Release Queue* DMA Channel Request Queue emptied by fills DMA ISR * Not built when a release callback is provided

DMA API SUmmary • Load the driver - dma. Load. Driver • Open a

DMA API SUmmary • Load the driver - dma. Load. Driver • Open a channel - dma. Open. Channel – Set channel ID, type, options, buffer ring size, release callback • Load the channel – Flyby – source or destination address – Memory to memory – both source and dest • Unload the channel if no release callback supplied