diff mbox series

[nanbield,5/5] arm-bsp/u-boot: corstone1000: enable virtio-net support for FVP

Message ID 20231123174711.2175145-6-emekcan.aras@arm.com
State New
Headers show
Series arm-bsp/corstone1000-fvp: Various FVP fixes and updates | expand

Commit Message

Emekcan Aras Nov. 23, 2023, 5:47 p.m. UTC
From: Emekcan Aras <emekcan.aras@arm.com>

Use Ethernet over VirtIO on FVP due to lan91c111 Ethernet driver support dropped from U-Boot.
This patch enables virtio-net device in u-boot to pass ACS tests related to
NIC and PXE. The current ethernet device still works in linux kernel and
corstone1000-mps3 Ethernet device is supported by u-boot, so no change is
required regarding existing Ethernet device.

Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
---
 .../u-boot/u-boot-corstone1000.inc            |  1 +
 ...rstone1000-enable-virtio-net-support.patch | 97 +++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-corstone1000-enable-virtio-net-support.patch
diff mbox series

Patch

diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
index 01a8683c..b6b7a04f 100644
--- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
@@ -49,6 +49,7 @@  SRC_URI:append = " \
     file://0039-enables-ondisk-capsule-update-feature.patch		  \
     file://0040-fix-runtime-capsule-update-flags-checks.patch		  \
     file://0041-scatter-gather-flag-workaround.patch			  \
+    file://0042-corstone1000-enable-virtio-net-support.patch		  \
     "
 
 do_configure:append(){
diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-corstone1000-enable-virtio-net-support.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-corstone1000-enable-virtio-net-support.patch
new file mode 100644
index 00000000..d94e26a5
--- /dev/null
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0042-corstone1000-enable-virtio-net-support.patch
@@ -0,0 +1,97 @@ 
+From 2ddd34b6838e836cf94a9da2f65cd01a21252846 Mon Sep 17 00:00:00 2001
+From: Emekcan Aras <emekcan.aras@arm.com>
+Date: Wed, 15 Nov 2023 16:04:06 +0000
+Subject: [PATCH] corstone1000: enable virtio-net support
+
+Adds virtio-net support in corstone1000-fvp.
+
+Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ arch/arm/dts/corstone1000-fvp.dts        |  6 ++++++
+ board/armltd/corstone1000/corstone1000.c | 24 +++++++++++++++++++++++-
+ configs/corstone1000_defconfig           |  2 ++
+ 3 files changed, 31 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
+index 26b0f1b3ce..8e54a40113 100644
+--- a/arch/arm/dts/corstone1000-fvp.dts
++++ b/arch/arm/dts/corstone1000-fvp.dts
+@@ -21,6 +21,12 @@
+ 		reg-io-width = <2>;
+ 	};
+ 
++	virtio: virtio-net@40400000 {
++		compatible = "virtio,mmio";
++		reg = <0x40400000 0x10000>;
++		interrupts = <145>;
++	};
++
+ 	vmmc_v3_3d: fixed_v3_3d {
+ 		compatible = "regulator-fixed";
+ 		regulator-name = "vmmc_supply";
+diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
+index e3c0e5bf50..ef74dc9032 100644
+--- a/board/armltd/corstone1000/corstone1000.c
++++ b/board/armltd/corstone1000/corstone1000.c
+@@ -18,6 +18,7 @@
+ #include <dm/platform_data/serial_pl01x.h>
+ #include <asm/armv8/mmu.h>
+ #include <asm/global_data.h>
++#include <generated/dt.h>
+ 
+ /* remove the DT nodes not needed in Linux */
+ DT_NON_COMPLIANT_PURGE_LIST(foo) = {
+@@ -101,6 +102,14 @@ static struct mm_region corstone1000_mem_map[] = {
+ 		.size = 0x80000000UL,
+ 		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ 			PTE_BLOCK_INNER_SHARE
++	}, {
++		/* ethernet */
++		.virt = 0x40400000UL,
++			.phys = 0x40400000UL,
++			.size = 0x00100000UL,
++			.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
++				PTE_BLOCK_NON_SHARE |
++				PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ 	}, {
+ 		/* List terminator */
+ 		0,
+@@ -150,10 +159,23 @@ void fwu_plat_get_bootidx(uint *boot_idx)
+ int board_late_init(void)
+ {
+ 	struct disk_partition part_info;
+-	struct udevice *dev, *bdev;
++	struct udevice *dev, *bdev,*virtio_bus, *virtio_child;;
+ 	struct nvmxip_plat *plat;
+ 	struct blk_desc *desc;
+ 	int ret;
++	const char *cmp_dtb = DEVICE_TREE;
++
++	if (!strcmp(cmp_dtb, "corstone1000-fvp")) {
++		ret = uclass_first_device_err(UCLASS_VIRTIO, &virtio_bus);
++		if (!virtio_bus){
++			log_err("Cannot find virtio device\n");
++			return ret;
++		}
++		while (virtio_bus) {
++			device_foreach_child_probe(virtio_child, virtio_bus);
++			uclass_next_device(&virtio_bus);
++		}
++	}
+ 
+ 	ret = uclass_first_device_err(UCLASS_NVMXIP, &dev);
+ 	if (ret < 0) {
+diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
+index 2de3f5d7b3..8770b474e2 100644
+--- a/configs/corstone1000_defconfig
++++ b/configs/corstone1000_defconfig
+@@ -78,3 +78,5 @@ CONFIG_DM_GPIO=y
+ CONFIG_SYSRESET_PSCI=y
+ CONFIG_EFI_SET_TIME=y
+ CONFIG_EFI_GET_TIME=y
++CONFIG_VIRTIO_NET=y
++CONFIG_VIRTIO_MMIO=y
+-- 
+2.25.1
+