Introduce Xilinx ZynqMP CAN controller
v6 cover Introduce Xilinx ZynqMP CAN controller
Changelog:
v5 -> v6:
Add ptimer based counter for time stamping on RX messages. Fix reset issues.
Rebase the patches with master latest changes. Added reference clock property for CAN ptimer.
v4 -> v5:
Add XlnxZynqMPCAN controller id to debug messages. Drop parameter errp of object_property_add(). Add formatting related suggestions.
v3 -> v4:
Correct formatting issues.
v2 -> v3:
Rectify the build issue.
Rearrange the patch order.
v1 -> v2:
Rename the CAN device state and address code style issues. Connect the CAN device to Xlnx-ZCU102 board.
Add maintainer entry.
Add QTEST for the CAN device.
Vikram Garhwal (4):
hw/net/can: Introduce Xilinx ZynqMP CAN controller
xlnx-zynqmp: Connect Xilinx ZynqMP CAN controllers tests/qtest: Introduce tests for Xilinx ZynqMP CAN controller
MAINTAINERS: Add maintainer entry for Xilinx ZynqMP CAN controller
MAINTAINERS | 8 + hw/arm/xlnx-zynqmp.c | 28 + hw/net/can/Makefile.objs | 1 + hw/net/can/xlnx-zynqmp-can.c | 1163 ++++++++++++++++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 4 + include/hw/net/xlnx-zynqmp-can.h | 79 +++ tests/qtest/Makefile.include | 2 + tests/qtest/xlnx-can-test.c | 367 ++++++++++++ 8 files changed, 1652 insertions(+) create mode 100644 hw/net/can/xlnx-zynqmp-can.c create mode 100644 include/hw/net/xlnx-zynqmp-can.h create mode 100644 tests/qtest/xlnx-can-test.c
--
2.7.4
PATCH v6 1/4 hw/net/can: Introduce Xilinx ZynqMP CAN controller
The Xilinx ZynqMP CAN controller is developed based on SocketCAN, QEMU CAN bus implementation. Bus connection and socketCAN connection for each CAN module can be set through command lines.
Example for using single CAN:
-object can-bus,id=canbus0 \
-global driver=xlnx.zynqmp-can,property=canbus0,value=canbus0 \
-object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0Example for connecting both CAN to same virtual CAN on host machine:
-object can-bus,id=canbus0 -object can-bus,id=canbus1 \
-global driver=xlnx.zynqmp-can,property=canbus0,value=canbus0 \
-global driver=xlnx.zynqmp-can,property=canbus1,value=canbus1 \
-object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0 \
-object can-host-socketcan,id=socketcan1,if=vcan0,canbus=canbus1To create virtual CAN on the host machine, please check the QEMU CAN docs:
https://github.com/qemu/qemu/blob/master/docs/can.txt
--- hw/net/can/Makefile.objs | 1 + hw/net/can/xlnx-zynqmp-can.c | 1163 ++++++++++++++++++++++++++++++++++++++ include/hw/net/xlnx-zynqmp-can.h | 79 +++ 3 files changed, 1243 insertions(+) create mode 100644 hw/net/can/xlnx-zynqmp-can.c create mode 100644 include/hw/net/xlnx-zynqmp-can.h
hw/net/can/Makefile.objs +1 -0
@@ -2,3 +2,4 @@ common-obj-$(CONFIG_CAN_SJA1000) += can_sja1000.o common-obj-$(CONFIG_CAN_PCI) += can_kvaser_pci.o common-obj-$(CONFIG_CAN_PCI) += can_pcm3680_pci.o common-obj-$(CONFIG_CAN_PCI) += can_mioe3680_pci.o +common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-can.o
hw/net/can/xlnx-zynqmp-can.c new file +1163 -0
1,163 lines not on this page · raw message
include/hw/net/xlnx-zynqmp-can.h new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 2/4 xlnx-zynqmp: Connect Xilinx ZynqMP CAN controllers
In reply to Vikram GarhwalConnect CAN0 and CAN1 on the ZynqMP.
--- hw/arm/xlnx-zynqmp.c | 28 ++++++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 4 ++++ 2 files changed, 32 insertions(+)
hw/arm/xlnx-zynqmp.c +28 -0
@@ -81,6 +81,14 @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = { 21, 22, }; +static const uint64_t can_addr[XLNX_ZYNQMP_NUM_CAN ] = { +0xFF060000 ,0xFF070000 , +}; + +static const int can_intr[XLNX_ZYNQMP_NUM_CAN ] = { +23 ,24 , +}; +static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI ] = {0xFF160000 ,0xFF170000 , };
@@ -247,6 +255,11 @@ static void xlnx_zynqmp_init(Object *obj) TYPE_CADENCE_UART); } +for (i =0 ; i <XLNX_ZYNQMP_NUM_CAN ; i++) { +object_initialize_child (obj,"can[*]" , &s->can[i], +TYPE_XLNX_ZYNQMP_CAN ); + } +object_initialize_child (obj,"sata" , &s->sata,TYPE_SYSBUS_AHCI );for (i =0 ; i <XLNX_ZYNQMP_NUM_SDHCI ; i++) {
@@ -492,6 +505,21 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) gic_spi[uart_intr[i]]); } +for (i =0 ; i <XLNX_ZYNQMP_NUM_CAN ; i++) { +object_property_set_int (OBJECT (&s->can[i]), i,"ctrl-idx" , + &error_abort); +object_property_set_int (OBJECT (&s->can[i]),XLNX_ZYNQMP_CAN_REF_CLK , +"ext_clk_freq" , &error_abort); +sysbus_realize (SYS_BUS_DEVICE (&s->can[i]), &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->can[i]),0 , can_addr[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->can[i]),0 , + gic_spi[can_intr[i]]); + } +object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , &error_abort);sysbus_realize (SYS_BUS_DEVICE (&s->sata), &err);
include/hw/arm/xlnx-zynqmp.h +4 -0
@@ -22,6 +22,7 @@#include "hw/intc/arm_gic.h" #include "hw/net/cadence_gem.h" #include "hw/char/cadence_uart.h" +#include "hw/net/xlnx-zynqmp-can.h" #include "hw/ide/ahci.h" #include "hw/sd/sdhci.h" #include "hw/ssi/xilinx_spips.h"
@@ -41,6 +42,8 @@#define XLNX_ZYNQMP_NUM_RPU_CPUS 2#define XLNX_ZYNQMP_NUM_GEMS 4#define XLNX_ZYNQMP_NUM_UARTS 2 +#define XLNX_ZYNQMP_NUM_CAN 2 +#define XLNX_ZYNQMP_CAN_REF_CLK (24 * 1000 * 1000)#define XLNX_ZYNQMP_NUM_SDHCI 2#define XLNX_ZYNQMP_NUM_SPIS 2#define XLNX_ZYNQMP_NUM_GDMA_CH 8
@@ -92,6 +95,7 @@ typedef struct XlnxZynqMPState {CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS ];CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS ]; +XlnxZynqMPCANState can[XLNX_ZYNQMP_NUM_CAN ];SysbusAHCIState sata;SDHCIState sdhci[XLNX_ZYNQMP_NUM_SDHCI ];XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS ];
Signature · 1 line
2.7.4
Re: [PATCH v6 2/4] xlnx-zynqmp: Connect Xilinx ZynqMP CAN controllers
Quoted 4 lines · Vikram Garhwal
Connect CAN0 and CAN1 on the ZynqMP.
Signed-off-by Vikram Garhwal <[email protected]>
Alistair
Quoted 91 lines
--- hw/arm/xlnx-zynqmp.c | 28 ++++++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 4 ++++ 2 files changed, 32 insertions(+)hw/arm/xlnx-zynqmp.c +28
-0@@ -81,6 +81,14 @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = { 21, 22, }; +static const uint64_t can_addr[XLNX_ZYNQMP_NUM_CAN ] = { +0xFF060000 ,0xFF070000 , +}; + +static const int can_intr[XLNX_ZYNQMP_NUM_CAN ] = { +23 ,24 , +}; +static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI ] = {0xFF160000 ,0xFF170000 , };@@ -247,6 +255,11 @@ static void xlnx_zynqmp_init(Object *obj) TYPE_CADENCE_UART); } +for (i =0 ; i <XLNX_ZYNQMP_NUM_CAN ; i++) { +object_initialize_child (obj,"can[*]" , &s->can[i], +TYPE_XLNX_ZYNQMP_CAN ); + } +object_initialize_child (obj,"sata" , &s->sata,TYPE_SYSBUS_AHCI );for (i =0 ; i <XLNX_ZYNQMP_NUM_SDHCI ; i++) {@@ -492,6 +505,21 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) gic_spi[uart_intr[i]]); } +for (i =0 ; i <XLNX_ZYNQMP_NUM_CAN ; i++) { +object_property_set_int (OBJECT (&s->can[i]), i,"ctrl-idx" , + &error_abort); +object_property_set_int (OBJECT (&s->can[i]),XLNX_ZYNQMP_CAN_REF_CLK , +"ext_clk_freq" , &error_abort); +sysbus_realize (SYS_BUS_DEVICE (&s->can[i]), &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->can[i]),0 , can_addr[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->can[i]),0 , + gic_spi[can_intr[i]]); + } +object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , &error_abort);sysbus_realize (SYS_BUS_DEVICE (&s->sata), &err);include/hw/arm/xlnx-zynqmp.h +4
-1@@ -22,6 +22,7 @@#include "hw/intc/arm_gic.h" #include "hw/net/cadence_gem.h" #include "hw/char/cadence_uart.h" +#include "hw/net/xlnx-zynqmp-can.h" #include "hw/ide/ahci.h" #include "hw/sd/sdhci.h" #include "hw/ssi/xilinx_spips.h" @@ -41,6 +42,8 @@#define XLNX_ZYNQMP_NUM_RPU_CPUS 2#define XLNX_ZYNQMP_NUM_GEMS 4#define XLNX_ZYNQMP_NUM_UARTS 2 +#define XLNX_ZYNQMP_NUM_CAN 2 +#define XLNX_ZYNQMP_CAN_REF_CLK (24 * 1000 * 1000)#define XLNX_ZYNQMP_NUM_SDHCI 2#define XLNX_ZYNQMP_NUM_SPIS 2#define XLNX_ZYNQMP_NUM_GDMA_CH 8@@ -92,6 +95,7 @@ typedef struct XlnxZynqMPState {CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS ];CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS ]; +XlnxZynqMPCANState can[XLNX_ZYNQMP_NUM_CAN ];SysbusAHCIState sata;SDHCIState sdhci[XLNX_ZYNQMP_NUM_SDHCI ];XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS ]; --2.7.4
PATCH v6 3/4 tests/qtest: Introduce tests for Xilinx ZynqMP CAN controller
In reply to Vikram GarhwalThe QTests perform five tests on the Xilinx ZynqMP CAN controller:
Tests the CAN controller in loopback, sleep and snoop mode. Tests filtering of incoming CAN messages.
--- tests/qtest/Makefile.include | 2 + tests/qtest/xlnx-can-test.c | 367 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 tests/qtest/xlnx-can-test.c
tests/qtest/Makefile.include +2 -0
@@ -136,6 +136,7 @@ check-qtest-aarch64-$(CONFIG_TPM_TIS_SYSBUS) += tpm-tis-device-swtpm-test check-qtest-aarch64-y += numa-test check-qtest-aarch64-y += boot-serial-test check-qtest-aarch64-y += migration-test +check-qtest-aarch64-y += xlnx-can-test # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make test unconditional ifneq ($(ARCH),arm)
@@ -266,6 +267,7 @@ tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \ tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y) tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y) tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o +tests/qtest/xlnx-can-test$(EXESUF): tests/qtest/xlnx-can-test.o tests/qtest/m25p80-test$(EXESUF): tests/qtest/m25p80-test.o tests/qtest/i440fx-test$(EXESUF): tests/qtest/i440fx-test.o $(libqos-pc-obj-y) tests/qtest/q35-test$(EXESUF): tests/qtest/q35-test.o $(libqos-pc-obj-y)
tests/qtest/xlnx-can-test.c new file +367 -0
367 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 4/4 MAINTAINERS: Add maintainer entry for Xilinx ZynqMP CAN controller
In reply to Vikram Garhwal--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -1466,6 +1466,14 @@ F: hw/net/opencores_eth.c Devices ------- +Xilinx CAN +M: Vikram Garhwal <[email protected]> +M: Francisco Iglesias <[email protected]> +S: Maintained +F: hw/net/can/xlnx-* +F: include/hw/net/xlnx-* +F: tests/qtest/xlnx-can-test* + EDU M: Jiri Slaby <[email protected]> S: Maintained
Signature · 1 line
2.7.4
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
qemu-system-aarch64: cannot set up guest memory 'ddr-ram': Cannot allocate memory
Broken pipe/tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
ERROR - too few tests run (expected 5, got 0)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 060
TEST iotest-qcow2: 061
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=2808f6f9aaa94638acd0daee96cc5b87', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-40zn8u5e/src/docker-src.2020-06-23-19.47.28.30297:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=2808f6f9aaa94638acd0daee96cc5b87
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-40zn8u5e/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 14m21.964s
user 0m9.568s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]