SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Macros | Functions | Variables
usb_dma.c 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 <sys-clk.h>
#include "usb.h"
#include "usb_controller.h"
#include "usb_dma.h"
Include dependency graph for usb_dma.c:

Macros

#define SUNXI_USB_DMA_MAX   (8)
 

Functions

static int lowlevel_usb_dma_set_channal_para (uint64_t husb, uint32_t dma_chan, uint32_t trans_dir, uint32_t ep_type)
 Set the parameters for a USB DMA channel.
 
static int lowlevel_usb_dma_set_packet_len (uint64_t husb, uint32_t dma_chan, uint32_t pkt_len)
 Set the packet length for a USB DMA channel.
 
static int lowlevel_usb_dma_start (uint64_t husb, uint32_t dma_chan, uint32_t addr, uint32_t pkt_len)
 Start a USB DMA transfer on a specific channel.
 
static int lowlevel_usb_dma_int_stop (uint64_t husb, uint32_t dma_chan)
 Stop a USB DMA transfer on a specific channel.
 
static int lowlevel_usb_dma_int_query (uint64_t husb)
 Query the status of USB DMA transfers.
 
static int lowlevel_usb_dma_int_clear (uint64_t husb)
 Clear the status of USB DMA transfers.
 
static int usb_index_check (uint32_t dma_index)
 Check if the USB DMA index is valid.
 
int usb_dma_init (uint64_t husb)
 Initialize USB DMA.
 
int usb_dma_request (void)
 Request a USB DMA channel.
 
int usb_dma_release (uint32_t dma_index)
 Release a USB DMA channel.
 
int usb_dma_setting (uint32_t dma_index, uint32_t trans_dir, uint32_t ep)
 Set the parameters of a USB DMA channel.
 
int usb_dma_set_pktlen (uint32_t dma_index, uint32_t pkt_len)
 Set the packet length of a USB DMA channel.
 
int usb_dma_start (uint32_t dma_index, uint32_t addr, uint32_t bytes)
 Start a USB DMA transfer.
 
int usb_dma_stop (uint32_t dma_index)
 Stop a USB DMA transfer.
 
int usb_dma_int_query (uint32_t dma_index)
 Query the interrupt status of a USB DMA channel.
 
int usb_dma_int_clear (void)
 Clear the interrupt status of all USB DMA channels.
 

Variables

static uint32_t usb_hd
 
static uint32_t usb_dma_used [SUNXI_USB_DMA_MAX]
 

Macro Definition Documentation

◆ SUNXI_USB_DMA_MAX

#define SUNXI_USB_DMA_MAX   (8)

Function Documentation

◆ lowlevel_usb_dma_int_clear()

static int lowlevel_usb_dma_int_clear ( uint64_t  husb)
static

Clear the status of USB DMA transfers.

This function is used to clear the status of USB DMA transfers.

Parameters
husbThe USB controller handle
Returns
0 on success, -1 on failure

◆ lowlevel_usb_dma_int_query()

static int lowlevel_usb_dma_int_query ( uint64_t  husb)
static

Query the status of USB DMA transfers.

This function is used to query the status of USB DMA transfers.

Parameters
husbThe USB controller handle
Returns
The status of DMA transfers on success, -1 on failure

◆ lowlevel_usb_dma_int_stop()

static int lowlevel_usb_dma_int_stop ( uint64_t  husb,
uint32_t  dma_chan 
)
static

Stop a USB DMA transfer on a specific channel.

This function is used to stop a USB DMA transfer on a specific channel.

Parameters
husbThe USB controller handle
dma_chanThe DMA channel number
Returns
0 on success, -1 on failure

◆ lowlevel_usb_dma_set_channal_para()

static int lowlevel_usb_dma_set_channal_para ( uint64_t  husb,
uint32_t  dma_chan,
uint32_t  trans_dir,
uint32_t  ep_type 
)
static

Set the parameters for a USB DMA channel.

This function is used to configure the parameters for a specific USB DMA channel.

Parameters
husbThe USB controller handle
dma_chanThe DMA channel number
trans_dirThe transfer direction (0: OUT, 1: IN)
ep_typeThe endpoint type
Returns
0 on success, -1 on failure

◆ lowlevel_usb_dma_set_packet_len()

static int lowlevel_usb_dma_set_packet_len ( uint64_t  husb,
uint32_t  dma_chan,
uint32_t  pkt_len 
)
static

Set the packet length for a USB DMA channel.

This function is used to set the packet length for a specific USB DMA channel.

Parameters
husbThe USB controller handle
dma_chanThe DMA channel number
pkt_lenThe packet length to be set
Returns
0 on success, -1 on failure

◆ lowlevel_usb_dma_start()

static int lowlevel_usb_dma_start ( uint64_t  husb,
uint32_t  dma_chan,
uint32_t  addr,
uint32_t  pkt_len 
)
static

Start a USB DMA transfer on a specific channel.

This function is used to start a USB DMA transfer on a specific channel with the given address and packet length.

Parameters
husbThe USB controller handle
dma_chanThe DMA channel number
addrThe address of the buffer to be transferred
pkt_lenThe length of the packet to be transferred
Returns
0 on success, -1 on failure

◆ usb_dma_init()

int usb_dma_init ( uint64_t  husb)

Initialize USB DMA.

This function is used to initialize USB DMA.

Parameters
husbThe USB controller handle
Returns
0 on success

◆ usb_dma_int_clear()

int usb_dma_int_clear ( void  )

Clear the interrupt status of all USB DMA channels.

This function is used to clear the interrupt status of all USB DMA channels.

Returns
0 on success, -1 on failure

◆ usb_dma_int_query()

int usb_dma_int_query ( uint32_t  dma_index)

Query the interrupt status of a USB DMA channel.

This function is used to query the interrupt status of a USB DMA channel.

Parameters
dma_indexThe DMA index to query
Returns
The interrupt status of the DMA channel

◆ usb_dma_release()

int usb_dma_release ( uint32_t  dma_index)

Release a USB DMA channel.

This function is used to release a USB DMA channel.

Parameters
dma_indexThe DMA index to release
Returns
0 on success, -1 on failure

◆ usb_dma_request()

int usb_dma_request ( void  )

Request a USB DMA channel.

This function is used to request a USB DMA channel.

Returns
The DMA index on success, 0 if no available DMA channel is found

◆ usb_dma_set_pktlen()

int usb_dma_set_pktlen ( uint32_t  dma_index,
uint32_t  pkt_len 
)

Set the packet length of a USB DMA channel.

This function is used to set the packet length of a USB DMA channel.

Parameters
dma_indexThe DMA index to configure
pkt_lenThe packet length to set
Returns
0 on success, -1 on failure

◆ usb_dma_setting()

int usb_dma_setting ( uint32_t  dma_index,
uint32_t  trans_dir,
uint32_t  ep 
)

Set the parameters of a USB DMA channel.

This function is used to set the parameters of a USB DMA channel.

Parameters
dma_indexThe DMA index to configure
trans_dirThe transfer direction (IN or OUT)
epThe endpoint number
Returns
0 on success, -1 on failure

◆ usb_dma_start()

int usb_dma_start ( uint32_t  dma_index,
uint32_t  addr,
uint32_t  bytes 
)

Start a USB DMA transfer.

This function is used to start a USB DMA transfer.

Parameters
dma_indexThe DMA index to use
addrThe address of the buffer for the transfer
bytesThe number of bytes to transfer
Returns
0 on success, -1 on failure

◆ usb_dma_stop()

int usb_dma_stop ( uint32_t  dma_index)

Stop a USB DMA transfer.

This function is used to stop a USB DMA transfer.

Parameters
dma_indexThe DMA index to stop
Returns
0 on success, -1 on failure

◆ usb_index_check()

static int usb_index_check ( uint32_t  dma_index)
static

Check if the USB DMA index is valid.

This function is used to check if the USB DMA index is within range and is currently in use.

Parameters
dma_indexThe USB DMA index to check
Returns
0 on success, -1 on failure

Variable Documentation

◆ usb_dma_used

uint32_t usb_dma_used[SUNXI_USB_DMA_MAX]
static

◆ usb_hd

uint32_t usb_hd
static