All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 09/32] hw/dma/xlnx_csu_dma: Support starting a read transfer through a class method
Date: Fri, 28 Jan 2022 15:29:46 +0000	[thread overview]
Message-ID: <20220128153009.2467560-10-peter.maydell@linaro.org> (raw)
In-Reply-To: <20220128153009.2467560-1-peter.maydell@linaro.org>

From: Francisco Iglesias <francisco.iglesias@xilinx.com>

An option on real hardware when embedding a DMA engine into a peripheral
is to make the peripheral control the engine through a custom DMA control
(hardware) interface between the two. Software drivers in this scenario
configure and trigger DMA operations through the controlling peripheral's
register API (for example, writing a specific bit in a register could
propagate down to a transfer start signal on the DMA control interface).
At the same time the status, results and interrupts for the transfer might
still be intended to be read and caught through the DMA engine's register
API (and signals).

This patch adds a class 'read' method for allowing to start read transfers
from peripherals embedding and controlling the Xilinx CSU DMA engine as in
above scenario.

Signed-off-by: Francisco Iglesias <francisco.iglesias@xilinx.com>
Reviewed-by: Luc Michel <luc@lmichel.fr>
Message-id: 20220121161141.14389-6-francisco.iglesias@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/dma/xlnx_csu_dma.h | 19 +++++++++++++++++--
 hw/dma/xlnx_csu_dma.c         | 17 +++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 28806628b10..922ab80eb61 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -51,7 +51,22 @@ typedef struct XlnxCSUDMA {
     RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX];
 } XlnxCSUDMA;
 
-#define XLNX_CSU_DMA(obj) \
-    OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA)
+OBJECT_DECLARE_TYPE(XlnxCSUDMA, XlnxCSUDMAClass, XLNX_CSU_DMA)
+
+struct XlnxCSUDMAClass {
+    SysBusDeviceClass parent_class;
+
+    /*
+     * read: Start a read transfer on a Xilinx CSU DMA engine
+     *
+     * @s: the Xilinx CSU DMA engine to start the transfer on
+     * @addr: the address to read
+     * @len: the number of bytes to read at 'addr'
+     *
+     * @return a MemTxResult indicating whether the operation succeeded ('len'
+     * bytes were read) or failed.
+     */
+    MemTxResult (*read)(XlnxCSUDMA *s, hwaddr addr, uint32_t len);
+};
 
 #endif
diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c
index 896bb3574dd..095f9544767 100644
--- a/hw/dma/xlnx_csu_dma.c
+++ b/hw/dma/xlnx_csu_dma.c
@@ -472,6 +472,20 @@ static uint64_t addr_msb_pre_write(RegisterInfo *reg, uint64_t val)
     return val & R_ADDR_MSB_ADDR_MSB_MASK;
 }
 
+static MemTxResult xlnx_csu_dma_class_read(XlnxCSUDMA *s, hwaddr addr,
+                                           uint32_t len)
+{
+    RegisterInfo *reg = &s->regs_info[R_SIZE];
+    uint64_t we = MAKE_64BIT_MASK(0, 4 * 8);
+
+    s->regs[R_ADDR] = addr;
+    s->regs[R_ADDR_MSB] = (uint64_t)addr >> 32;
+
+    register_write(reg, len, we, object_get_typename(OBJECT(s)), false);
+
+    return (s->regs[R_SIZE] == 0) ? MEMTX_OK : MEMTX_ERROR;
+}
+
 static const RegisterAccessInfo *xlnx_csu_dma_regs_info[] = {
 #define DMACH_REGINFO(NAME, snd)                                              \
     (const RegisterAccessInfo []) {                                           \
@@ -696,6 +710,7 @@ static void xlnx_csu_dma_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     StreamSinkClass *ssc = STREAM_SINK_CLASS(klass);
+    XlnxCSUDMAClass *xcdc = XLNX_CSU_DMA_CLASS(klass);
 
     dc->reset = xlnx_csu_dma_reset;
     dc->realize = xlnx_csu_dma_realize;
@@ -704,6 +719,8 @@ static void xlnx_csu_dma_class_init(ObjectClass *klass, void *data)
 
     ssc->push = xlnx_csu_dma_stream_push;
     ssc->can_push = xlnx_csu_dma_stream_can_push;
+
+    xcdc->read = xlnx_csu_dma_class_read;
 }
 
 static void xlnx_csu_dma_init(Object *obj)
-- 
2.25.1



  parent reply	other threads:[~2022-01-28 16:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 15:29 [PULL 00/32] target-arm queue Peter Maydell
2022-01-28 15:29 ` [PULL 01/32] Update copyright dates to 2022 Peter Maydell
2022-01-28 15:29 ` [PULL 02/32] hw/armv7m: Fix broken VMStateDescription Peter Maydell
2022-01-28 15:29 ` [PULL 03/32] hw/char/exynos4210_uart: Fix crash on trying to load VM state Peter Maydell
2022-01-28 15:29 ` [PULL 04/32] rtc: Move RTC function prototypes to their own header Peter Maydell
2022-01-28 15:29 ` [PULL 05/32] hw/misc: Add a model of Versal's PMC SLCR Peter Maydell
2022-01-28 15:29 ` [PULL 06/32] hw/arm/xlnx-versal: 'Or' the interrupts from the BBRAM and RTC models Peter Maydell
2022-01-28 15:29 ` [PULL 07/32] hw/arm/xlnx-versal: Connect Versal's PMC SLCR Peter Maydell
2022-01-28 15:29 ` [PULL 08/32] include/hw/dma/xlnx_csu_dma: Add in missing includes in the header Peter Maydell
2022-01-28 15:29 ` Peter Maydell [this message]
2022-01-28 15:29 ` [PULL 10/32] hw/ssi: Add a model of Xilinx Versal's OSPI flash memory controller Peter Maydell
2022-01-28 15:29 ` [PULL 11/32] hw/arm/xlnx-versal: Connect the OSPI flash memory controller model Peter Maydell
2022-01-28 15:29 ` [PULL 12/32] hw/block/m25p80: Add support for Micron Xccela flash mt35xu01g Peter Maydell
2022-01-28 15:29 ` [PULL 13/32] hw/arm/xlnx-versal-virt: Connect mt35xu01g flashes to the OSPI Peter Maydell
2022-01-28 15:29 ` [PULL 14/32] MAINTAINERS: Add an entry for Xilinx Versal OSPI Peter Maydell
2022-01-28 15:29 ` [PULL 15/32] MAINTAINERS: Remove myself (for raspi) Peter Maydell
2022-01-28 15:29 ` [PULL 16/32] scripts: Explain the difference between linux-headers and standard-headers Peter Maydell
2022-01-28 15:29 ` [PULL 17/32] target/arm: Log CPU index in 'Taking exception' log Peter Maydell
2022-01-28 15:29 ` [PULL 18/32] hw/intc/arm_gicv3_its: Add tracepoints Peter Maydell
2022-01-28 15:29 ` [PULL 19/32] hw/intc/arm_gicv3: Initialise dma_as in GIC, not ITS Peter Maydell
2022-01-28 15:29 ` [PULL 20/32] hw/intc/arm_gicv3_its: Don't clear GITS_CREADR when GITS_CTLR.ENABLED is set Peter Maydell
2022-01-28 15:29 ` [PULL 21/32] hw/intc/arm_gicv3_its: Don't clear GITS_CWRITER on writes to GITS_CBASER Peter Maydell
2022-01-28 15:29 ` [PULL 22/32] hw/intc/arm_gicv3: Honour GICD_CTLR.EnableGrp1NS for LPIs Peter Maydell
2022-01-28 15:30 ` [PULL 23/32] hw/intc/arm_gicv3_its: Sort ITS command list into numeric order Peter Maydell
2022-01-28 15:30 ` [PULL 24/32] hw/intc/arm_gicv3_redist: Remove unnecessary zero checks Peter Maydell
2022-01-28 15:30 ` [PULL 25/32] hw/intc/arm_gicv3: Set GICR_CTLR.CES if LPIs are supported Peter Maydell
2022-01-28 15:30 ` [PULL 26/32] hw/intc/arm_gicv3_its: Provide read accessor for translation_ops Peter Maydell
2022-01-28 15:30 ` [PULL 27/32] hw/intc/arm_gicv3_its: Make GITS_BASER<n> RAZ/WI for unimplemented registers Peter Maydell
2022-01-28 15:30 ` [PULL 28/32] hw/intc/arm_gicv3_its: Check table bounds against correct limit Peter Maydell
2022-01-28 15:30 ` [PULL 29/32] hw/intc/arm_gicv3_its: Implement MOVALL Peter Maydell
2022-01-28 15:30 ` [PULL 30/32] hw/intc/arm_gicv3_its: Implement MOVI Peter Maydell
2022-01-28 15:30 ` [PULL 31/32] hw/arm: ast2600: Fix address mapping of second SPI controller Peter Maydell
2022-01-28 15:30 ` [PULL 32/32] target/arm: Use correct entrypoint for SVC taken from Hyp to Hyp Peter Maydell
2022-01-29 15:55 ` [PULL 00/32] target-arm queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220128153009.2467560-10-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.