no-OS
axi_dmac.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef AXI_DMAC_H_
34 #define AXI_DMAC_H_
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include "no_os_util.h"
41 
42 /******************************************************************************/
43 /********************** Macros and Constants Definitions **********************/
44 /******************************************************************************/
45 #define AXI_DMAC_REG_IRQ_MASK 0x80
46 #define AXI_DMAC_REG_IRQ_PENDING 0x84
47 #define AXI_DMAC_IRQ_SOT NO_OS_BIT(0)
48 #define AXI_DMAC_IRQ_EOT NO_OS_BIT(1)
49 
50 #define AXI_DMAC_REG_INTF_DESC 0x010
51 #define AXI_DMAC_DMA_BPB_DEST NO_OS_GENMASK(3,0)
52 #define AXI_DMAC_DMA_TYPE_DEST NO_OS_GENMASK(5,4)
53 #define AXI_DMAC_DMA_BPB_SRC NO_OS_GENMASK(11,8)
54 #define AXI_DMAC_DMA_TYPE_SRC NO_OS_GENMASK(13,12)
55 //Define macro for src and dest
56 
57 #define AXI_DMAC_REG_CTRL 0x400
58 #define AXI_DMAC_CTRL_ENABLE NO_OS_BIT(0)
59 #define AXI_DMAC_CTRL_DISABLE 0u
60 #define AXI_DMAC_CTRL_PAUSE NO_OS_BIT(1)
61 
62 #define AXI_DMAC_REG_TRANSFER_ID 0x404
63 #define AXI_DMAC_REG_TRANSFER_SUBMIT 0x408
64 #define AXI_DMAC_TRANSFER_SUBMIT NO_OS_BIT(0)
65 #define AXI_DMAC_QUEUE_FULL NO_OS_BIT(0)
66 #define AXI_DMAC_REG_FLAGS 0x40c
67 #define AXI_DMAC_REG_DEST_ADDRESS 0x410
68 #define AXI_DMAC_REG_SRC_ADDRESS 0x414
69 #define AXI_DMAC_REG_X_LENGTH 0x418
70 #define AXI_DMAC_REG_Y_LENGTH 0x41c
71 #define AXI_DMAC_REG_DEST_STRIDE 0x420
72 #define AXI_DMAC_REG_SRC_STRIDE 0x424
73 #define AXI_DMAC_REG_TRANSFER_DONE 0x428
74 
75 /******************************************************************************/
76 /*************************** Types Declarations *******************************/
77 /******************************************************************************/
78 enum use_irq {
81 };
82 
88 };
89 
90 enum dma_flags {
92  DMA_LAST = 2,
94 };
95 
96 // Could be transformed to a bool
98  NO = 0,
99  CYCLIC = 1
100 };
101 
103  uint32_t size;
104  volatile bool transfer_done;
106  uint32_t src_addr;
107  uint32_t dest_addr;
108 };
109 
110 struct axi_dmac {
111  const char *name;
112  uint32_t base;
115  bool hw_cyclic;
116  uint32_t max_length;
117  uint32_t width_dst;
118  uint32_t width_src;
119  volatile struct axi_dma_transfer transfer;
120  //Current sub-transfer properties
121  uint32_t init_addr;
122  uint32_t remaining_size;
123  uint32_t next_src_addr;
124  uint32_t next_dest_addr;
125 };
126 
128  const char *name;
129  uint32_t base;
131 };
132 
133 /******************************************************************************/
134 /************************ Functions Declarations ******************************/
135 /******************************************************************************/
136 void axi_dmac_dev_to_mem_isr(void *instance);
137 void axi_dmac_mem_to_dev_isr(void *instance);
138 void axi_dmac_mem_to_mem_isr(void *instance);
139 void axi_dmac_write_isr(void *instance);
140 int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr,
141  uint32_t *reg_data);
142 int32_t axi_dmac_write(struct axi_dmac *dmac, uint32_t reg_addr,
143  uint32_t reg_data);
144 int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy);
145 int32_t axi_dmac_init(struct axi_dmac **adc_core,
146  const struct axi_dmac_init *init);
147 int32_t axi_dmac_remove(struct axi_dmac *dmac);
148 int32_t axi_dmac_transfer_start(struct axi_dmac *dmac,
149  struct axi_dma_transfer *dma_transfer);
150 int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac,
151  uint32_t timeout_ms);
152 void axi_dmac_transfer_stop(struct axi_dmac *dmac);
153 
154 #endif
AXI_DMAC_CTRL_ENABLE
#define AXI_DMAC_CTRL_ENABLE
Definition: axi_dmac.h:58
DMA_MEM_TO_MEM
@ DMA_MEM_TO_MEM
Definition: axi_dmac.h:87
axi_dmac_is_transfer_ready
int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy)
Definition: axi_dmac.c:263
AXI_DMAC_REG_INTF_DESC
#define AXI_DMAC_REG_INTF_DESC
Definition: axi_dmac.h:50
timeout
uint32_t timeout
Definition: ad413x.c:49
no_os_alloc.h
axi_dmac_init::base
uint32_t base
Definition: axi_dmac.h:129
AXI_DMAC_REG_X_LENGTH
#define AXI_DMAC_REG_X_LENGTH
Definition: axi_dmac.h:69
axi_dmac::transfer
volatile struct axi_dma_transfer transfer
Definition: axi_dmac.h:119
axi_dmac::max_length
uint32_t max_length
Definition: axi_dmac.h:116
axi_dmac::direction
enum dma_direction direction
Definition: axi_dmac.h:114
axi_dmac_mem_to_dev_isr
void axi_dmac_mem_to_dev_isr(void *instance)
Definition: axi_dmac.c:106
axi_dmac_transfer_start
int32_t axi_dmac_transfer_start(struct axi_dmac *dmac, struct axi_dma_transfer *dma_transfer)
Definition: axi_dmac.c:385
axi_dmac_init
Definition: axi_dmac.h:127
axi_dmac::next_dest_addr
uint32_t next_dest_addr
Definition: axi_dmac.h:124
axi_dmac_init::name
const char * name
Definition: axi_dmac.h:128
axi_dmac::width_dst
uint32_t width_dst
Definition: axi_dmac.h:117
axi_dmac_write_isr
void axi_dmac_write_isr(void *instance)
AXI_DMAC_REG_SRC_ADDRESS
#define AXI_DMAC_REG_SRC_ADDRESS
Definition: axi_dmac.h:68
DMA_PARTIAL_REPORTING_EN
@ DMA_PARTIAL_REPORTING_EN
Definition: axi_dmac.h:93
axi_dmac_transfer_wait_completion
int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac, uint32_t timeout_ms)
Definition: axi_dmac.c:525
axi_dma_transfer::transfer_done
volatile bool transfer_done
Definition: axi_dmac.h:104
no_os_delay.h
Header file of Delay functions.
axi_dmac_write
int32_t axi_dmac_write(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t reg_data)
Definition: axi_dmac.c:244
axi_dmac_transfer_stop
void axi_dmac_transfer_stop(struct axi_dmac *dmac)
Definition: axi_dmac.c:564
AXI_DMAC_DMA_BPB_DEST
#define AXI_DMAC_DMA_BPB_DEST
Definition: axi_dmac.h:51
no_os_axi_io.h
Header file of AXI IO.
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
axi_dmac_mem_to_dev_isr
void axi_dmac_mem_to_dev_isr(void *instance)
Definition: axi_dmac.c:106
AXI_DMAC_REG_SRC_STRIDE
#define AXI_DMAC_REG_SRC_STRIDE
Definition: axi_dmac.h:72
axi_dmac::next_src_addr
uint32_t next_src_addr
Definition: axi_dmac.h:123
AXI_DMAC_QUEUE_FULL
#define AXI_DMAC_QUEUE_FULL
Definition: axi_dmac.h:65
axi_dmac_remove
int32_t axi_dmac_remove(struct axi_dmac *dmac)
Definition: axi_dmac.c:367
DMA_MEM_TO_DEV
@ DMA_MEM_TO_DEV
Definition: axi_dmac.h:86
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
axi_dma_transfer
Definition: axi_dmac.h:102
no_os_error.h
Error codes definition.
use_irq
use_irq
Definition: axi_dmac.h:78
axi_dmac_transfer_wait_completion
int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac, uint32_t timeout_ms)
Definition: axi_dmac.c:525
IRQ_DISABLED
@ IRQ_DISABLED
Definition: axi_dmac.h:79
axi_dmac_read
int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t *reg_data)
Definition: axi_dmac.c:226
AXI_DMAC_REG_IRQ_PENDING
#define AXI_DMAC_REG_IRQ_PENDING
Definition: axi_dmac.h:46
AXI_DMAC_REG_TRANSFER_SUBMIT
#define AXI_DMAC_REG_TRANSFER_SUBMIT
Definition: axi_dmac.h:63
AXI_DMAC_CTRL_DISABLE
#define AXI_DMAC_CTRL_DISABLE
Definition: axi_dmac.h:59
IRQ_ENABLED
@ IRQ_ENABLED
Definition: axi_dmac.h:80
axi_dmac_init
int32_t axi_dmac_init(struct axi_dmac **adc_core, const struct axi_dmac_init *init)
Definition: axi_dmac.c:334
dma_direction
dma_direction
Definition: axi_dmac.h:83
axi_dmac.h
Driver for the Analog Devices AXI-DMAC core.
AXI_DMAC_REG_IRQ_MASK
#define AXI_DMAC_REG_IRQ_MASK
Definition: axi_dmac.h:45
axi_dma_transfer::src_addr
uint32_t src_addr
Definition: axi_dmac.h:106
dma_flags
dma_flags
Definition: axi_dmac.h:90
axi_dma_transfer::dest_addr
uint32_t dest_addr
Definition: axi_dmac.h:107
AXI_DMAC_IRQ_EOT
#define AXI_DMAC_IRQ_EOT
Definition: axi_dmac.h:48
axi_dmac::width_src
uint32_t width_src
Definition: axi_dmac.h:118
no_os_axi_io_read
int32_t no_os_axi_io_read(uint32_t base, uint32_t offset, uint32_t *data)
AXI IO Altera specific read function.
Definition: altera_axi_io.c:53
cyclic_transfer
cyclic_transfer
Definition: axi_dmac.h:97
axi_dmac_remove
int32_t axi_dmac_remove(struct axi_dmac *dmac)
Definition: axi_dmac.c:367
AXI_DMAC_IRQ_SOT
#define AXI_DMAC_IRQ_SOT
Definition: axi_dmac.h:47
axi_dmac_init::irq_option
enum use_irq irq_option
Definition: axi_dmac.h:130
axi_dmac_dev_to_mem_isr
void axi_dmac_dev_to_mem_isr(void *instance)
Definition: axi_dmac.c:55
axi_dma_transfer::cyclic
enum cyclic_transfer cyclic
Definition: axi_dmac.h:105
axi_dmac_is_transfer_ready
int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy)
Definition: axi_dmac.c:263
axi_dmac_write
int32_t axi_dmac_write(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t reg_data)
Definition: axi_dmac.c:244
AXI_DMAC_TRANSFER_SUBMIT
#define AXI_DMAC_TRANSFER_SUBMIT
Definition: axi_dmac.h:64
AXI_DMAC_REG_DEST_ADDRESS
#define AXI_DMAC_REG_DEST_ADDRESS
Definition: axi_dmac.h:67
axi_dmac_transfer_stop
void axi_dmac_transfer_stop(struct axi_dmac *dmac)
Definition: axi_dmac.c:564
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
AXI_DMAC_REG_FLAGS
#define AXI_DMAC_REG_FLAGS
Definition: axi_dmac.h:66
INVALID_DIR
@ INVALID_DIR
Definition: axi_dmac.h:84
NO
@ NO
Definition: axi_dmac.h:98
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
DMA_CYCLIC
@ DMA_CYCLIC
Definition: axi_dmac.h:91
axi_dmac_init
int32_t axi_dmac_init(struct axi_dmac **dmac_core, const struct axi_dmac_init *init)
Definition: axi_dmac.c:334
CYCLIC
@ CYCLIC
Definition: axi_dmac.h:99
axi_dmac_mem_to_mem_isr
void axi_dmac_mem_to_mem_isr(void *instance)
Definition: axi_dmac.c:163
axi_dmac::hw_cyclic
bool hw_cyclic
Definition: axi_dmac.h:115
axi_dmac::base
uint32_t base
Definition: axi_dmac.h:112
axi_dmac_dev_to_mem_isr
void axi_dmac_dev_to_mem_isr(void *instance)
Definition: axi_dmac.c:55
axi_dmac::init_addr
uint32_t init_addr
Definition: axi_dmac.h:121
no_os_axi_io_write
int32_t no_os_axi_io_write(uint32_t base, uint32_t offset, uint32_t data)
AXI IO Altera specific write function.
Definition: altera_axi_io.c:67
AXI_DMAC_REG_CTRL
#define AXI_DMAC_REG_CTRL
Definition: axi_dmac.h:57
axi_dmac_read
int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t *reg_data)
Definition: axi_dmac.c:226
axi_dmac_transfer_start
int32_t axi_dmac_transfer_start(struct axi_dmac *dmac, struct axi_dma_transfer *dma_transfer)
Definition: axi_dmac.c:385
DMA_LAST
@ DMA_LAST
Definition: axi_dmac.h:92
no_os_util.h
Header file of utility functions.
DMA_DEV_TO_MEM
@ DMA_DEV_TO_MEM
Definition: axi_dmac.h:85
AXI_DMAC_REG_DEST_STRIDE
#define AXI_DMAC_REG_DEST_STRIDE
Definition: axi_dmac.h:71
AXI_DMAC_DMA_BPB_SRC
#define AXI_DMAC_DMA_BPB_SRC
Definition: axi_dmac.h:53
axi_dmac::remaining_size
uint32_t remaining_size
Definition: axi_dmac.h:122
axi_dma_transfer::size
uint32_t size
Definition: axi_dmac.h:103
AXI_DMAC_REG_Y_LENGTH
#define AXI_DMAC_REG_Y_LENGTH
Definition: axi_dmac.h:70
axi_dmac::irq_option
enum use_irq irq_option
Definition: axi_dmac.h:113
axi_dmac::name
const char * name
Definition: axi_dmac.h:111
axi_dmac
Definition: axi_dmac.h:110
axi_dmac_mem_to_mem_isr
void axi_dmac_mem_to_mem_isr(void *instance)
Definition: axi_dmac.c:163