From 67b2bcd428a13d14d4311bd1122e664f391af4d4 Mon Sep 17 00:00:00 2001
From: Diego Sueiro <diego.sueiro@arm.com>
Date: Wed, 4 Oct 2023 06:29:12 +0100
Subject: [PATCH] vexpress64: Imply CONFIG_ARM64_CRC32 by default

Enable the Arm64 CRC-32 instruction by default for
vexpress64. The CRC-32 instruction is a required
feature of ARMv8.1 and newer.

Upstream-Status: Pending
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
 board/armltd/vexpress64/Kconfig  |  1 +
 include/configs/vexpress_aemv8.h | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
index 9ef3fa1b379f..1a0e0a5018d8 100644
--- a/board/armltd/vexpress64/Kconfig
+++ b/board/armltd/vexpress64/Kconfig
@@ -24,6 +24,7 @@ config VEXPRESS64_BASE_MODEL
 	imply DM_RNG
 	imply RNG_ARM_RNDR
 	select ARM_SMCCC
+	imply ARM64_CRC32
 
 choice
 	prompt "VExpress64 board variant"
diff --git a/include/configs/vexpress_aemv8.h b/include/configs/vexpress_aemv8.h
index 5eee13b3fc01..5c271d239501 100644
--- a/include/configs/vexpress_aemv8.h
+++ b/include/configs/vexpress_aemv8.h
@@ -172,7 +172,7 @@
  */
 #define BOOTENV_DEV_SMH(devtypeu, devtypel, instance) \
 	"bootcmd_smh= " 						\
-		"if load hostfs - ${boot_addr_r} ${boot_name}; then"		\
+		"if load hostfs - ${boot_addr_r} ${boot_name}; then"	\
 		"  setenv bootargs;"					\
 		"  abootimg addr ${boot_addr_r};"			\
 		"  abootimg get dtb --index=0 fdt_addr_r;"		\
@@ -181,13 +181,14 @@
 		"  if load hostfs - ${kernel_addr_r} ${kernel_name}; then"	\
 		"    setenv fdt_high 0xffffffffffffffff;"		\
 		"    setenv initrd_high 0xffffffffffffffff;"		\
-		"    if test -n load hostfs - ${fdt_addr_r} ${fdtfile}; then"			\
-		"        fdt move $fdtcontroladdr $fdt_addr_r;"			\
-		"    fi;"			\
-		"    load hostfs - ${ramdisk_addr_r} ${ramdisk_name};" \
+		"    load hostfs - ${fdt_addr_r} ${fdtfile};"		\
+		"    if test $? -eq 1; then "                           \
+		"        fdt move $fdtcontroladdr $fdt_addr_r;"		\
+		"    fi;"						\
+		"    load hostfs - ${ramdisk_addr_r} ${ramdisk_name};" 	\
 		"    fdt addr ${fdt_addr_r};"				\
 		"    fdt resize;"					\
-		"    fdt chosen ${ramdisk_addr_r} ${filesize};"	\
+		"    fdt chosen ${ramdisk_addr_r} ${filesize};"		\
 		"    booti $kernel_addr_r - ${fdt_addr_r};"		\
 		"  fi;"							\
 		"fi\0"
