@@ -333,10 +333,28 @@ static void zdma_load_src_descriptor(XlnxZDMA *s)
333
333
}
334
334
}
335
335
336
+ static void zdma_update_descr_addr (XlnxZDMA * s , bool type ,
337
+ unsigned int basereg )
338
+ {
339
+ uint64_t addr , next ;
340
+
341
+ if (type == DTYPE_LINEAR ) {
342
+ addr = zdma_get_regaddr64 (s , basereg );
343
+ next = addr + sizeof (s -> dsc_dst );
344
+ } else {
345
+ addr = zdma_get_regaddr64 (s , basereg );
346
+ addr += sizeof (s -> dsc_dst );
347
+ address_space_read (s -> dma_as , addr , s -> attr , (void * ) & next , 8 );
348
+ }
349
+
350
+ zdma_put_regaddr64 (s , basereg , next );
351
+ }
352
+
336
353
static void zdma_load_dst_descriptor (XlnxZDMA * s )
337
354
{
338
355
uint64_t dst_addr ;
339
356
unsigned int ptype = ARRAY_FIELD_EX32 (s -> regs , ZDMA_CH_CTRL0 , POINT_TYPE );
357
+ bool dst_type ;
340
358
341
359
if (ptype == PT_REG ) {
342
360
memcpy (& s -> dsc_dst , & s -> regs [R_ZDMA_CH_DST_DSCR_WORD0 ],
@@ -349,24 +367,10 @@ static void zdma_load_dst_descriptor(XlnxZDMA *s)
349
367
if (!zdma_load_descriptor (s , dst_addr , & s -> dsc_dst )) {
350
368
ARRAY_FIELD_DP32 (s -> regs , ZDMA_CH_ISR , AXI_RD_DST_DSCR , true);
351
369
}
352
- }
353
-
354
- static uint64_t zdma_update_descr_addr (XlnxZDMA * s , bool type ,
355
- unsigned int basereg )
356
- {
357
- uint64_t addr , next ;
358
370
359
- if (type == DTYPE_LINEAR ) {
360
- next = zdma_get_regaddr64 (s , basereg );
361
- next += sizeof (s -> dsc_dst );
362
- zdma_put_regaddr64 (s , basereg , next );
363
- } else {
364
- addr = zdma_get_regaddr64 (s , basereg );
365
- addr += sizeof (s -> dsc_dst );
366
- address_space_read (s -> dma_as , addr , s -> attr , & next , 8 );
367
- zdma_put_regaddr64 (s , basereg , next );
368
- }
369
- return next ;
371
+ /* Advance the descriptor pointer. */
372
+ dst_type = FIELD_EX32 (s -> dsc_dst .words [3 ], ZDMA_CH_DST_DSCR_WORD3 , TYPE );
373
+ zdma_update_descr_addr (s , dst_type , R_ZDMA_CH_DST_CUR_DSCR_LSB );
370
374
}
371
375
372
376
static void zdma_write_dst (XlnxZDMA * s , uint8_t * buf , uint32_t len )
@@ -387,14 +391,7 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
387
391
dst_size = FIELD_EX32 (s -> dsc_dst .words [2 ], ZDMA_CH_DST_DSCR_WORD2 ,
388
392
SIZE );
389
393
if (dst_size == 0 && ptype == PT_MEM ) {
390
- uint64_t next ;
391
- bool dst_type = FIELD_EX32 (s -> dsc_dst .words [3 ],
392
- ZDMA_CH_DST_DSCR_WORD3 ,
393
- TYPE );
394
-
395
- next = zdma_update_descr_addr (s , dst_type ,
396
- R_ZDMA_CH_DST_CUR_DSCR_LSB );
397
- zdma_load_descriptor (s , next , & s -> dsc_dst );
394
+ zdma_load_dst_descriptor (s );
398
395
dst_size = FIELD_EX32 (s -> dsc_dst .words [2 ], ZDMA_CH_DST_DSCR_WORD2 ,
399
396
SIZE );
400
397
}
@@ -511,16 +508,15 @@ static void zdma_process_descr(XlnxZDMA *s)
511
508
zdma_src_done (s );
512
509
}
513
510
514
- /* Load next descriptor. */
515
511
if (ptype == PT_REG || src_cmd == CMD_STOP ) {
516
512
ARRAY_FIELD_DP32 (s -> regs , ZDMA_CH_CTRL2 , EN , 0 );
517
513
zdma_set_state (s , DISABLED );
518
- return ;
519
514
}
520
515
521
516
if (src_cmd == CMD_HALT ) {
522
517
zdma_set_state (s , PAUSED );
523
518
ARRAY_FIELD_DP32 (s -> regs , ZDMA_CH_ISR , DMA_PAUSE , 1 );
519
+ ARRAY_FIELD_DP32 (s -> regs , ZDMA_CH_ISR , DMA_DONE , false);
524
520
zdma_ch_imr_update_irq (s );
525
521
return ;
526
522
}
@@ -681,6 +677,12 @@ static RegisterAccessInfo zdma_regs_info[] = {
681
677
},{ .name = "ZDMA_CH_DBG0" , .addr = A_ZDMA_CH_DBG0 ,
682
678
.rsvd = 0xfffffe00 ,
683
679
.ro = 0x1ff ,
680
+
681
+ /*
682
+ * There's SW out there that will check the debug regs for free space.
683
+ * Claim that we always have 0x100 free.
684
+ */
685
+ .reset = 0x100
684
686
},{ .name = "ZDMA_CH_DBG1" , .addr = A_ZDMA_CH_DBG1 ,
685
687
.rsvd = 0xfffffe00 ,
686
688
.ro = 0x1ff ,
0 commit comments