SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Classes | Macros | Functions
sys-dma.h File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <common.h>
#include <log.h>
#include <reg-dma.h>
#include <sys-clk.h>
Include dependency graph for sys-dma.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sunxi_dma_desc_t
 
struct  sunxi_dma_channel_config_t
 
struct  sunxi_dma_set_t
 
struct  sunxi_dma_irq_handler_t
 
struct  sunxi_dma_channel_reg_t
 
struct  sunxi_dma_reg_t
 
struct  sunxi_dma_source_t
 
struct  sunxi_dma_t
 

Macros

#define DMA_DEFAULT_CLK_RST_OFFSET   (16)
 
#define DMA_DEFAULT_CLK_GATE_OFFSET   (0)
 

Functions

void sunxi_dma_init (sunxi_dma_t *dma)
 Initialize the DMA subsystem.
 
void sunxi_dma_exit (sunxi_dma_t *dma)
 Clean up and exit the DMA subsystem.
 
uint32_t sunxi_dma_request (uint32_t dmatype)
 Request a DMA channel of the specified type.
 
uint32_t sunxi_dma_request_from_last (uint32_t dmatype)
 Request a DMA channel from the last allocated channel of the specified type.
 
int sunxi_dma_release (uint32_t dma_fd)
 Release a previously requested DMA channel.
 
int sunxi_dma_setting (uint32_t dma_fd, sunxi_dma_set_t *cfg)
 Configure the settings of a DMA channel.
 
int sunxi_dma_start (uint32_t dma_fd, uint32_t saddr, uint32_t daddr, uint32_t bytes)
 Start a DMA transfer.
 
int sunxi_dma_stop (uint32_t dma_fd)
 Stop a currently running DMA transfer.
 
int sunxi_dma_querystatus (uint32_t dma_fd)
 Query the status of a DMA transfer.
 
int sunxi_dma_install_int (uint32_t dma_fd, void *p)
 Installs an interrupt handler for the DMA.
 
int sunxi_dma_enable_int (uint32_t dma_fd)
 Enables interrupts for the specified DMA.
 
int sunxi_dma_disable_int (uint32_t dma_fd)
 Disables interrupts for the specified DMA.
 
int sunxi_dma_free_int (uint32_t dma_fd)
 Frees the interrupt resources for the specified DMA.
 
int sunxi_dma_test (uint32_t *src_addr, uint32_t *dst_addr, uint32_t len)
 Perform a test DMA transfer between the specified source and destination addresses.
 

Macro Definition Documentation

◆ DMA_DEFAULT_CLK_GATE_OFFSET

#define DMA_DEFAULT_CLK_GATE_OFFSET   (0)

◆ DMA_DEFAULT_CLK_RST_OFFSET

#define DMA_DEFAULT_CLK_RST_OFFSET   (16)

Function Documentation

◆ sunxi_dma_disable_int()

int sunxi_dma_disable_int ( uint32_t  dma_fd)

Disables interrupts for the specified DMA.

This function disables the interrupt generation for the specified DMA device, stopping it from signaling interrupts for completed or erroneous DMA operations.

Parameters
dma_fdFile descriptor for the DMA device.
Returns
0 on success, or a negative error code on failure.

Disables interrupts for the specified DMA.

Disables interrupts for a specific DMA channel.

Parameters
dma_fdHandle to the DMA channel
Returns
0 on success, -1 if channel is not in use

◆ sunxi_dma_enable_int()

int sunxi_dma_enable_int ( uint32_t  dma_fd)

Enables interrupts for the specified DMA.

This function enables the interrupt generation for the specified DMA device, allowing it to signal when DMA operations are complete or have encountered errors.

Parameters
dma_fdFile descriptor for the DMA device.
Returns
0 on success, or a negative error code on failure.

Enables interrupts for the specified DMA.

Enables interrupts for a specific DMA channel, specifically package end interrupts.

Parameters
dma_fdHandle to the DMA channel
Returns
0 on success, -1 if channel is not in use

◆ sunxi_dma_exit()

void sunxi_dma_exit ( sunxi_dma_t dma)

Clean up and exit the DMA subsystem.

Clean up and exit the DMA subsystem.

Releases all DMA channels, disables interrupts, and shuts down the DMA controller.

Parameters
dmaPointer to DMA configuration structure

◆ sunxi_dma_free_int()

int sunxi_dma_free_int ( uint32_t  dma_fd)

Frees the interrupt resources for the specified DMA.

This function releases any resources associated with the DMA interrupt handler that was previously installed. It should be called when the DMA is no longer in use.

Parameters
dma_fdFile descriptor for the DMA device.
Returns
0 on success, or a negative error code on failure.

Frees the interrupt resources for the specified DMA.

Releases the interrupt handler associated with a DMA channel and clears pending interrupts.

Parameters
dma_fdHandle to the DMA channel
Returns
0 on success, -1 if channel is not in use or interrupt handler was not set

◆ sunxi_dma_init()

void sunxi_dma_init ( sunxi_dma_t dma)

Initialize the DMA subsystem.

Initialize the DMA subsystem.

Initializes the DMA controller by setting up registers, clearing interrupts, configuring auto clock gating, and initializing channel structures.

Parameters
dmaPointer to DMA configuration structure containing base addresses and settings

◆ sunxi_dma_install_int()

int sunxi_dma_install_int ( uint32_t  dma_fd,
void *  p 
)

Installs an interrupt handler for the DMA.

This function installs a DMA interrupt handler to manage DMA transfer completion or error events.

Parameters
dma_fdFile descriptor for the DMA device.
pPointer to the data structure that holds the interrupt handler context or configuration.
Returns
0 on success, or a negative error code on failure.

Installs an interrupt handler for the DMA.

Sets up an interrupt handler for a DMA channel and clears any pending interrupts.

Parameters
dma_fdHandle to the DMA channel
pUser data to associate with the interrupt handler
Returns
0 on success, -1 if channel is not in use

◆ sunxi_dma_querystatus()

int sunxi_dma_querystatus ( uint32_t  dma_fd)

Query the status of a DMA transfer.

Parameters
hdmaThe DMA channel number to query status for.
Returns
The status of the DMA transfer.

Query the status of a DMA transfer.

Checks whether a DMA transfer is still in progress on the specified channel.

Parameters
dma_fdHandle to the DMA channel to query
Returns
1 if transfer is in progress, 0 if completed, -1 if channel is not in use

◆ sunxi_dma_release()

int sunxi_dma_release ( uint32_t  dma_fd)

Release a previously requested DMA channel.

Parameters
hdmaThe DMA channel number to release.
Returns
0 if successful, or an error code if failed.

Release a previously requested DMA channel.

Releases a previously requested DMA channel, disabling its interrupts.

Parameters
dma_fdHandle to the DMA channel to release
Returns
0 on success, -1 if the channel was not in use

◆ sunxi_dma_request()

uint32_t sunxi_dma_request ( uint32_t  dmatype)

Request a DMA channel of the specified type.

Parameters
dmatypeThe type of DMA channel to request.
Returns
The DMA channel number if successful, or an error code if failed.

Request a DMA channel of the specified type.

Searches for an available DMA channel starting from channel 0.

Parameters
dmatypeType of DMA channel to request (currently unused)
Returns
Handle to the requested DMA channel, or 0 if no channels are available

◆ sunxi_dma_request_from_last()

uint32_t sunxi_dma_request_from_last ( uint32_t  dmatype)

Request a DMA channel from the last allocated channel of the specified type.

Parameters
dmatypeThe type of DMA channel to request.
Returns
The DMA channel number if successful, or an error code if failed.

Request a DMA channel from the last allocated channel of the specified type.

Searches for an available DMA channel starting from the highest-numbered channel.

Parameters
dmatypeType of DMA channel to request (currently unused)
Returns
Handle to the requested DMA channel, or 0 if no channels are available

◆ sunxi_dma_setting()

int sunxi_dma_setting ( uint32_t  dma_fd,
sunxi_dma_set_t cfg 
)

Configure the settings of a DMA channel.

Parameters
hdmaThe DMA channel number to configure.
cfgPointer to the DMA configuration structure.
Returns
0 if successful, or an error code if failed.

Configure the settings of a DMA channel.

Sets up a DMA channel with specified configuration parameters like loop mode, wait cycles, and data block size.

Parameters
dma_fdHandle to the DMA channel to configure
cfgPointer to configuration structure containing DMA settings
Returns
0 on success, -1 if the channel is not in use

◆ sunxi_dma_start()

int sunxi_dma_start ( uint32_t  dma_fd,
uint32_t  saddr,
uint32_t  daddr,
uint32_t  bytes 
)

Start a DMA transfer.

Parameters
hdmaThe DMA channel number to start the transfer on.
saddrSource address of the data to transfer.
daddrDestination address to transfer the data to.
bytesNumber of bytes to transfer.
Returns
0 if successful, or an error code if failed.

Initiates a DMA data transfer from source to destination address with specified size.

Parameters
dma_fdHandle to the DMA channel to use
saddrSource address for the DMA transfer
daddrDestination address for the DMA transfer
bytesNumber of bytes to transfer
Returns
0 on success, -1 if the channel is not in use

◆ sunxi_dma_stop()

int sunxi_dma_stop ( uint32_t  dma_fd)

Stop a currently running DMA transfer.

Parameters
hdmaThe DMA channel number to stop the transfer on.
Returns
0 if successful, or an error code if failed.

Stop a currently running DMA transfer.

Halts an ongoing DMA transfer on the specified channel.

Parameters
dma_fdHandle to the DMA channel to stop
Returns
0 on success, -1 if the channel is not in use

◆ sunxi_dma_test()

int sunxi_dma_test ( uint32_t src_addr,
uint32_t dst_addr,
uint32_t  len 
)

Perform a test DMA transfer between the specified source and destination addresses.

Parameters
src_addrPointer to the source address.
dst_addrPointer to the destination address.
Returns
0 if successful, or an error code if failed.

Perform a test DMA transfer between the specified source and destination addresses.

Performs a DMA transfer test between two memory regions, verifies data integrity, and reports transfer performance.

Parameters
src_addrSource memory address for test transfer
dst_addrDestination memory address for test transfer
lenLength of data to transfer in bytes
Returns
0 on success, -1 if channel request failed, -2 if transfer timed out