Skip to content

Commit 761d7d8

Browse files
author
Riccardo Gandolfi
committed
Updated drivers for iDMA
1 parent 3b88bca commit 761d7d8

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

include/hal/dma/idma_v2.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,23 @@ static inline int pulp_cl_idma_L1ToL2_2d(unsigned int src, unsigned int dst, uns
253253
static inline int pulp_idma_L2ToL1_2d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps);
254254
static inline int pulp_cl_idma_L2ToL1_2d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps);
255255

256+
/** Intra-cluster memory 2-dimensional transfer with event-based completion.
257+
*
258+
\param src Address in the cluster memory where to store the data. There is no restriction on memory alignment.
259+
\param dst Address in the cluster memory where to load the data. There is no restriction on memory alignment.
260+
\param size Number of bytes to be transfered. The only restriction is that this size must fit 16 bits, i.e. must be inferior to 65536.
261+
\param src_stride 2D stride, which is the number of bytes which are added to the beginning of the current line to switch to the next one. Must fit 16 bits, i.e. must be inferior to 65536.
262+
\param dst_stride 2D stride, which is the number of bytes which are added to the beginning of the current line to switch to the next one. Must fit 16 bits, i.e. must be inferior to 65536.
263+
\param num_reps Number of 1D transfers that comprise the 2D transfer.
264+
265+
\return The identifier of the transfer. This can be used with plp_dma_wait to wait for the completion of this transfer.
266+
*/
267+
268+
static inline int pulp_idma_L1ToL1_2d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps);
269+
static inline int pulp_idma_cl_L1ToL1_2d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps);
270+
271+
272+
256273
/** Cluster memory to external memory 3-dimensional transfer with event-based completion.
257274
*
258275
\param src Address in the external memory where to store the data. There is no restriction on memory alignment.
@@ -290,6 +307,22 @@ static inline int pulp_cl_idma_L2ToL1_2d(unsigned int src, unsigned int dst, uns
290307
static inline int pulp_idma_L2ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d);
291308
static inline int pulp_cl_idma_L2ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d);
292309

310+
/** Intra-cluster memory 3-dimensional transfer with event-based completion.
311+
*
312+
\param src Address in the external memory where to store the data. There is no restriction on memory alignment.
313+
\param dst Address in the cluster memory where to load the data. There is no restriction on memory alignment.
314+
\param size Number of bytes to be transfered. The only restriction is that this size must fit 16 bits, i.e. must be inferior to 65536.
315+
\param src_stride 2D stride, which is the number of bytes which are added to the beginning of the current line to switch to the next one. Must fit 16 bits, i.e. must be inferior to 65536.
316+
\param dst_stride 2D stride, which is the number of bytes which are added to the beginning of the current line to switch to the next one. Must fit 16 bits, i.e. must be inferior to 65536.
317+
\param num_reps Number of 1D transfers that comprise the 2D transfer.
318+
\param src_stride_3d Stride between 2D pages in the source memory.
319+
\param dst_stride_3d Stride between 2D pages in the destination memory.
320+
\param num_reps_3d Number of 2D pages to be transfered.
321+
322+
\return The identifier of the transfer. This can be used with plp_dma_wait to wait for the completion of this transfer.
323+
*/
324+
325+
static inline int pulp_idma_L1ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps_2d, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d);
293326
static inline int pulp_cl_idma_L1ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps_2d, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d);
294327

295328

@@ -308,17 +341,36 @@ static inline int pulp_cl_idma_zeromem(unsigned int dst, unsigned short size, id
308341

309342
/** DMA barrier.
310343
* This blocks the core until no transfer is on-going in the DMA.
344+
* Careful: these only wait for transfers towards L2
311345
*/
312346
static inline void plp_dma_barrier();
313347
static inline void plp_cl_dma_barrier();
314348

349+
/** DMA barrier.
350+
* This blocks the core until no transfer is on-going in the DMA.
351+
* Careful: these only wait for transfers towards L1
352+
*/
353+
354+
static inline void plp_dma_barrier_toL1();
355+
static inline void plp_cl_dma_barrier_toL1();
356+
357+
/** DMA barrier.
358+
* This blocks the core until no transfer is on-going in the DMA.
359+
* Careful: these only wait for transfers towards L2
360+
*/
361+
362+
static inline void plp_dma_barrier_toL2();
363+
static inline void plp_cl_dma_barrier_toL2();
364+
315365
/** DMA wait.
316366
* This blocks the core until the specified transfer is finished.
317367
*
318368
\param counter The counter ID identifying the transfer. This has been returned from an enqueued transfer (e.g. plp_dma_l2ToL1_2d)
319369
*/
320370
static inline void plp_dma_wait(unsigned int dma_tx_id);
321371
static inline void plp_cl_dma_wait(unsigned int dma_tx_id);
372+
static inline void plp_cl_dma_wait_toL1(unsigned int dma_tx_id);
373+
static inline void plp_cl_dma_wait_toL2(unsigned int dma_tx_id);
322374
//!@}
323375

324376

@@ -409,6 +461,22 @@ static inline unsigned int pulp_cl_idma_tx_cplt(unsigned int dma_tx_id);
409461
static inline unsigned int plp_dma_status();
410462
static inline unsigned int plp_cl_dma_status();
411463

464+
/** Return the DMA status for a transfer towards L1 memory.
465+
*
466+
\return DMA status. 1 means there are still on-going transfers, 0 means nothing is on-going.
467+
*/
468+
469+
static inline unsigned int plp_dma_status_toL1();
470+
static inline unsigned int plp_cl_dma_status_toL1();
471+
472+
/** Return the DMA status for a transfer towards L2 memory.
473+
*
474+
\return DMA status. 1 means there are still on-going transfers, 0 means nothing is on-going.
475+
*/
476+
477+
static inline unsigned int plp_dma_status_toL2();
478+
static inline unsigned int plp_cl_dma_status_toL2();
479+
412480

413481
//!@}
414482

@@ -581,10 +649,26 @@ static inline unsigned int plp_dma_status() {
581649
return DMA_READ(IDMA_REG32_3D_STATUS_0_REG_OFFSET);
582650
}
583651

652+
static inline unsigned int plp_dma_status_toL1() {
653+
return DMA_READ(IDMA_REG32_3D_STATUS_1_REG_OFFSET);
654+
}
655+
656+
static inline unsigned int plp_dma_status_toL2() {
657+
return DMA_READ(IDMA_REG32_3D_STATUS_0_REG_OFFSET);
658+
}
659+
584660
static inline unsigned int plp_cl_dma_status() {
585661
return DMA_CL_READ(IDMA_REG32_3D_STATUS_0_REG_OFFSET);
586662
}
587663

664+
static inline unsigned int plp_cl_dma_status_toL1() {
665+
return DMA_CL_READ(IDMA_REG32_3D_STATUS_1_REG_OFFSET);
666+
}
667+
668+
static inline unsigned int plp_cl_dma_status_toL2() {
669+
return DMA_CL_READ(IDMA_REG32_3D_STATUS_0_REG_OFFSET);
670+
}
671+
588672
static inline void plp_dma_wait(unsigned int dma_tx_id) {
589673
while(!pulp_idma_tx_cplt(dma_tx_id)) {
590674
eu_evt_maskWaitAndClr(1 << IDMA_EVENT);
@@ -944,6 +1028,25 @@ static inline int pulp_cl_idma_L2ToL1_3d(unsigned int src, unsigned int dst, uns
9441028
return dma_tx_id;
9451029
}
9461030

1031+
static inline int pulp_idma_L1ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps_2d, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d) {
1032+
unsigned int dma_tx_id;
1033+
unsigned int cfg = IDMA_DEFAULT_CONFIG_L1TOL1_3D;
1034+
DMA_WRITE(src, IDMA_REG32_3D_SRC_ADDR_LOW_REG_OFFSET);
1035+
DMA_WRITE(dst, IDMA_REG32_3D_DST_ADDR_LOW_REG_OFFSET);
1036+
DMA_WRITE(size, IDMA_REG32_3D_LENGTH_LOW_REG_OFFSET);
1037+
DMA_WRITE(cfg, IDMA_REG32_3D_CONF_REG_OFFSET);
1038+
DMA_WRITE(src_stride, IDMA_REG32_3D_SRC_STRIDE_2_LOW_REG_OFFSET);
1039+
DMA_WRITE(dst_stride, IDMA_REG32_3D_DST_STRIDE_2_LOW_REG_OFFSET);
1040+
DMA_WRITE(src_stride_3d, IDMA_REG32_3D_SRC_STRIDE_3_LOW_REG_OFFSET);
1041+
DMA_WRITE(dst_stride_3d, IDMA_REG32_3D_DST_STRIDE_3_LOW_REG_OFFSET);
1042+
DMA_WRITE(num_reps_2d, IDMA_REG32_3D_REPS_2_LOW_REG_OFFSET);
1043+
DMA_WRITE(num_reps_3d, IDMA_REG32_3D_REPS_3_LOW_REG_OFFSET);
1044+
1045+
asm volatile("" : : : "memory");
1046+
dma_tx_id = DMA_READ(IDMA_REG32_3D_NEXT_ID_1_REG_OFFSET);
1047+
return dma_tx_id;
1048+
}
1049+
9471050
static inline int pulp_cl_idma_L1ToL1_3d(unsigned int src, unsigned int dst, unsigned short size, unsigned int src_stride, unsigned int dst_stride, unsigned int num_reps_2d, unsigned int src_stride_3d, unsigned int dst_stride_3d, unsigned int num_reps_3d) {
9481051
unsigned int dma_tx_id;
9491052
unsigned int cfg = IDMA_DEFAULT_CONFIG_L1TOL1_3D;
@@ -1005,4 +1108,26 @@ static inline void plp_cl_dma_barrier() {
10051108
}
10061109
}
10071110

1111+
static inline void plp_dma_barrier_toL1() {
1112+
while(plp_dma_status_toL1()) {
1113+
eu_evt_maskWaitAndClr(1 << IDMA_EVENT);
1114+
}
1115+
}
1116+
static inline void plp_cl_dma_barrier_toL1() {
1117+
while(plp_cl_dma_status_toL1()) {
1118+
eu_evt_maskWaitAndClr(1 << IDMA_EVENT);
1119+
}
1120+
}
1121+
1122+
static inline void plp_dma_barrier_toL2() {
1123+
while(plp_dma_status_toL2()) {
1124+
eu_evt_maskWaitAndClr(1 << IDMA_EVENT);
1125+
}
1126+
}
1127+
static inline void plp_cl_dma_barrier_toL2() {
1128+
while(plp_cl_dma_status_toL2()) {
1129+
eu_evt_maskWaitAndClr(1 << IDMA_EVENT);
1130+
}
1131+
}
1132+
10081133
#endif // __HAL_IDMA_V1_H__

0 commit comments

Comments
 (0)