Blame SOURCES/powerpc-utils-7790c5ae.patch

956c23
commit 7790c5ae7ff50785c26e7d3942e0b86c9edb9df2
956c23
Author: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
956c23
Date:   Sun Jan 21 21:10:08 2018 +0530
956c23
956c23
    update_flash: Use device tree to get firmware version details
956c23
    
956c23
    On P9, OPAL exports firmware information via device tree
956c23
    (/ibm,firmware-versions node). Even recent hostboot firmware on P8 BMC system
956c23
    exports these information via mini device tree.
956c23
    
956c23
    Lets add support to parse device tree to get firmware information. If firmware
956c23
    information is not present in device tree then fall back to existing ipmi
956c23
    method.
956c23
    
956c23
    Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
956c23
    Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
956c23
956c23
diff --git a/scripts/update_flash_nv b/scripts/update_flash_nv
956c23
index 0ef765c..bb9dfee 100755
956c23
--- a/scripts/update_flash_nv
956c23
+++ b/scripts/update_flash_nv
956c23
@@ -58,6 +58,9 @@ DT_PATH=/proc/device-tree
956c23
 DT_FW_MI_FILE=${DT_PATH}/ibm,opal/firmware/mi-version
956c23
 DT_FW_ML_FILE=${DT_PATH}/ibm,opal/firmware/ml-version
956c23
 
956c23
+# Firmware versions device tree node
956c23
+DT_PATH_FW_NODE=${DT_PATH}/ibm,firmware-versions
956c23
+
956c23
 # Code update status values
956c23
 FLASH_SUCCESS=0			# Success
956c23
 FLASH_PARAM_ERR=-1		# Parameter error
956c23
@@ -587,7 +590,49 @@ opp_manage_flash() {
956c23
 	exit $E_SUCCESS
956c23
 }
956c23
 
956c23
-opp_display_current_fw_version() {
956c23
+# Use device tree to get firmware version
956c23
+opp_display_dt_firmware_version() {
956c23
+	local prop_prod=""
956c23
+
956c23
+	echo
956c23
+	echo "Firmware version:"
956c23
+
956c23
+	# Different BMCs uses different device tree property to display
956c23
+	# product name. On P9 system OPAL firmware takes care of parsing
956c23
+	# and it will add version property under device tree. But on older
956c23
+	# systems will have IBM or open-power or buildroot depending on
956c23
+	# who builds firmware image.
956c23
+	if [ -f $DT_PATH_FW_NODE/version ]; then
956c23
+		prop_prod=version
956c23
+	elif [ -f $DT_PATH_FW_NODE/IBM ]; then
956c23
+		prop_prod=IBM
956c23
+	elif [ -f $DT_PATH_FW_NODE/open-power ]; then
956c23
+		prop_prod=open-power
956c23
+	elif [ -f $DT_PATH_FW_NODE/buildroot ]; then
956c23
+		prop_prod=buildroot
956c23
+	fi
956c23
+
956c23
+	if [ "$prop_prod" != "" ]; then
956c23
+		echo " Product Version       : $(tr -d '\0' < $DT_PATH_FW_NODE/$prop_prod)"
956c23
+	fi
956c23
+
956c23
+	for i in `ls $DT_PATH_FW_NODE`
956c23
+	do
956c23
+		if [ "$i" = "$prop_prod" ]; then
956c23
+			continue
956c23
+		fi
956c23
+		if [ "$i" = "name" ]; then
956c23
+			continue
956c23
+		fi
956c23
+		if [ "$i" = "phandle" ] || [ "$i" = "linux,phandle" ]; then
956c23
+			continue
956c23
+		fi
956c23
+		echo " Product Extra         : $i-$(tr -d '\0' < $DT_PATH_FW_NODE/$i)"
956c23
+	done
956c23
+}
956c23
+
956c23
+# Use inband ipmi interface to get firmware version
956c23
+opp_display_ipmi_fw_version() {
956c23
 	which ipmitool >/dev/null 2>&1
956c23
 	if [ $? -ne 0 ]; then
956c23
 		echo "update_flash: ipmitool command not found."
956c23
@@ -609,6 +654,14 @@ opp_display_current_fw_version() {
956c23
 
956c23
 	echo "Firmware version:"
956c23
 	ipmitool fru print $id
956c23
+}
956c23
+
956c23
+opp_display_current_fw_version() {
956c23
+	if [ -d $DT_PATH_FW_NODE ]; then
956c23
+		opp_display_dt_firmware_version
956c23
+	else
956c23
+		opp_display_ipmi_fw_version
956c23
+	fi
956c23
 
956c23
 	exit $E_SUCCESS
956c23
 }