hw/arm: zynqmp: Implement a CSU DMA model and connect it with GQSPI
Subsystems (2)
v4 cover hw/arm: zynqmp: Implement a CSU DMA model and connect it with GQSPI
From: Bin Meng <[email protected]>
ZynqMP QSPI supports SPI transfer using DMA mode, but currently this is unimplemented. When QSPI is programmed to use DMA mode, QEMU will crash. This is observed when testing VxWorks 7.
We added a Xilinx CSU DMA model and the implementation is based on
https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c
and the one in Edgar's branch.
Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
3. Make the values of int_enable and int_disable mutually exclusive otherwise IRQ cannot be delivered.
4. Clear int_status after int_disable is set.
5. Coding convention issues clean-up
The DST part of the model is verified along with ZynqMP GQSPI model.
Changes in v4:
- Add complete CSU DMA model based on Edgar's branch
- Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
3. Make the values of int_enable and int_disable mutually exclusive otherwise IRQ cannot be delivered.
4. Clear int_status after int_disable is set.
5. Coding convention issues clean-up
- remove one change that is not a checkpatch warning
- Rename "csu_dma" to "qspi_dma"
- Modify XLNX_ZYNQMP_SPIPS_R_MAX
Changes in v3:
- Implement DMA as a separate CSU DMA model
- new patch: xlnx-zynqmp: Add XLNX CSU DMA module
- new patch: xilinx_spips: Remove DMA related code from zynqmp_qspips
Changes in v2:
- Remove unconnected TYPE_STREAM_SINK link property
- Add a TYPE_MEMORY_REGION link property, to allow board codes to tell the device what its view of the world that it is doing DMA to is
- Replace cpu_physical_memory_write() with address_space_write()
Xuzhou Cheng (5):
hw/dma: xlnx_csu_dma: Implement a Xilinx CSU DMA model hw/arm: xlnx-zynqmp: Clean up coding convention issues hw/arm: xlnx-zynqmp: Connect a Xilinx CSU DMA module for QSPI hw/ssi: xilinx_spips: Clean up coding convention issues hw/ssi: xilinx_spips: Remove DMA related dead codes from zynqmp_spips
include/hw/arm/xlnx-zynqmp.h | 5 +- include/hw/dma/xlnx_csu_dma.h | 52 +++ include/hw/ssi/xilinx_spips.h | 2 +- hw/arm/xlnx-zynqmp.c | 23 +- hw/dma/xlnx_csu_dma.c | 747 ++++++++++++++++++++++++++++++++++ hw/ssi/xilinx_spips.c | 33 +- hw/arm/Kconfig | 1 + hw/dma/Kconfig | 4 + hw/dma/meson.build | 1 + 9 files changed, 844 insertions(+), 24 deletions(-) create mode 100644 include/hw/dma/xlnx_csu_dma.h create mode 100644 hw/dma/xlnx_csu_dma.c
Signature · 1 line
2.25.1
PATCH v4 1/5 hw/dma: xlnx_csu_dma: Implement a Xilinx CSU DMA model
From: Xuzhou Cheng <[email protected]>
ZynqMP QSPI supports SPI transfer using DMA mode, but currently this is unimplemented. When QSPI is programmed to use DMA mode, QEMU will crash. This is observed when testing VxWorks 7.
This adds a Xilinx CSU DMA model and the implementation is based on
https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c.
The DST part of the model is verified along with ZynqMP GQSPI model.
---
Changes in v4:
- Add complete CSU DMA model based on Edgar's branch
- Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
3. Make the values of int_enable and int_disable mutually exclusive otherwise IRQ cannot be delivered.
4. Clear int_status after int_disable is set.
5. Coding convention issues clean-up
Changes in v3:
- Implement DMA as a separate CSU DMA model
Changes in v2:
- Remove unconnected TYPE_STREAM_SINK link property
- Add a TYPE_MEMORY_REGION link property, to allow board codes to tell the device what its view of the world that it is doing DMA to is
- Replace cpu_physical_memory_write() with address_space_write()
include/hw/dma/xlnx_csu_dma.h | 52 +++ hw/dma/xlnx_csu_dma.c | 747 ++++++++++++++++++++++++++++++++++ hw/dma/Kconfig | 4 + hw/dma/meson.build | 1 + 4 files changed, 804 insertions(+) create mode 100644 include/hw/dma/xlnx_csu_dma.h create mode 100644 hw/dma/xlnx_csu_dma.c
include/hw/dma/xlnx_csu_dma.h new file +52 -0
@@ -0,0 +1,52 @@ +/* +* Xilinx Platform CSU Stream DMA emulation +* +* This implementation is based on +* https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 or +* (at your option) version 3 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef XLNX_CSU_DMA_H +#define XLNX_CSU_DMA_H + +#define TYPE_XLNX_CSU_DMA "xlnx.csu_dma" + +#define XLNX_CSU_DMA_R_MAX (0x2c / 4) + +typedef struct XlnxCSUDMA { +SysBusDevice busdev; +MemoryRegion iomem; +MemTxAttrs attr; +MemoryRegion *dma_mr; +AddressSpace *dma_as; +qemu_irq irq; +StreamSink *tx_dev;/* Used as generic StreamSink */ +ptimer_state *src_timer; + +uint16_t width; +bool is_dst; +bool r_size_last_word; + +StreamCanPushNotifyFn notify; +void *notify_opaque; + +uint32_t regs[XLNX_CSU_DMA_R_MAX ]; +RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX ]; +}XlnxCSUDMA ; + +#define XLNX_CSU_DMA (obj) \ + OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA) + +#endif
hw/dma/xlnx_csu_dma.c new file +747 -0
747 lines not on this page · raw message
hw/dma/Kconfig +4 -0
@@ -26,3 +26,7 @@ config STP2000 config SIFIVE_PDMA bool + +config XLNX_CSU_DMA + bool + select REGISTER
hw/dma/meson.build +1 -0
@@ -14,3 +14,4 @@ softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_dma.c', 'soc_dma.c')) softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_dma.c')) softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_dma.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_PDMA', if_true: files('sifive_pdma.c')) +softmmu_ss.add(when: 'CONFIG_XLNX_CSU_DMA', if_true: files('xlnx_csu_dma.c'))
Signature · 1 line
2.25.1
Re: [PATCH v4 1/5] hw/dma: xlnx_csu_dma: Implement a Xilinx CSU DMA model
Quoted 13 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
ZynqMP QSPI supports SPI transfer using DMA mode, but currently this is unimplemented. When QSPI is programmed to use DMA mode, QEMU will crash. This is observed when testing VxWorks 7.
This adds a Xilinx CSU DMA model and the implementation is based on
https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c.
The DST part of the model is verified along with ZynqMP GQSPI model.Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>
Quoted 8 lines
---
Changes in v4:
- Add complete CSU DMA model based on Edgar's branch
- Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
The relaxation of alignment is a new feature, not included on the ZynqMP but it will be included in future versions. Would be nice to keep it but we can also add it later since it's not really related to QSPI.
Quoted 2 lines
3. Make the values of
int_enableandint_disablemutually exclusive otherwise IRQ cannot be delivered.
This doesn't sound right. The enable and disable regs are stateless. They both indirectly modify the MASK register.
I.e, setting a bit in the enable register will clear the correspoding bit in the mask register, atomically, without the need for read-modify-write of MASK.
The disable register does the opposite.
Quoted 1 line
4. Clear
int_statusafterint_disableis set.
This doesn't sound right either. Status is a w1c register, i.e bits get set when the interrupt event happens in the DMA and bits only get cleared when SW writes a 1 to the STATUS reg to clear bits (write one to clear, w1c).
Other than the interrupt issues, I think this looks good.
Cheers,
Edgar
Re: [PATCH v4 1/5] hw/dma: xlnx_csu_dma: Implement a Xilinx CSU DMA model
Hi Edgar,
Quoted 24 lines · Edgar E. Iglesias
Quoted 13 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
ZynqMP QSPI supports SPI transfer using DMA mode, but currently this is unimplemented. When QSPI is programmed to use DMA mode, QEMU will crash. This is observed when testing VxWorks 7.
This adds a Xilinx CSU DMA model and the implementation is based on
https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c.
The DST part of the model is verified along with ZynqMP GQSPI model.Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>Quoted 8 lines
---
Changes in v4:
- Add complete CSU DMA model based on Edgar's branch
- Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
Quoted 3 lines
The relaxation of alignment is a new feature, not included on the ZynqMP but it will be included in future versions. Would be nice to keep it but we can also add it later since it's not really related to QSPI.
I think Xilinx folks can add the "byte-align" property in the future patches. Is this a new feature for Versal?
Quoted 12 lines
Quoted 3 lines
3. Make the values of
int_enableandint_disablemutually exclusive otherwise IRQ cannot be delivered.This doesn't sound right. The enable and disable regs are stateless. They both indirectly modify the MASK register.
I.e, setting a bit in the enable register will clear the correspoding bit in the mask register, atomically, without the need for read-modify-write of MASK.
The disable register does the opposite.
Quoted 7 lines
Quoted 1 line
4. Clear
int_statusafterint_disableis set.This doesn't sound right either. Status is a w1c register, i.e bits get set when the interrupt event happens in the DMA and bits only get cleared when SW writes a 1 to the STATUS reg to clear bits (write one to clear, w1c).
Other than the interrupt issues, I think this looks good.
Without these interrupt fixes, our tests cannot pass. We will have a further look at your comments.
Regards,
Bin
Re: [PATCH v4 1/5] hw/dma: xlnx_csu_dma: Implement a Xilinx CSU DMA model
Quoted 28 lines · Bin Meng
Hi Edgar,
Quoted 24 lines · Edgar E. Iglesias
Quoted 21 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
ZynqMP QSPI supports SPI transfer using DMA mode, but currently this is unimplemented. When QSPI is programmed to use DMA mode, QEMU will crash. This is observed when testing VxWorks 7.
This adds a Xilinx CSU DMA model and the implementation is based on
https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c.
The DST part of the model is verified along with ZynqMP GQSPI model.Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v4:
- Add complete CSU DMA model based on Edgar's branch
- Differences with Edgar's branch:
1. Match the registers' FIELD to UG1807.
2. Remove "byte-align" property. Per UG1807, SIZE and ADDR registers must be word aligned.
Quoted 6 lines
Quoted 3 lines
The relaxation of alignment is a new feature, not included on the ZynqMP but it will be included in future versions. Would be nice to keep it but we can also add it later since it's not really related to QSPI.
I think Xilinx folks can add the "byte-align" property in the future patches. Is this a new feature for Versal?
It's not in silicon yet, yeah, we can add it later.
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
3. Make the values of
int_enableandint_disablemutually exclusive otherwise IRQ cannot be delivered.This doesn't sound right. The enable and disable regs are stateless. They both indirectly modify the MASK register.
I.e, setting a bit in the enable register will clear the correspoding bit in the mask register, atomically, without the need for read-modify-write of MASK.
The disable register does the opposite.
Quoted 1 line
4. Clear
int_statusafterint_disableis set.
Quoted 8 lines
Quoted 5 lines
This doesn't sound right either. Status is a w1c register, i.e bits get set when the interrupt event happens in the DMA and bits only get cleared when SW writes a 1 to the STATUS reg to clear bits (write one to clear, w1c).
Other than the interrupt issues, I think this looks good.
Without these interrupt fixes, our tests cannot pass. We will have a further look at your comments.
This is a common interrupt handling pattern in most Xilinx devices. You can look at the xlnx-zdma.c IMR, ISR, IEN, IDS regs as an example.
Cheers,
Edgar
PATCH v4 2/5 hw/arm: xlnx-zynqmp: Clean up coding convention issues
In reply to Bin MengFrom: Xuzhou Cheng <[email protected]>
There are some coding convention warnings in xlnx-zynqmp.c and xlnx-zynqmp.h, as reported by:
$ ./scripts/checkpatch.pl include/hw/arm/xlnx-zynqmp.h $ ./scripts/checkpatch.pl hw/arm/xlnx-zynqmp.c
Let's clean them up.
---
Changes in v4:
- remove one change that is not a checkpatch warning
include/hw/arm/xlnx-zynqmp.h | 3 ++- hw/arm/xlnx-zynqmp.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
include/hw/arm/xlnx-zynqmp.h +2 -1
@@ -60,7 +60,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP)#define XLNX_ZYNQMP_GIC_REGIONS 6 -/* ZynqMP maps the ARM GIC regions (GICC, GICD ...) at consecutive 64k offsets +/* +* ZynqMP maps the ARM GIC regions (GICC, GICD ...) at consecutive 64k offsets * and under-decodes the 64k region. This mirrors the 4k regions to every 4k * aligned address in the 64k region. To implement each GIC region needs a * number of memory region aliases.
hw/arm/xlnx-zynqmp.c +6 -3
@@ -301,11 +301,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) ram_size =memory_region_size (s->ddr_ram); -/* Create the DDR Memory Regions. User friendly checks should happen at +/* +* Create the DDR Memory Regions. User friendly checks should happen at * the board level */ if (ram_size >XLNX_ZYNQMP_MAX_LOW_RAM_SIZE ) { -/* The RAM size is above the maximum available for the low DDR. +/* +* The RAM size is above the maximum available for the low DDR. * Create the high DDR memory region as well. */ assert (ram_size <=XLNX_ZYNQMP_MAX_RAM_SIZE );
@@ -526,7 +528,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (&s->sdhci[i]);Object *sdhci =OBJECT (&s->sdhci[i]); -/* Compatible with: +/* +* Compatible with: * - SD Host Controller Specification Version 3.00 * - SDIO Specification Version 3.0 * - eMMC Specification Version 4.51
Signature · 1 line
2.25.1
Re: [PATCH v4 2/5] hw/arm: xlnx-zynqmp: Clean up coding convention issues
Quoted 5 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
There are some coding convention warnings in
xlnx-zynqmp.candxlnx-zynqmp.h, as reported by:
Quoted 7 lines
$ ./scripts/checkpatch.pl include/hw/arm/xlnx-zynqmp.h $ ./scripts/checkpatch.pl hw/arm/xlnx-zynqmp.cLet's clean them up.
Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>
Quoted 57 lines
---
Changes in v4:
- remove one change that is not a checkpatch warninginclude/hw/arm/xlnx-zynqmp.h | 3 ++- hw/arm/xlnx-zynqmp.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)include/hw/arm/xlnx-zynqmp.h +2
-1@@ -60,7 +60,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP)#define XLNX_ZYNQMP_GIC_REGIONS 6 -/* ZynqMP maps the ARM GIC regions (GICC, GICD ...) at consecutive 64k offsets +/* +* ZynqMP maps the ARM GIC regions (GICC, GICD ...) at consecutive 64k offsets * and under-decodes the 64k region. This mirrors the 4k regions to every 4k * aligned address in the 64k region. To implement each GIC region needs a * number of memory region aliases. hw/arm/xlnx-zynqmp.c +6
-3@@ -301,11 +301,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) ram_size =memory_region_size (s->ddr_ram); -/* Create the DDR Memory Regions. User friendly checks should happen at +/* +* Create the DDR Memory Regions. User friendly checks should happen at * the board level */ if (ram_size >XLNX_ZYNQMP_MAX_LOW_RAM_SIZE ) { -/* The RAM size is above the maximum available for the low DDR. +/* +* The RAM size is above the maximum available for the low DDR. * Create the high DDR memory region as well. */ assert (ram_size <=XLNX_ZYNQMP_MAX_RAM_SIZE );@@ -526,7 +528,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (&s->sdhci[i]);Object *sdhci =OBJECT (&s->sdhci[i]); -/* Compatible with: +/* +* Compatible with: * - SD Host Controller Specification Version 3.00 * - SDIO Specification Version 3.0 * - eMMC Specification Version 4.51 Signature · 1 line
2.25.1
PATCH v4 3/5 hw/arm: xlnx-zynqmp: Connect a Xilinx CSU DMA module for QSPI
In reply to Bin MengFrom: Xuzhou Cheng <[email protected]>
Add a Xilinx CSU DMA module to ZynqMP SoC, and connent the stream link of GQSPI to CSU DMA.
---
Changes in v4:
- Rename "csu_dma" to "qspi_dma"
Changes in v3:
- new patch: xlnx-zynqmp: Add XLNX CSU DMA module
include/hw/arm/xlnx-zynqmp.h | 2 ++ hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++ hw/arm/Kconfig | 1 + 3 files changed, 17 insertions(+)
include/hw/arm/xlnx-zynqmp.h +2 -0
@@ -35,6 +35,7 @@#include "target/arm/cpu.h" #include "qom/object.h" #include "net/can_emu.h" +#include "hw/dma/xlnx_csu_dma.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )
@@ -108,6 +109,7 @@ struct XlnxZynqMPState {XlnxZynqMPRTC rtc;XlnxZDMA gdma[XLNX_ZYNQMP_NUM_GDMA_CH ];XlnxZDMA adma[XLNX_ZYNQMP_NUM_ADMA_CH ]; +XlnxCSUDMA qspi_dma;char *boot_cpu;ARMCPU *boot_cpu_ptr;
hw/arm/xlnx-zynqmp.c +14 -0
@@ -50,6 +50,7 @@#define QSPI_ADDR 0xff0f0000#define LQSPI_ADDR 0xc0000000#define QSPI_IRQ 15 +#define QSPI_DMA_ADDR 0xff0f0800#define DP_ADDR 0xfd4a0000#define DP_IRQ 113
@@ -63,6 +64,8 @@#define RTC_ADDR 0xffa60000#define RTC_IRQ 26 + +#define SDHCI_CAPABILITIES 0x280737ec6481/* Datasheet: UG1085 (v1.7) */ static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS ] = {
@@ -284,6 +287,8 @@ static void xlnx_zynqmp_init(Object *obj)for (i =0 ; i <XLNX_ZYNQMP_NUM_ADMA_CH ; i++) {object_initialize_child (obj,"adma[*]" , &s->adma[i],TYPE_XLNX_ZDMA ); } + +object_initialize_child (obj,"qspi-dma" , &s->qspi_dma,TYPE_XLNX_CSU_DMA ); }static void xlnx_zynqmp_realize (DeviceState *dev,Error **errp)
@@ -643,6 +648,15 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adma[i]),0 , gic_spi[adma_ch_intr[i]]); } + +if (!sysbus_realize (SYS_BUS_DEVICE (&s->qspi_dma), errp)) { +return ; + } + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi_dma),0 ,QSPI_DMA_ADDR ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->qspi_dma),0 , gic_spi[QSPI_IRQ ]); +object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , +OBJECT (&s->qspi_dma), errp); }static Property xlnx_zynqmp_props[] = {
hw/arm/Kconfig +1 -0
@@ -353,6 +353,7 @@ config XLNX_ZYNQMP_ARM select SSI_M25P80 select XILINX_AXI select XILINX_SPIPS + select XLNX_CSU_DMA select XLNX_ZYNQMP select XLNX_ZDMA
Signature · 1 line
2.25.1
Re: [PATCH v4 3/5] hw/arm: xlnx-zynqmp: Connect a Xilinx CSU DMA module for QSPI
Quoted 54 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
Add a Xilinx CSU DMA module to ZynqMP SoC, and connent the stream link of GQSPI to CSU DMA.
Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v4:
- Rename "csu_dma" to "qspi_dma"Changes in v3:
- new patch: xlnx-zynqmp: Add XLNX CSU DMA moduleinclude/hw/arm/xlnx-zynqmp.h | 2 ++ hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++ hw/arm/Kconfig | 1 + 3 files changed, 17 insertions(+)include/hw/arm/xlnx-zynqmp.h +2
-0@@ -35,6 +35,7 @@#include "target/arm/cpu.h" #include "qom/object.h" #include "net/can_emu.h" +#include "hw/dma/xlnx_csu_dma.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )@@ -108,6 +109,7 @@ struct XlnxZynqMPState {XlnxZynqMPRTC rtc;XlnxZDMA gdma[XLNX_ZYNQMP_NUM_GDMA_CH ];XlnxZDMA adma[XLNX_ZYNQMP_NUM_ADMA_CH ]; +XlnxCSUDMA qspi_dma;char *boot_cpu;ARMCPU *boot_cpu_ptr;hw/arm/xlnx-zynqmp.c +1
-0@@ -50,6 +50,7 @@#define QSPI_ADDR 0xff0f0000#define LQSPI_ADDR 0xc0000000#define QSPI_IRQ 15 +#define QSPI_DMA_ADDR 0xff0f0800#define DP_ADDR 0xfd4a0000#define DP_IRQ 113
hw/arm/xlnx-zynqmp.c line 68
Quoted 5 lines
hw/arm/xlnx-zynqmp.c +2
-0@@ -63,6 +64,8 @@#define RTC_ADDR 0xffa60000#define RTC_IRQ 26 + +
These blank lines look un-related, if you remove them, this looks good to me:
Quoted 43 lines
hw/arm/xlnx-zynqmp.c +11
-0#define SDHCI_CAPABILITIES 0x280737ec6481/* Datasheet: UG1085 (v1.7) */ static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS ] = {@@ -284,6 +287,8 @@ static void xlnx_zynqmp_init(Object *obj)for (i =0 ; i <XLNX_ZYNQMP_NUM_ADMA_CH ; i++) {object_initialize_child (obj,"adma[*]" , &s->adma[i],TYPE_XLNX_ZDMA ); } + +object_initialize_child (obj,"qspi-dma" , &s->qspi_dma,TYPE_XLNX_CSU_DMA ); }static void xlnx_zynqmp_realize (DeviceState *dev,Error **errp)@@ -643,6 +648,15 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adma[i]),0 , gic_spi[adma_ch_intr[i]]); } + +if (!sysbus_realize (SYS_BUS_DEVICE (&s->qspi_dma), errp)) { +return ; + } + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi_dma),0 ,QSPI_DMA_ADDR ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->qspi_dma),0 , gic_spi[QSPI_IRQ ]); +object_property_set_link (OBJECT (&s->qspi),"stream-connected-dma" , +OBJECT (&s->qspi_dma), errp); }static Property xlnx_zynqmp_props[] = {hw/arm/Kconfig +1
-0@@ -353,6 +353,7 @@ config XLNX_ZYNQMP_ARM select SSI_M25P80 select XILINX_AXI select XILINX_SPIPS + select XLNX_CSU_DMA select XLNX_ZYNQMP select XLNX_ZDMASignature · 1 line
2.25.1
Re: [PATCH v4 3/5] hw/arm: xlnx-zynqmp: Connect a Xilinx CSU DMA module for QSPI
Hi Edgar,
Quoted 59 lines · Edgar E. Iglesias
Quoted 57 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
Add a Xilinx CSU DMA module to ZynqMP SoC, and connent the stream link of GQSPI to CSU DMA.
Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v4:
- Rename "csu_dma" to "qspi_dma"Changes in v3:
- new patch: xlnx-zynqmp: Add XLNX CSU DMA moduleinclude/hw/arm/xlnx-zynqmp.h | 2 ++ hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++ hw/arm/Kconfig | 1 + 3 files changed, 17 insertions(+)include/hw/arm/xlnx-zynqmp.h +2
-0@@ -35,6 +35,7 @@#include "target/arm/cpu.h" #include "qom/object.h" #include "net/can_emu.h" +#include "hw/dma/xlnx_csu_dma.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )@@ -108,6 +109,7 @@ struct XlnxZynqMPState {XlnxZynqMPRTC rtc;XlnxZDMA gdma[XLNX_ZYNQMP_NUM_GDMA_CH ];XlnxZDMA adma[XLNX_ZYNQMP_NUM_ADMA_CH ]; +XlnxCSUDMA qspi_dma;char *boot_cpu;ARMCPU *boot_cpu_ptr;hw/arm/xlnx-zynqmp.c +1
-0@@ -50,6 +50,7 @@#define QSPI_ADDR 0xff0f0000#define LQSPI_ADDR 0xc0000000#define QSPI_IRQ 15 +#define QSPI_DMA_ADDR 0xff0f0800#define DP_ADDR 0xfd4a0000#define DP_IRQ 113@@ -63,6 +64,8 @@#define RTC_ADDR 0xffa60000#define RTC_IRQ 26
Quoted 6 lines
hw/arm/xlnx-zynqmp.c line 68
Quoted 2 lines
hw/arm/xlnx-zynqmp.c +2
-0+ +These blank lines look un-related, if you remove them, this looks good to me:
Reviewed-by Edgar E. Iglesias <[email protected]>
Thanks for the review.
A RESEND version was already sent out to the ML before. Sorry for the inconvenience.
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/
Regards,
Bin
Re: [PATCH v4 3/5] hw/arm: xlnx-zynqmp: Connect a Xilinx CSU DMA module for QSPI
Quoted 68 lines · Bin Meng
Hi Edgar,
Quoted 64 lines · Edgar E. Iglesias
Quoted 54 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
Add a Xilinx CSU DMA module to ZynqMP SoC, and connent the stream link of GQSPI to CSU DMA.
Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>---
Changes in v4:
- Rename "csu_dma" to "qspi_dma"Changes in v3:
- new patch: xlnx-zynqmp: Add XLNX CSU DMA moduleinclude/hw/arm/xlnx-zynqmp.h | 2 ++ hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++ hw/arm/Kconfig | 1 + 3 files changed, 17 insertions(+)include/hw/arm/xlnx-zynqmp.h +2
-0@@ -35,6 +35,7 @@#include "target/arm/cpu.h" #include "qom/object.h" #include "net/can_emu.h" +#include "hw/dma/xlnx_csu_dma.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )@@ -108,6 +109,7 @@ struct XlnxZynqMPState {XlnxZynqMPRTC rtc;XlnxZDMA gdma[XLNX_ZYNQMP_NUM_GDMA_CH ];XlnxZDMA adma[XLNX_ZYNQMP_NUM_ADMA_CH ]; +XlnxCSUDMA qspi_dma;char *boot_cpu;ARMCPU *boot_cpu_ptr;hw/arm/xlnx-zynqmp.c +1
-0@@ -50,6 +50,7 @@#define QSPI_ADDR 0xff0f0000#define LQSPI_ADDR 0xc0000000#define QSPI_IRQ 15 +#define QSPI_DMA_ADDR 0xff0f0800#define DP_ADDR 0xfd4a0000#define DP_IRQ 113hw/arm/xlnx-zynqmp.c line 68
Quoted 5 lines
hw/arm/xlnx-zynqmp.c +2
-0@@ -63,6 +64,8 @@#define RTC_ADDR 0xffa60000#define RTC_IRQ 26 + +These blank lines look un-related, if you remove them, this looks good to me:
Quoted 8 lines
Quoted 1 line
Reviewed-by Edgar E. Iglesias <[email protected]>Thanks for the review.
A RESEND version was already sent out to the ML before. Sorry for the inconvenience.
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/
Ah I see, no worries!
Cheers,
Edgar
PATCH v4 4/5 hw/ssi: xilinx_spips: Clean up coding convention issues
In reply to Bin MengFrom: Xuzhou Cheng <[email protected]>
There are some coding convention warnings in xilinx_spips.c, as reported by:
$ ./scripts/checkpatch.pl hw/ssi/xilinx_spips.c
Let's clean them up.
---
(no changes since v1)
hw/ssi/xilinx_spips.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
hw/ssi/xilinx_spips.c +14 -9
@@ -176,7 +176,8 @@ FIELD(GQSPI_FIFO_CTRL, GENERIC_FIFO_RESET, 0, 1)#define R_GQSPI_GFIFO_THRESH (0x150 / 4)#define R_GQSPI_DATA_STS (0x15c / 4) -/* We use the snapshot register to hold the core state for the currently +/* +* We use the snapshot register to hold the core state for the currently * or most recently executed command. So the generic fifo format is defined * for the snapshot register */
@@ -424,7 +425,8 @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d)xlnx_zynqmp_qspips_update_ixr (s); } -/* N way (num) in place bit striper. Lay out row wise bits (MSB to LSB) +/* +* N way (num) in place bit striper. Lay out row wise bits (MSB to LSB) * column wise (from element 0 to N-1). num is the length of x, and dir * reverses the direction of the transform. Best illustrated by example: * Each digit in the below array is a single bit (num == 3):
@@ -637,8 +639,10 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s) tx_rx[i] = tx; } }else { -/* Extract a dummy byte and generate dummy cycles according to the -* link state */ +/* +* Extract a dummy byte and generate dummy cycles according to the +* link state +*/ tx =fifo8_pop (&s->tx_fifo); dummy_cycles =8 / s->link_state; }
@@ -721,8 +725,9 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s) }break ;case (SNOOP_ADDR ): -/* Address has been transmitted, transmit dummy cycles now if -* needed */ +/* +* Address has been transmitted, transmit dummy cycles now if needed +*/ if (s->cmd_dummies <0 ) { s->snoop_state =SNOOP_NONE ; }else {
@@ -876,7 +881,7 @@ static void xlnx_zynqmp_qspips_notify(void *opaque) }static uint64_t xilinx_spips_read (void *opaque,hwaddr addr, -unsigned size) +unsigned size) {XilinxSPIPS *s = opaque;uint32_t mask = ~0 ;
@@ -970,7 +975,7 @@ static uint64_t xlnx_zynqmp_qspips_read(void *opaque, }static void xilinx_spips_write (void *opaque,hwaddr addr, -uint64_t value,unsigned size) +uint64_t value,unsigned size) {int mask = ~0 ;XilinxSPIPS *s = opaque;
@@ -1072,7 +1077,7 @@ static void xilinx_qspips_write(void *opaque, hwaddr addr, }static void xlnx_zynqmp_qspips_write (void *opaque,hwaddr addr, -uint64_t value,unsigned size) +uint64_t value,unsigned size) {XlnxZynqMPQSPIPS *s =XLNX_ZYNQMP_QSPIPS (opaque);uint32_t reg = addr /4 ;
Signature · 1 line
2.25.1
PATCH v4 5/5 hw/ssi: xilinx_spips: Remove DMA related dead codes from zynqmp_spips
In reply to Bin MengFrom: Xuzhou Cheng <[email protected]>
Now that the Xilinx CSU DMA model is implemented, the existing DMA related dead codes in the ZynqMP QSPI are useless and should be removed. The maximum register number is also updated to only include the QSPI registers.
---
Changes in v4:
- Modify XLNX_ZYNQMP_SPIPS_R_MAX
Changes in v3:
- new patch: xilinx_spips: Remove DMA related code from zynqmp_qspips
include/hw/ssi/xilinx_spips.h | 2 +- hw/ssi/xilinx_spips.c | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-)
include/hw/ssi/xilinx_spips.h +1 -1
@@ -34,7 +34,7 @@typedef struct XilinxSPIPS XilinxSPIPS ;#define XLNX_SPIPS_R_MAX (0x100 / 4) -#define XLNX_ZYNQMP_SPIPS_R_MAX (0x830 / 4) +#define XLNX_ZYNQMP_SPIPS_R_MAX (0x200 / 4)/* Bite off 4k chunks at a time */ #define LQSPI_CACHE_SIZE 1024
hw/ssi/xilinx_spips.c +0 -10
@@ -195,13 +195,6 @@#define R_GQSPI_MOD_ID (0x1fc / 4)#define R_GQSPI_MOD_ID_RESET (0x10a0000) -#define R_QSPIDMA_DST_CTRL (0x80c / 4) -#define R_QSPIDMA_DST_CTRL_RESET (0x803ffa00) -#define R_QSPIDMA_DST_I_MASK (0x820 / 4) -#define R_QSPIDMA_DST_I_MASK_RESET (0xfe) -#define R_QSPIDMA_DST_CTRL2 (0x824 / 4) -#define R_QSPIDMA_DST_CTRL2_RESET (0x081bfff8) -/* size of TXRX FIFOs */ #define RXFF_A (128)#define TXFF_A (128)
@@ -417,9 +410,6 @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) s->regs[R_GQSPI_GPIO ] =1 ; s->regs[R_GQSPI_LPBK_DLY_ADJ ] =R_GQSPI_LPBK_DLY_ADJ_RESET ; s->regs[R_GQSPI_MOD_ID ] =R_GQSPI_MOD_ID_RESET ; - s->regs[R_QSPIDMA_DST_CTRL ] =R_QSPIDMA_DST_CTRL_RESET ; - s->regs[R_QSPIDMA_DST_I_MASK ] =R_QSPIDMA_DST_I_MASK_RESET ; - s->regs[R_QSPIDMA_DST_CTRL2 ] =R_QSPIDMA_DST_CTRL2_RESET ; s->man_start_com_g = false; s->gqspi_irqline =0 ;xlnx_zynqmp_qspips_update_ixr (s);
Signature · 1 line
2.25.1
Re: [PATCH v4 5/5] hw/ssi: xilinx_spips: Remove DMA related dead codes from zynqmp_spips
Quoted 9 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
Now that the Xilinx CSU DMA model is implemented, the existing DMA related dead codes in the ZynqMP QSPI are useless and should be removed. The maximum register number is also updated to only include the QSPI registers.
Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>
Quoted 57 lines
---
Changes in v4:
- ModifyXLNX_ZYNQMP_SPIPS_R_MAXChanges in v3:
- new patch:xilinx_spips: Remove DMA related code fromzynqmp_qspipsinclude/hw/ssi/xilinx_spips.h | 2 +- hw/ssi/xilinx_spips.c | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-)include/hw/ssi/xilinx_spips.h +1
-1@@ -34,7 +34,7 @@typedef struct XilinxSPIPS XilinxSPIPS ;#define XLNX_SPIPS_R_MAX (0x100 / 4) -#define XLNX_ZYNQMP_SPIPS_R_MAX (0x830 / 4) +#define XLNX_ZYNQMP_SPIPS_R_MAX (0x200 / 4)/* Bite off 4k chunks at a time */ #define LQSPI_CACHE_SIZE 1024hw/ssi/xilinx_spips.c +0
-10@@ -195,13 +195,6 @@#define R_GQSPI_MOD_ID (0x1fc / 4)#define R_GQSPI_MOD_ID_RESET (0x10a0000) -#define R_QSPIDMA_DST_CTRL (0x80c / 4) -#define R_QSPIDMA_DST_CTRL_RESET (0x803ffa00) -#define R_QSPIDMA_DST_I_MASK (0x820 / 4) -#define R_QSPIDMA_DST_I_MASK_RESET (0xfe) -#define R_QSPIDMA_DST_CTRL2 (0x824 / 4) -#define R_QSPIDMA_DST_CTRL2_RESET (0x081bfff8) -/* size of TXRX FIFOs */ #define RXFF_A (128)#define TXFF_A (128)@@ -417,9 +410,6 @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) s->regs[R_GQSPI_GPIO ] =1 ; s->regs[R_GQSPI_LPBK_DLY_ADJ ] =R_GQSPI_LPBK_DLY_ADJ_RESET ; s->regs[R_GQSPI_MOD_ID ] =R_GQSPI_MOD_ID_RESET ; - s->regs[R_QSPIDMA_DST_CTRL ] =R_QSPIDMA_DST_CTRL_RESET ; - s->regs[R_QSPIDMA_DST_I_MASK ] =R_QSPIDMA_DST_I_MASK_RESET ; - s->regs[R_QSPIDMA_DST_CTRL2 ] =R_QSPIDMA_DST_CTRL2_RESET ; s->man_start_com_g = false; s->gqspi_irqline =0 ;xlnx_zynqmp_qspips_update_ixr (s);Signature · 1 line
2.25.1