dma driver apis

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

Upload: yazid

Post on 08-Feb-2016

51 views

Category:

Documents


1 download

DESCRIPTION

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. dmaLoadDriver(). Idle. dmaCloseChannel(). dmaUnloadChannel(). dmaOpenChannel(). dmaCloseChannel(). Enabled. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: DMA Driver APIs

DMA Driver APIs

DMA State DiagramLoading Driver and Opening ChannelDMA Channel AttributesLoading Data to a ChannelUnloading Data from a Channel

Page 2: DMA Driver APIs

DMA Driver State Diagram

Idle

Enabled Disabled

dmaLoadDriver()

dmaOpenChannel()

dmaDisableChannel()

dmaEnableChannel()

dmaCloseChannel()

dmaCloseChannel()

dmaLoadChannel()

dmaUnloadChannel()

Page 3: DMA Driver APIs

Loading DMA Driver

prototype: int dmaLoadDriver(void)

Returns 0 always.

Page 4: DMA Driver APIs

Opening a DMA Channelprototype: int dmaOpenChannel(

int *channel_ID,int channel_type,unsigned int option_flags,int ring_size,dmaReleaseType release_rtn)

example:

rc = dmaOpenChannel (

&channel_id,

DMA_FIFO_1_TX,

(DMA_MEM_TO_MEM_MODE | DMA_DADDR_INCR | DMA_SADDR_INCR),

64,

releaseFunction);

Returns Error Code

Page 5: DMA Driver APIs

dmaOpenChannel Return Codes

Possible Return Values for dmaOpenChannel()

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

Page 6: DMA Driver APIs

Channel ID

prototype: int dmaOpenChannel( int *channel_ID,int channel_type,unsigned int option_flags,int ring_size,dmaReleaseType (release_rtn)

Handle for opened channel, used in various DMA APIs.

Page 7: DMA Driver APIs

Channel Typeprototype: int dmaOpenChannel(

int *channel_ID,int channel_type,unsigned int option_flags,int ring_size,dmaReleaseType release_rtn)

PeripheralFIFO

DMA Memory “Fly-By Write”

PeripheralFIFO

DMA Memory “Fly-By Read”

DMA_FIFO_1_TX(Channel 4)

DMA_FIFO_1_RX(Channel 3)

Page 8: DMA Driver APIs

Option Flags

• 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

These Flags Configure the DMA Channel Control Registers

prototype: int dmaOpenChannel( int *channel_ID,

int channel_type,unsigned int option_flags,

int ring_size,dmaReleaseType release_rtn)

Page 9: DMA Driver APIs

option_flags: DMA_Operation Mode

PeripheralFIFO Memory

PeripheralFIFO Memory

Default Setting“Fly-By”

Memory DMA Memory DMA_MEM_TO_MEM

DMA

DMA

OR

Page 10: DMA Driver APIs

option_flags : Burst Transfer Size

BCLK

TA*

TA*

TA*

Default Setting

DMA_8_BYTE_BURST

DMA_16_BYTE_BURST

1 LongWord

(4 Bytes)

2 LongWords

(8 Bytes)

4 LongWords

(16 Bytes)

Page 11: DMA Driver APIs

option_flags : Channel Request Source

Net+ARM

DREQ* DACK* DONE*

Peripheral DMA_EXTERNAL_REQ

Net+ARM

DREQ* DACK* DONE*

Peripheral

Default SettingInternal Fly-By

peripheral*OR

Mem-to-Mem undersoftware control

*Note: Internal Fly-By hardwired to ENI RX and ENI TX

Page 12: DMA Driver APIs

option_flags : Address Increment

Applies to Memory-to-Memory DMA only.SourceMemory

DestinationMemory

SourceRange Destination

Range DMA_DADDR_INCDMA_SRC_INCR

SourceMemory

DestinationMemory

DestinationRange DMA_DADDR_INC

Default Setting

SourceLocation

*Note: It never makes sense to NOTincrement the destination address

DMA

DMA

Page 13: DMA Driver APIs

option_flags : DMA Transaction Operand Size

8-bitPeripheral

FIFOMemory

16-bitPeripheral

FIFOMemory

DMA_8_BIT

DMA_16_BIT

32-bitPeripheral

FIFOMemory Default Setting

DMA

DMA

DMA

Page 14: DMA Driver APIs

DMA Channel Ring Size

prototype: int dmaOpenChannel( int *channel_ID,int channel_type,unsigned int option_flags,int ring_size,dmaReleaseType release_rtn)

Ring Size = Number of Buffer Descriptors:

• Max 64 for Mem-to-Mem

• Max 128 for Fly-By

Page 15: DMA Driver APIs

DMA Channel ring_size

DMA Channel

Buffer Descriptor Pointer

SystemMemory

Buffer DescriptorRing Area

(CONTIGUOUS)

dmaOpenChannel() allocates BD ring area from heap, based on int ring_size.

Page 16: DMA Driver APIs

Release Callback

prototype: void (*dmaReleaseType) (int channel_ID, dmaMessageType *request_msg)

EnableddmaLoadChannel()

The defined callback will be called when thedmaLoadChannel() request has completed, with input parameters channel_ID and *request_msg.

prototype: int dmaOpenChannel( int *channel_ID,

int channel_type,unsigned int option_flags,

int ring_size,dmaReleaseType release_rtn)

Page 17: DMA Driver APIs

Loading a ChannelLoading a channel configures the previously allocated Buffer Descriptors.

prototype: int dmaLoadChannel(int channel_ID,dmaMessageType request_msg)

typedef struct dmaMessageStruct{

struct dmaMessageStruct *next;void *src_addr;void *dst_addr;long length;long status;long error_value;long reserved[4];

} dmaMessageType;

Page 18: DMA Driver APIs

Fly-By Read Loading

Memory

Destination Area

PeripheralFIFO

Set up enough dmaMessageType’sto accommodate all expected data.

*next Address of next dmaMessageType if more than 32Kbytes needed.

*src_addr Not Used*dst_addr Start of Destination (incrementing)length Up to 32Kbytes

Page 19: DMA Driver APIs

Fly-By Write Loading

Memory

Source Data Area

PeripheralFIFO

Set up enough dmaMessageType’sto accommodate outgoing data.

*next Address of next dmaMessageType if more than 32Kbytes needed.

*src_addr Start of Data Buffer (incrementing)*dst_addr Not Usedlength Up to 32Kbytes

Page 20: DMA Driver APIs

Memory to Memory Loading

Memory

Source Data Area

Memory

Set up enough dmaMessageType’sto accommodate outgoing data.

*next Address of next dmaMessageType if more than 32Kbytes needed.

*src_addr Start of Source Data Buffer (incrementing)*dst_addr Start of Destination Buffer (incrementing)length Up to 32Kbytes

Destination

Page 21: DMA Driver APIs

UnLoading a ChannelUnLoading a channel is called to remove a processed request from the DMA’s queue when no release callback is supplied.

prototype: int dmaUnloadChannel(int channel_ID,dmaMessageType *request_msg,int wait_time)

DMA Channel

Buffer Descriptor Pointer

SystemMemory

Buffer Descriptors

Used

Unused

Used

UnusedUnload

Note: Each request_msg uses one buffer descriptor.

Page 22: DMA Driver APIs

Request Processing - no Release Callback

dmaLoadChannel()

DMA Channel Request Queue

DMA ISR

DMA Channel Release Queue*

dmaUnloadChannel()

* Not built when a release callback is provided

fills

emptied by fills

emptied by

Page 23: DMA Driver APIs

DMA API SUmmary

• Load the driver - dmaLoadDriver• Open a channel - dmaOpenChannel

– 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