meta-ampere: mtjade: flash UEFI firmware at 4MB offset

UEFI firmware for Ampere Altra-based platform starts at offset 0x400000
but currently the firmware image is flashed start at offset 0. This
makes the Host fail to boot.
This commit supports offset option for the mtd-util's flashcp utility
and update the script to flash UEFI firmware starting at offset
0x400000.

Tested:
1. Turn on the Host.
2. Flash UEFI firmware. Wait for the flash complete and check if Host
   can boot successfully.
4. Turn off the Host.
5. Flash UEFI firmware. Wait for the flash complete.
6. Turn on the Host and check if Host can boot successfully.

Signed-off-by: Tung Nguyen <tung.nguyen@amperecomputing.com>
Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I0d48bfd0a7b7350b46a98bf10fe4de3887f09f02
diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
index 876671c..7a9ace3 100755
--- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
@@ -15,6 +15,8 @@
 # limitations under the License.
 
 do_flash () {
+        OFFSET=$1
+
 	# Check the PNOR partition available
 	HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
 	if [ -z "$HOST_MTD" ];
@@ -30,18 +32,10 @@
 			echo "Fail to probe Host SPI-NOR device"
 			exit 1
 		fi
-
-		echo "--- Flashing firmware to @/dev/$HOST_MTD"
-		flash_eraseall /dev/$HOST_MTD
-		flashcp -v $IMAGE /dev/$HOST_MTD
-
-		echo "--- Unbind the ASpeed SMC driver"
-		echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/unbind
-	else
-		echo "--- Flashing firmware to @/dev/$HOST_MTD"
-		flash_eraseall /dev/$HOST_MTD
-		flashcp -v $IMAGE /dev/$HOST_MTD
 	fi
+
+	echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET"
+	flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET
 }
 
 
@@ -84,7 +78,7 @@
 fi
 
 # Flash the firmware
-do_flash
+do_flash 0x400000
 
 # Switch the host SPI bus to HOST."
 echo "--- Switch the host SPI bus to HOST."
@@ -99,5 +93,5 @@
 then
 	sleep 5
 	echo "Turn on the Host"
-	obmcutil chassison
+	obmcutil poweron
 fi