no-OS
axi_dmac.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef AXI_DMAC_H_
40 #define AXI_DMAC_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_util.h"
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 #define AXI_DMAC_REG_IRQ_MASK 0x80
52 #define AXI_DMAC_REG_IRQ_PENDING 0x84
53 #define AXI_DMAC_IRQ_SOT NO_OS_BIT(0)
54 #define AXI_DMAC_IRQ_EOT NO_OS_BIT(1)
55 
56 #define AXI_DMAC_REG_INTF_DESC 0x010
57 #define AXI_DMAC_DMA_TYPE_DEST NO_OS_GENMASK(5,4)
58 #define AXI_DMAC_DMA_TYPE_SRC NO_OS_GENMASK(13,12)
59 //Define macro for src and dest
60 
61 #define AXI_DMAC_REG_CTRL 0x400
62 #define AXI_DMAC_CTRL_ENABLE NO_OS_BIT(0)
63 #define AXI_DMAC_CTRL_DISABLE 0u
64 #define AXI_DMAC_CTRL_PAUSE NO_OS_BIT(1)
65 
66 #define AXI_DMAC_REG_TRANSFER_ID 0x404
67 #define AXI_DMAC_REG_TRANSFER_SUBMIT 0x408
68 #define AXI_DMAC_TRANSFER_SUBMIT NO_OS_BIT(0)
69 #define AXI_DMAC_QUEUE_FULL NO_OS_BIT(0)
70 #define AXI_DMAC_REG_FLAGS 0x40c
71 #define AXI_DMAC_REG_DEST_ADDRESS 0x410
72 #define AXI_DMAC_REG_SRC_ADDRESS 0x414
73 #define AXI_DMAC_REG_X_LENGTH 0x418
74 #define AXI_DMAC_REG_Y_LENGTH 0x41c
75 #define AXI_DMAC_REG_DEST_STRIDE 0x420
76 #define AXI_DMAC_REG_SRC_STRIDE 0x424
77 #define AXI_DMAC_REG_TRANSFER_DONE 0x428
78 
79 /******************************************************************************/
80 /*************************** Types Declarations *******************************/
81 /******************************************************************************/
82 enum use_irq {
85 };
86 
92 };
93 
94 enum dma_flags {
96  DMA_LAST = 2,
98 };
99 
100 // Could be transformed to a bool
102  NO = 0,
103  CYCLIC = 1
104 };
105 
107  uint32_t size;
108  volatile bool transfer_done;
110  uint32_t src_addr;
111  uint32_t dest_addr;
112 };
113 
114 struct axi_dmac {
115  const char *name;
116  uint32_t base;
119  bool hw_cyclic;
120  uint32_t max_length;
121  volatile struct axi_dma_transfer transfer;
122  //Current sub-transfer properties
123  uint32_t init_addr;
124  uint32_t remaining_size;
125  uint32_t next_src_addr;
126  uint32_t next_dest_addr;
127 };
128 
130  const char *name;
131  uint32_t base;
133 };
134 
135 /******************************************************************************/
136 /************************ Functions Declarations ******************************/
137 /******************************************************************************/
138 void axi_dmac_dev_to_mem_isr(void *instance);
139 void axi_dmac_mem_to_dev_isr(void *instance);
140 void axi_dmac_mem_to_mem_isr(void *instance);
141 void axi_dmac_write_isr(void *instance);
142 int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr,
143  uint32_t *reg_data);
144 int32_t axi_dmac_write(struct axi_dmac *dmac, uint32_t reg_addr,
145  uint32_t reg_data);
146 int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy);
147 int32_t axi_dmac_init(struct axi_dmac **adc_core,
148  const struct axi_dmac_init *init);
149 int32_t axi_dmac_remove(struct axi_dmac *dmac);
150 int32_t axi_dmac_transfer_start(struct axi_dmac *dmac,
151  struct axi_dma_transfer *dma_transfer);
152 int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac,
153  uint32_t timeout_ms);
154 void axi_dmac_transfer_stop(struct axi_dmac *dmac);
155 
156 #endif
AXI_DMAC_CTRL_ENABLE
#define AXI_DMAC_CTRL_ENABLE
Definition: axi_dmac.h:62
DMA_MEM_TO_MEM
@ DMA_MEM_TO_MEM
Definition: axi_dmac.h:91
axi_dmac_is_transfer_ready
int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy)
Definition: axi_dmac.c:268
axi_dmac_init::base
uint32_t base
Definition: axi_dmac.h:131
AXI_DMAC_REG_X_LENGTH
#define AXI_DMAC_REG_X_LENGTH
Definition: axi_dmac.h:73
axi_dmac::transfer
volatile struct axi_dma_transfer transfer
Definition: axi_dmac.h:121
axi_dmac::max_length
uint32_t max_length
Definition: axi_dmac.h:120
axi_dmac::direction
enum dma_direction direction
Definition: axi_dmac.h:118
axi_dmac_mem_to_dev_isr
void axi_dmac_mem_to_dev_isr(void *instance)
Definition: axi_dmac.c:111
axi_dmac_transfer_start
int32_t axi_dmac_transfer_start(struct axi_dmac *dmac, struct axi_dma_transfer *dma_transfer)
Definition: axi_dmac.c:378
axi_dmac_init
Definition: axi_dmac.h:129
axi_dmac::next_dest_addr
uint32_t next_dest_addr
Definition: axi_dmac.h:126
axi_dmac_init::name
const char * name
Definition: axi_dmac.h:130
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:72
DMA_PARTIAL_REPORTING_EN
@ DMA_PARTIAL_REPORTING_EN
Definition: axi_dmac.h:97
axi_dmac_transfer_wait_completion
int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac, uint32_t timeout_ms)
Definition: axi_dmac.c:506
axi_dma_transfer::transfer_done
volatile bool transfer_done
Definition: axi_dmac.h:108
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:249
axi_dmac_transfer_stop
void axi_dmac_transfer_stop(struct axi_dmac *dmac)
Definition: axi_dmac.c:544
no_os_axi_io.h
Header file of AXI IO.
axi_dmac_mem_to_dev_isr
void axi_dmac_mem_to_dev_isr(void *instance)
Definition: axi_dmac.c:111
AXI_DMAC_REG_SRC_STRIDE
#define AXI_DMAC_REG_SRC_STRIDE
Definition: axi_dmac.h:76
axi_dmac::next_src_addr
uint32_t next_src_addr
Definition: axi_dmac.h:125
AXI_DMAC_QUEUE_FULL
#define AXI_DMAC_QUEUE_FULL
Definition: axi_dmac.h:69
axi_dmac_remove
int32_t axi_dmac_remove(struct axi_dmac *dmac)
Definition: axi_dmac.c:360
DMA_MEM_TO_DEV
@ DMA_MEM_TO_DEV
Definition: axi_dmac.h:90
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: delay.c:130
axi_dma_transfer
Definition: axi_dmac.h:106
no_os_error.h
Error codes definition.
use_irq
use_irq
Definition: axi_dmac.h:82
axi_dmac_transfer_wait_completion
int32_t axi_dmac_transfer_wait_completion(struct axi_dmac *dmac, uint32_t timeout_ms)
Definition: axi_dmac.c:506
IRQ_DISABLED
@ IRQ_DISABLED
Definition: axi_dmac.h:83
axi_dmac_read
int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t *reg_data)
Definition: axi_dmac.c:231
AXI_DMAC_REG_IRQ_PENDING
#define AXI_DMAC_REG_IRQ_PENDING
Definition: axi_dmac.h:52
AXI_DMAC_REG_TRANSFER_SUBMIT
#define AXI_DMAC_REG_TRANSFER_SUBMIT
Definition: axi_dmac.h:67
AXI_DMAC_CTRL_DISABLE
#define AXI_DMAC_CTRL_DISABLE
Definition: axi_dmac.h:63
IRQ_ENABLED
@ IRQ_ENABLED
Definition: axi_dmac.h:84
axi_dmac_init
int32_t axi_dmac_init(struct axi_dmac **adc_core, const struct axi_dmac_init *init)
Definition: axi_dmac.c:331
dma_direction
dma_direction
Definition: axi_dmac.h:87
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:51
axi_dma_transfer::src_addr
uint32_t src_addr
Definition: axi_dmac.h:110
dma_flags
dma_flags
Definition: axi_dmac.h:94
axi_dma_transfer::dest_addr
uint32_t dest_addr
Definition: axi_dmac.h:111
AXI_DMAC_IRQ_EOT
#define AXI_DMAC_IRQ_EOT
Definition: axi_dmac.h:54
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: axi_io.c:59
cyclic_transfer
cyclic_transfer
Definition: axi_dmac.h:101
axi_dmac_remove
int32_t axi_dmac_remove(struct axi_dmac *dmac)
Definition: axi_dmac.c:360
AXI_DMAC_IRQ_SOT
#define AXI_DMAC_IRQ_SOT
Definition: axi_dmac.h:53
axi_dmac_init::irq_option
enum use_irq irq_option
Definition: axi_dmac.h:132
axi_dmac_dev_to_mem_isr
void axi_dmac_dev_to_mem_isr(void *instance)
Definition: axi_dmac.c:60
axi_dma_transfer::cyclic
enum cyclic_transfer cyclic
Definition: axi_dmac.h:109
axi_dmac_is_transfer_ready
int32_t axi_dmac_is_transfer_ready(struct axi_dmac *dmac, bool *rdy)
Definition: axi_dmac.c:268
axi_dmac_write
int32_t axi_dmac_write(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t reg_data)
Definition: axi_dmac.c:249
AXI_DMAC_TRANSFER_SUBMIT
#define AXI_DMAC_TRANSFER_SUBMIT
Definition: axi_dmac.h:68
AXI_DMAC_REG_DEST_ADDRESS
#define AXI_DMAC_REG_DEST_ADDRESS
Definition: axi_dmac.h:71
axi_dmac_transfer_stop
void axi_dmac_transfer_stop(struct axi_dmac *dmac)
Definition: axi_dmac.c:544
AXI_DMAC_REG_FLAGS
#define AXI_DMAC_REG_FLAGS
Definition: axi_dmac.h:70
INVALID_DIR
@ INVALID_DIR
Definition: axi_dmac.h:88
NO
@ NO
Definition: axi_dmac.h:102
DMA_CYCLIC
@ DMA_CYCLIC
Definition: axi_dmac.h:95
axi_dmac_init
int32_t axi_dmac_init(struct axi_dmac **dmac_core, const struct axi_dmac_init *init)
Definition: axi_dmac.c:331
CYCLIC
@ CYCLIC
Definition: axi_dmac.h:103
axi_dmac_mem_to_mem_isr
void axi_dmac_mem_to_mem_isr(void *instance)
Definition: axi_dmac.c:168
axi_dmac::hw_cyclic
bool hw_cyclic
Definition: axi_dmac.h:119
axi_dmac::base
uint32_t base
Definition: axi_dmac.h:116
axi_dmac_dev_to_mem_isr
void axi_dmac_dev_to_mem_isr(void *instance)
Definition: axi_dmac.c:60
axi_dmac::init_addr
uint32_t init_addr
Definition: axi_dmac.h:123
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: axi_io.c:73
AXI_DMAC_REG_CTRL
#define AXI_DMAC_REG_CTRL
Definition: axi_dmac.h:61
axi_dmac_read
int32_t axi_dmac_read(struct axi_dmac *dmac, uint32_t reg_addr, uint32_t *reg_data)
Definition: axi_dmac.c:231
axi_dmac_transfer_start
int32_t axi_dmac_transfer_start(struct axi_dmac *dmac, struct axi_dma_transfer *dma_transfer)
Definition: axi_dmac.c:378
DMA_LAST
@ DMA_LAST
Definition: axi_dmac.h:96
no_os_util.h
Implementation of utility functions.
DMA_DEV_TO_MEM
@ DMA_DEV_TO_MEM
Definition: axi_dmac.h:89
AXI_DMAC_REG_DEST_STRIDE
#define AXI_DMAC_REG_DEST_STRIDE
Definition: axi_dmac.h:75
axi_dmac::remaining_size
uint32_t remaining_size
Definition: axi_dmac.h:124
axi_dma_transfer::size
uint32_t size
Definition: axi_dmac.h:107
AXI_DMAC_REG_Y_LENGTH
#define AXI_DMAC_REG_Y_LENGTH
Definition: axi_dmac.h:74
axi_dmac::irq_option
enum use_irq irq_option
Definition: axi_dmac.h:117
axi_dmac::name
const char * name
Definition: axi_dmac.h:115
axi_dmac
Definition: axi_dmac.h:114
axi_dmac_mem_to_mem_isr
void axi_dmac_mem_to_mem_isr(void *instance)
Definition: axi_dmac.c:168