meta-ampere: mtjade: update platform init

Set PSON to default value in AC power will prevent the Host ON
accidentally. This commit also configures some important GPIOs to
default value when A/C.

Tested:
1. Do A/C power and check if power and host state from "obmcutil status"
not Running.

Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: Iba99a2dbef3b48a5d110e92c9167a69a603a8e54
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
index 4b448ef..e04af8d 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
@@ -2,54 +2,45 @@
 
 # shellcheck source=/dev/null
 source /usr/sbin/gpio-lib.sh
+source /usr/sbin/gpio-defs.sh
 
-# GPIOAC3 BMC_SPI0_BACKUP_SEL Boot from MAIN SPI-HOST
-gpio_configure_output 227 0
+# Configure to boot from MAIN SPI-HOST
+gpio_configure_output "$SPI0_BACKUP_SEL" 0
 
-# GPIOM4 S0_I2C9_ALERT_L
-gpio_configure_input 100
-
-# GPIOM5 S1_I2C9_ALERT_L
-gpio_configure_input 101
-
-# GPIOQ7 GPIO_BMC_VGA_FRONT_PRES_L
-gpio_configure_input 135
-
-# GPIOS0 GPIO_S0_VRHOT_L
-gpio_configure_input 144
-
-# GPIOS1 GPIO_S1_VRHOT_L
-gpio_configure_input 145
-
-# GPIOY3 BMC_VGA_SEL
-gpio_configure_output 195 1
-
-# GPIO_BMC_READY
-gpio_configure_output 229 1
+gpio_configure_input "$S0_I2C9_ALERT_L"
+gpio_configure_input "$S1_I2C9_ALERT_L"
+gpio_configure_input "$GPIO_BMC_VGA_FRONT_PRES_L"
+gpio_configure_input "$GPIO_S0_VRHOT_L"
+gpio_configure_input "$GPIO_S1_VRHOT_L"
+gpio_configure_output "$BMC_VGA_SEL" 1
 
 # =======================================================
 # Below GPIOs are controlled by other services so just
 # initialize in A/C power only.
 bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
 if [ "$bootstatus" == '32' ]; then
-	# BMC_GPIOR2_EXT_HIGHTEMP_L
-	gpio_configure_output 138 1
+	gpio_configure_output "$BMC_GPIOR2_EXT_HIGHTEMP_L" 1
+	gpio_configure_output "$GPIO_BMC_VR_PMBUS_SEL_L" 1
+	gpio_configure_output "$GPIO_BMC_I2C6_RESET_L" 1
 
-	# GPIOS5 GPIO_BMC_VR_PMBUS_SEL_L
-	gpio_configure_output 149 1
+	# Initialize OCP register
+	gpio_configure_output "$OCP_MAIN_PWREN" 0
 
-	# GPIOH7 GPIO_BMC_I2C6_RESET_L
-	gpio_configure_output 63 1
+	# Configure SPI-NOR/EEPROM switching
+	gpio_configure_output "$SPI0_PROGRAM_SEL" 0
+	gpio_configure_output "$BMC_I2C_BACKUP_SEL" 1
+	gpio_configure_output "$SPI0_BACKUP_SEL" 0
 
-	# GPIO_BMC_OCP_AUX_PWREN
-	gpio_configure_output 139 1
+	# Initialize BMC_SYS_PSON_L, SHD_REQ_L, BMC_SYSRESET_L
+	gpio_configure_output "$SYS_PSON_L" 1
+	gpio_configure_output "$S0_SHD_REQ_L" 1
+	gpio_configure_output "$S0_SYSRESET_L" 1
+	gpio_configure_output "$S1_SYSRESET_L" 1
 
-	# GPIO_BMC_OCP_MAIN_PWREN
-	gpio_configure_output 140 0
-
-	# BMC_GPIOAC2_SPI0_PROGRAM_SEL
-	gpio_configure_output 226 0
-
-	# BMC_GPIOB0_I2C_BACKUP_SEL
-	gpio_configure_output 8 1
+	# RTC Lock, SPECIAL_BOOT
+	gpio_configure_output "$RTC_LOCK" 0
+	gpio_configure_output "$S0_SPECIAL_BOOT" 0
+	gpio_configure_output "$S1_SPECIAL_BOOT" 0
 fi
+
+gpio_configure_output "$BMC_READY" 1
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
index e0a7c02..2f2a4d6 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
@@ -15,6 +15,7 @@
 S0_SHD_ACK_L=50
 S0_REBOOT_ACK_L=75
 S0_SYSRESET_L=91
+S1_SYSRESET_L=92
 
 
 ### Table 1: GPIO Assignments
@@ -24,6 +25,9 @@
 CPU_BMC_HIGHTEMP_L=72
 CPU_FAULT_ALERT=73
 S1_CPU_FW_BOOT_OK=202
+S0_SPECIAL_BOOT=3
+S1_SPECIAL_BOOT=66
+RTC_LOCK=203
 
 ### Table 2: Alert and Additional Miscellaneous Signals
 S0_SCP_AUTH_FAILURE=74
@@ -42,3 +46,14 @@
 ### SPI0 Mode  selection
 SPI0_PROGRAM_SEL=226
 SPI0_BACKUP_SEL=227
+
+### Mt.Jade specific GPIOs
+S0_I2C9_ALERT_L=100
+S1_I2C9_ALERT_L=101
+GPIO_BMC_VGA_FRONT_PRES_L=135
+GPIO_S0_VRHOT_L=144
+GPIO_S1_VRHOT_L=145
+BMC_VGA_SEL=195
+BMC_GPIOR2_EXT_HIGHTEMP_L=138
+GPIO_BMC_VR_PMBUS_SEL_L=149
+GPIO_BMC_I2C6_RESET_L=63