boards: arm: QEMU target for Cortex-A9 simulation

The qemu_cortex_a9 target simulates the Xilinx Zynq-7000
in a single core configuration with 512 MB of RAM. Supported
peripherals are the Zynq's two UARTs, of which one is activated
for console use, and the two Ethernet controllers, of which
GEM0 can be linked to the local zeth interface.

This target uses Xilinx' fork of QEMU, which is already being
used by the qemu_cortex_r5 target. Although being labelled
'arm64', this version of QEMU is also capable of emulating the
Zynq-7000 based on a binary device tree file. While regular
QEMU provides a Zynq-based machine, this implementation is
buggy and/or incomplete.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@weidmueller.com>
diff --git a/boards/arm/qemu_cortex_a9/Kconfig.board b/boards/arm/qemu_cortex_a9/Kconfig.board
new file mode 100644
index 0000000..c9b0568
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/Kconfig.board
@@ -0,0 +1,11 @@
+#
+# Kconfig - Cortex-A9 QEMU Emulation
+#
+# Copyright (c) 2021, Weidmueller Interface GmbH & Co. KG
+# SPDX-License-Identifier: Apache-2.0
+#
+
+config BOARD_QEMU_CORTEX_A9
+	bool "Cortex-A9 Emulation (QEMU)"
+	depends on SOC_XILINX_ZYNQ7000
+	select QEMU_TARGET
diff --git a/boards/arm/qemu_cortex_a9/Kconfig.defconfig b/boards/arm/qemu_cortex_a9/Kconfig.defconfig
new file mode 100644
index 0000000..9430bb6
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/Kconfig.defconfig
@@ -0,0 +1,99 @@
+#
+# Kconfig - Cortex-A9 (Zynq-7000) QEMU Emulation
+#
+# Copyright (c) 2021, Weidmueller Interface GmbH & Co. KG
+# SPDX-License-Identifier: Apache-2.0
+#
+
+if BOARD_QEMU_CORTEX_A9
+
+config BUILD_OUTPUT_BIN
+	default n
+
+config BOARD
+	default "qemu_cortex_a9"
+
+config SYS_CLOCK_HW_CYCLES_PER_SEC
+	int
+	default 100000000
+
+config SYS_CLOCK_TICKS_PER_SEC
+	default 100
+
+if CONSOLE
+
+	config UART_CONSOLE
+	default y
+
+endif # CONSOLE
+
+if LOG
+
+	if LOG_PROCESS_THREAD
+
+		config LOG_PROCESS_THREAD_STACK_SIZE
+		default 8192
+
+	endif # LOG_PROCESS_THREAD
+
+endif # LOG
+
+if NETWORKING
+
+	config NET_L2_ETHERNET
+	default y
+
+	config NET_TX_STACK_SIZE
+	default 8192
+
+	config NET_RX_STACK_SIZE
+	default 8192
+
+	if NET_TCP
+
+		config NET_TCP_WORKQ_STACK_SIZE
+		default 8192
+
+	endif # NET_TCP
+
+	if NET_MGMT_EVENT
+
+		config NET_MGMT_EVENT_STACK_SIZE
+		default 8192
+
+	endif # NET_MGMT_EVENT
+
+	config TEST_RANDOM_GENERATOR
+	default y
+
+endif # NETWORKING
+
+if QEMU_ICOUNT
+
+	config QEMU_ICOUNT_SHIFT
+	default 3
+
+endif # QEMU_ICOUNT
+
+if SERIAL
+
+	config UART_XLNX_PS
+	default y
+
+endif # SERIAL
+
+if SHELL
+
+	config SHELL_STACK_SIZE
+	default 8192
+
+endif # SHELL
+
+if UART_PIPE
+
+	config UART_PIPE_ON_DEV_NAME
+	default "uart1"
+
+endif # UART_PIPE
+
+endif # BOARD_QEMU_CORTEX_A9
diff --git a/boards/arm/qemu_cortex_a9/board.cmake b/boards/arm/qemu_cortex_a9/board.cmake
new file mode 100644
index 0000000..5c25bc8
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/board.cmake
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2021, Weidmueller Interface GmbH & Co. KG
+# SPDX-License-Identifier: Apache-2.0
+#
+
+set(EMU_PLATFORM qemu)
+set(QEMU_ARCH xilinx-aarch64)
+
+set(QEMU_CPU_TYPE_${ARCH} cortex-a9)
+
+set(QEMU_FLAGS_${ARCH}
+  -nographic
+  -machine arm-generic-fdt-7series
+  -dtb ${ZEPHYR_BASE}/boards/${ARCH}/${BOARD}/fdt-zynq7000s.dtb
+  )
+
+set(QEMU_KERNEL_OPTION
+  "-device;loader,file=\$<TARGET_FILE:\${logical_target_for_zephyr_elf}>,cpu-num=0"
+  )
+
+board_set_debugger_ifnset(qemu)
diff --git a/boards/arm/qemu_cortex_a9/fdt-zynq7000s.dtb b/boards/arm/qemu_cortex_a9/fdt-zynq7000s.dtb
new file mode 100644
index 0000000..ded5b73
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/fdt-zynq7000s.dtb
Binary files differ
diff --git a/boards/arm/qemu_cortex_a9/qemu_cortex_a9.dts b/boards/arm/qemu_cortex_a9/qemu_cortex_a9.dts
new file mode 100644
index 0000000..2792d06
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/qemu_cortex_a9.dts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2021 Weidmueller Interface GmbH & Co. KG
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/dts-v1/;
+
+#include <xilinx/zynq7000.dtsi>
+#include <dt-bindings/ethernet/xlnx_gem.h>
+
+/ {
+	model = "QEMU Cortex-A9";
+	compatible = "xlnx,zynq7000";
+	interrupt-parent = <&gic>;
+
+	sram0: memory@100000 {
+		compatible = "mmio-sram";
+		reg = <0x00100000 DT_SIZE_M(512)>;
+	};
+
+	flash0: flash@0 {
+		reg = <0x00000000 DT_SIZE_M(256)>;
+	};
+
+	chosen {
+		zephyr,flash      = &flash0;
+		zephyr,sram       = &sram0;
+		zephyr,console    = &uart0;
+		zephyr,shell-uart = &uart0;
+		zephyr,ocm        = &ocm_low;
+	};
+};
+
+&uart0 {
+	status = "okay";
+	current-speed = <115200>;
+	clock-frequency = <50000000>;
+};
+
+&uart1 {
+	status = "okay";
+	current-speed = <115200>;
+	clock-frequency = <50000000>;
+};
+
+&gem0 {
+	status = "okay";
+	clock-frequency = <1000000000>;
+	mdc-divider = <XLNX_GEM_MDC_DIVIDER_224>;
+	local-mac-address = [00 00 00 01 02 03];
+};
diff --git a/boards/arm/qemu_cortex_a9/qemu_cortex_a9.yaml b/boards/arm/qemu_cortex_a9/qemu_cortex_a9.yaml
new file mode 100644
index 0000000..e896b27
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/qemu_cortex_a9.yaml
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2018, Diego Sueiro
+# Copyright (c) 2021, Weidmueller Interface GmbH & Co. KG
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+identifier: qemu_cortex_a9
+name: QEMU Emulation for Cortex-A9
+type: qemu
+simulation: qemu
+arch: arm
+toolchain:
+  - zephyr
+  - gnuarmemb
+  - xtools
+supported:
+  - net
+  - netif:eth
+ram: 524288
+flash: 262144
+testing:
+  default: true
+  ignore_tags:
+    - bluetooth
+    - gpio
diff --git a/boards/arm/qemu_cortex_a9/qemu_cortex_a9_defconfig b/boards/arm/qemu_cortex_a9/qemu_cortex_a9_defconfig
new file mode 100644
index 0000000..925c59a
--- /dev/null
+++ b/boards/arm/qemu_cortex_a9/qemu_cortex_a9_defconfig
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2021, Weidmueller Interface GmbH & Co. KG
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+CONFIG_SOC_SERIES_XILINX_ZYNQ7000=y
+CONFIG_SOC_XILINX_ZYNQ7000=y
+CONFIG_BOARD_QEMU_CORTEX_A9=y
+
+CONFIG_ARM_ARCH_TIMER=y
+
+CONFIG_SERIAL=y
+CONFIG_CONSOLE=y
+
+CONFIG_ARMV7_EXCEPTION_STACK_SIZE=8192
+CONFIG_ARMV7_FIQ_STACK_SIZE=8192
+CONFIG_ARMV7_SVC_STACK_SIZE=8192
+CONFIG_ARMV7_SYS_STACK_SIZE=8192
+CONFIG_IDLE_STACK_SIZE=8192
+CONFIG_ISR_STACK_SIZE=8192
+CONFIG_MAIN_STACK_SIZE=8192
+CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192