aboutsummaryrefslogtreecommitdiff
path: root/hw/dma/xlnx-zdma.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/dma/xlnx-zdma.c')
-rw-r--r--hw/dma/xlnx-zdma.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
index 2d9c0a0d5e..1c45367f3c 100644
--- a/hw/dma/xlnx-zdma.c
+++ b/hw/dma/xlnx-zdma.c
@@ -333,10 +333,28 @@ static void zdma_load_src_descriptor(XlnxZDMA *s)
}
}
+static void zdma_update_descr_addr(XlnxZDMA *s, bool type,
+ unsigned int basereg)
+{
+ uint64_t addr, next;
+
+ if (type == DTYPE_LINEAR) {
+ addr = zdma_get_regaddr64(s, basereg);
+ next = addr + sizeof(s->dsc_dst);
+ } else {
+ addr = zdma_get_regaddr64(s, basereg);
+ addr += sizeof(s->dsc_dst);
+ address_space_read(s->dma_as, addr, s->attr, (void *) &next, 8);
+ }
+
+ zdma_put_regaddr64(s, basereg, next);
+}
+
static void zdma_load_dst_descriptor(XlnxZDMA *s)
{
uint64_t dst_addr;
unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, POINT_TYPE);
+ bool dst_type;
if (ptype == PT_REG) {
memcpy(&s->dsc_dst, &s->regs[R_ZDMA_CH_DST_DSCR_WORD0],
@@ -349,24 +367,10 @@ static void zdma_load_dst_descriptor(XlnxZDMA *s)
if (!zdma_load_descriptor(s, dst_addr, &s->dsc_dst)) {
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, AXI_RD_DST_DSCR, true);
}
-}
-
-static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,
- unsigned int basereg)
-{
- uint64_t addr, next;
- if (type == DTYPE_LINEAR) {
- next = zdma_get_regaddr64(s, basereg);
- next += sizeof(s->dsc_dst);
- zdma_put_regaddr64(s, basereg, next);
- } else {
- addr = zdma_get_regaddr64(s, basereg);
- addr += sizeof(s->dsc_dst);
- address_space_read(s->dma_as, addr, s->attr, &next, 8);
- zdma_put_regaddr64(s, basereg, next);
- }
- return next;
+ /* Advance the descriptor pointer. */
+ dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3, TYPE);
+ zdma_update_descr_addr(s, dst_type, R_ZDMA_CH_DST_CUR_DSCR_LSB);
}
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)
dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
SIZE);
if (dst_size == 0 && ptype == PT_MEM) {
- uint64_t next;
- bool dst_type = FIELD_EX32(s->dsc_dst.words[3],
- ZDMA_CH_DST_DSCR_WORD3,
- TYPE);
-
- next = zdma_update_descr_addr(s, dst_type,
- R_ZDMA_CH_DST_CUR_DSCR_LSB);
- zdma_load_descriptor(s, next, &s->dsc_dst);
+ zdma_load_dst_descriptor(s);
dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
SIZE);
}
@@ -511,16 +508,15 @@ static void zdma_process_descr(XlnxZDMA *s)
zdma_src_done(s);
}
- /* Load next descriptor. */
if (ptype == PT_REG || src_cmd == CMD_STOP) {
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_CTRL2, EN, 0);
zdma_set_state(s, DISABLED);
- return;
}
if (src_cmd == CMD_HALT) {
zdma_set_state(s, PAUSED);
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, DMA_PAUSE, 1);
+ ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, DMA_DONE, false);
zdma_ch_imr_update_irq(s);
return;
}
@@ -681,6 +677,12 @@ static RegisterAccessInfo zdma_regs_info[] = {
},{ .name = "ZDMA_CH_DBG0", .addr = A_ZDMA_CH_DBG0,
.rsvd = 0xfffffe00,
.ro = 0x1ff,
+
+ /*
+ * There's SW out there that will check the debug regs for free space.
+ * Claim that we always have 0x100 free.
+ */
+ .reset = 0x100
},{ .name = "ZDMA_CH_DBG1", .addr = A_ZDMA_CH_DBG1,
.rsvd = 0xfffffe00,
.ro = 0x1ff,