meta-ampere: mtjade: update scripts with new gpio linename

Mt.Jade GPIO line-names are updated to follow naming convention at
https://github.com/openbmc/docs/blob/master/designs/device-tree-gpio-naming.md.
This commit updates related scripts to use the correct linenames.

Tested:
Check below features to work as before:
+ UEFI and SCP firmware update.
+ Host power control
+ Ampere UART mux switch
+ SCP failover

Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I080f844047618327042a7742d3fa6423b62be744
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf b/meta-ampere/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf
similarity index 100%
rename from meta-ampere/meta-mitchell/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf
rename to meta-ampere/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf
diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend
similarity index 100%
rename from meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend
rename to meta-ampere/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-fault-monitor/ampere_fault_monitor.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-fault-monitor/ampere_fault_monitor.sh
index 8f9637c..7e62eae 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-fault-monitor/ampere_fault_monitor.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-fault-monitor/ampere_fault_monitor.sh
@@ -64,7 +64,7 @@
 	local psu0_value
 	local psu1_value
 
-	psu0_presence=$(gpioget $(gpiofind PSU1_PRESENT))
+	psu0_presence=$(gpioget $(gpiofind presence-ps0))
 	psu0_failed="true"
 	if [ "$psu0_presence" == "0" ]; then
 		# PSU0 presence, monitor the PSUs using pmbus, check the STATUS_WORD
@@ -75,7 +75,7 @@
 		fi
 	fi
 
-	psu1_presence=$(gpioget $(gpiofind PSU2_PRESENT))
+	psu1_presence=$(gpioget $(gpiofind presence-ps1))
 	psu1_failed="true"
 	if [ "$psu1_presence" == "0" ]; then
 		# PSU1 presence, monitor the PSUs using pmbus, check the STATUS_WORD
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb
index c209295..ad6dd1f 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb
@@ -15,6 +15,7 @@
 SRC_URI = " \
     file://ampere_platform_init.sh \
     file://ampere_uart_console_setup.sh \
+    file://mtjade_platform_gpios_init.sh \
     file://ampere_uartmux_ctrl.sh \
     file://ampere-platform-init.service \
     "
@@ -29,4 +30,5 @@
     install -m 0755 ${WORKDIR}/ampere_uartmux_ctrl.sh ${D}/${sbindir}/
     install -d ${D}${systemd_unitdir}/system/
     install -m 0644 ${WORKDIR}/ampere-platform-init.service ${D}${systemd_unitdir}/system
+    install -m 0755 ${WORKDIR}/mtjade_platform_gpios_init.sh ${D}${sbindir}/platform_gpios_init.sh
 }
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 0a14259..7e33776 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
@@ -1,51 +1,51 @@
 #!/bin/bash
 
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
-source /usr/sbin/gpio-lib.sh
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
-source /usr/sbin/gpio-defs.sh
+# shellcheck disable=SC2046
+# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh
+source /usr/sbin/platform_gpios_init.sh
 source /usr/sbin/ampere_uart_console_setup.sh
 
-# Configure to boot from MAIN SPI-HOST
-gpio_configure_output "$SPI0_BACKUP_SEL" 0
-
-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
+#pre platform init function. implemented in platform_gpios_init.sh
+pre-platform-init
 
 # =======================================================
-# Below GPIOs are controlled by other services so just
-# initialize in A/C power only.
+# Setting default value for device sel and mux
 bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
 if [ "$bootstatus" == '32' ]; then
-	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
-
-	# Initialize OCP register
-	gpio_configure_output "$OCP_MAIN_PWREN" 0
-
-	# 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
-
-	# 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
-
-	# RTC Lock, SPECIAL_BOOT
-	gpio_configure_output "$RTC_LOCK" 0
-	gpio_configure_output "$S0_SPECIAL_BOOT" 0
-	gpio_configure_output "$S1_SPECIAL_BOOT" 0
+    echo "CONFIGURE: gpio pins to output high after AC power"
+    for gpioName in "${output_high_gpios_in_ac[@]}"; do
+        gpioset $(gpiofind "$gpioName")=1
+    done
+    echo "CONFIGURE: gpio pins to output low after AC power"
+    for gpioName in "${output_low_gpios_in_ac[@]}"; do
+        gpioset $(gpiofind "$gpioName")=0
+    done
+    echo "CONFIGURE: gpio pins to input after AC power"
+    for gpioName in "${input_gpios_in_ac[@]}"; do
+        gpioget $(gpiofind "$gpioName")
+    done
 fi
 
-gpio_configure_output "$BMC_READY" 1
+# =======================================================
+# Setting default value for others gpio pins
+echo "CONFIGURE: gpio pins to output high"
+for gpioName in "${output_high_gpios_in_bmc_reboot[@]}"; do
+    gpioset $(gpiofind "$gpioName")=1
+done
+echo "CONFIGURE: gpio pins to output low"
+for gpioName in "${output_low_gpios_in_bmc_reboot[@]}"; do
+    gpioset $(gpiofind "$gpioName")=0
+done
+echo "CONFIGURE: gpio pins to input"
+for gpioName in "${input_gpios_in_bmc_reboot[@]}"; do
+    gpioget $(gpiofind "$gpioName")
+done
+
 # =======================================================
 # Setting uart muxes to BMC as default
 uart_console_setup
+
+#post platform init function. implemented in platform_gpios_init.sh
+post-platform-init
+
+exit 0
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh
index f3b94d2..c659e56 100755
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh
@@ -18,37 +18,51 @@
 # Usage: ampere_uartmux_ctrl.sh <CPU UART port number> <UARTx_MODE>
 #        <UARTx_MODE> of 1 sets CPU To HDR_CONN
 #        <UARTx_MODE> of 2 sets BMC to CPU (eg dropbear ssh server on port 2200)
-
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
-source /usr/sbin/gpio-lib.sh
+# shellcheck disable=SC2046
 
 if [ $# -lt 2 ]; then
 	exit 1
 fi
 
 case "$1" in
-	1) GPIO_UARTx_MODE0=56
+	1) GPIO_UARTx_MODE0="uart1-mode0"
+		GPIO_UARTx_MODE1="uart1-mode1"
 	;;
-	2) GPIO_UARTx_MODE0=57
+	2) GPIO_UARTx_MODE0="uart2-mode0"
+		GPIO_UARTx_MODE1="uart2-mode1"
 	;;
-	3) GPIO_UARTx_MODE0=58
+	3) GPIO_UARTx_MODE0="uart3-mode0"
+		GPIO_UARTx_MODE1="uart3-mode1"
 	;;
-	4) GPIO_UARTx_MODE0=59
+	4) GPIO_UARTx_MODE0="uart4-mode0"
+		GPIO_UARTx_MODE1="uart4-mode1"
 	;;
 	*) echo "Invalid UART port selection"
-	   exit 1
+		exit 1
 	;;
 esac
 
 echo "Ampere UART MUX CTRL UART port $1 to mode $2"
 
 case "$2" in
-	1) gpio_configure_output "${GPIO_UARTx_MODE0}" 0
-	   exit 0
-	;;
-	2) gpio_configure_output "${GPIO_UARTx_MODE0}" 1
-	   exit 0
-	;;
+	1)
+		if gpiofind "$GPIO_UARTx_MODE0"; then
+			gpioset $(gpiofind "$GPIO_UARTx_MODE0")=1
+		fi
+		if gpiofind "$GPIO_UARTx_MODE1"; then
+			gpioset $(gpiofind "$GPIO_UARTx_MODE1")=0
+		fi
+		exit 0
+		;;
+	2)
+		if gpiofind "$GPIO_UARTx_MODE0"; then
+			gpioset $(gpiofind "$GPIO_UARTx_MODE0")=0
+		fi
+		if gpiofind "$GPIO_UARTx_MODE1"; then
+			gpioset $(gpiofind "$GPIO_UARTx_MODE1")=1
+		fi
+		exit 0
+		;;
 	*) echo "Invalid UART mode selection"
 	   exit 1
 	;;
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh
new file mode 100644
index 0000000..d7bb3d3
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/mtjade_platform_gpios_init.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uart_console_setup.sh
+source /usr/sbin/ampere_uart_console_setup.sh
+
+function pre-platform-init() {
+    echo "Do pre platform init"
+}
+
+
+function post-platform-init() {
+    echo "Do post platform init"
+}
+
+export output_high_gpios_in_ac=(
+    # add device enable, mux setting, device select gpios
+    "ext-hightemp-n"
+    "vr-pmbus-sel-n"
+    "i2c6-reset-n"
+    "i2c-backup-sel"
+    "power-chassis-control"
+    "host0-shd-req-n"
+    "host0-sysreset-n"
+    "s0-spi-auth-fail-n"
+)
+
+export output_low_gpios_in_ac=(
+    # add device enable, mux setting, device select gpios
+    "ocp-main-pwren"
+    "spi0-program-sel"
+    "spi0-backup-sel"
+    "s0-rtc-lock"
+    "host0-special-boot"
+    "s1-special-boot"
+)
+
+export input_gpios_in_ac=(
+    # add device enable, mux setting, device select gpios
+)
+
+export output_high_gpios_in_bmc_reboot=(
+    "bmc-vga-en-n"
+)
+
+export output_low_gpios_in_bmc_reboot=(
+    "spi0-backup-sel"
+)
+
+export input_gpios_in_bmc_reboot=(
+    "s0-i2c9-alert-n"
+    "s1-i2c9-alert-n"
+    "s1-i2c9-alert-n"
+    "s0-vr-hot-n"
+    "s1-vr-hot-n"
+)
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils.bbappend b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils.bbappend
index e3a63f1..df4fdf4 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils.bbappend
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils.bbappend
@@ -1,7 +1,6 @@
 FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
 
 SRC_URI:append = " \
-                  file://gpio-defs.sh \
                   file://gpio-lib.sh \
                   file://ampere_power_util.sh \
                   file://ampere_firmware_upgrade.sh \
@@ -12,7 +11,6 @@
 do_install:append() {
     install -d ${D}/usr/sbin
     install -m 0755 ${WORKDIR}/gpio-lib.sh ${D}/${sbindir}/
-    install -m 0755 ${WORKDIR}/gpio-defs.sh ${D}/${sbindir}/
     install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/
     install -m 0755 ${WORKDIR}/ampere_firmware_upgrade.sh ${D}/${sbindir}/
     install -m 0755 ${WORKDIR}/ampere_flash_bios.sh ${D}/${sbindir}/
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh
index 6f0a11f..5ba3735 100755
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_firmware_upgrade.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC2046
 
 do_fru_upgrade() {
 	FRU_DEVICE="/sys/bus/i2c/devices/3-0050/eeprom"
@@ -54,23 +55,20 @@
 	fi
 
 	if [[ $SECPRO == 1 ]]; then
-		# 3 is S0_SPECIAL_BOOT
-		gpioset 0 3=1
-		# 66 is S1_SPECIAL_BOOT
-		gpioset 0 66=1
+		gpioset $(gpiofind host0-special-boot)=1
+		gpioset $(gpiofind s1-special-boot)=1
 	fi
 
 	# Switch EEPROM control to BMC AST2500 I2C
-	# 226 is BMC_GPIOAC2_SPI0_PROGRAM_SEL
-	gpioset 0 226=0
+	gpioset $(gpiofind spi0-program-sel)=0
 
 	# 08 is BMC_GPIOB0_I2C_BACKUP_SEL
 	if [[ $DEV_SEL == 1 ]]; then
 		echo "Run update primary Boot EEPROM"
-		gpioset 0 8=1       # Main EEPROM
+		gpioset $(gpiofind i2c-backup-sel)=1       # Main EEPROM
 	elif [[ $DEV_SEL == 2 ]]; then
 		echo "Run update secondary Boot EEPROM"
-		gpioset 0 8=0       # Second EEPROM
+		gpioset $(gpiofind i2c-backup-sel)=0       # Second EEPROM
 	else
 		echo "Please choose Main (1) or Second EEPROM (2)"
 		exit 0
@@ -81,18 +79,15 @@
 
 	# Switch EEPROM control to Host
 	# 08 is BMC_GPIOB0_I2C_BACKUP_SEL
-	gpioset 0 8=1
-	# 226 is BMC_GPIOAC2_SPI0_PROGRAM_SEL
-	gpioset 0 226=1
+	gpioset $(gpiofind i2c-backup-sel)=1
+	gpioset $(gpiofind spi0-program-sel)=1
 
 	# Deassert SECPRO GPIO PINs
-        if [[ $SECPRO == 1 ]]; then
-                echo "De-asserting special GPIO PINs"
-                # 3 is S0_SPECIAL_BOOT
-                gpioset 0 3=0
-                # 66 is S1_SPECIAL_BOOT
-                gpioset 0 66=0
-        fi
+	if [[ $SECPRO == 1 ]]; then
+		echo "De-asserting special GPIO PINs"
+		gpioset $(gpiofind host0-special-boot)=0
+		gpioset $(gpiofind s1-special-boot)=0
+	fi
 
 	if [ "$chassisstate" == 'On' ];
 	then
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
index 5a13da4..cf3ec26 100755
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_flash_bios.sh
@@ -13,6 +13,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+# shellcheck disable=SC2046
 
 do_flash () {
 	# Check the PNOR partition available
@@ -93,19 +94,19 @@
 
 # Switch the host SPI bus to BMC"
 echo "--- Switch the host SPI bus to BMC."
-if ! gpioset 0 226=0; then
+if ! gpioset $(gpiofind spi0-program-sel)=0; then
 	echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state"
 	exit 1
 fi
 
 # Switch the host SPI bus (between primary and secondary)
-# 227 is BMC_SPI0_BACKUP_SEL
+# 227 is spi0-backup-sel
 if [[ $DEV_SEL == 1 ]]; then
 	echo "Run update primary Host SPI-NOR"
-	gpioset 0 227=0       # Primary SPI
+	gpioset $(gpiofind spi0-backup-sel)=0       # Primary SPI
 elif [[ $DEV_SEL == 2 ]]; then
 	echo "Run update secondary Host SPI-NOR"
-	gpioset 0 227=1       # Second SPI
+	gpioset $(gpiofind spi0-backup-sel)=1       # Second SPI
 else
 	echo "Please choose primary SPI (1) or second SPI (2)"
 	exit 0
@@ -116,7 +117,7 @@
 
 # Switch the host SPI bus to HOST."
 echo "--- Switch the host SPI bus to HOST."
-if ! gpioset 0 226=1; then
+if ! gpioset $(gpiofind spi0-program-sel)=1; then
 	echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state"
 	exit 1
 fi
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_power_util.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_power_util.sh
index a738e7f..5a641e9 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_power_util.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/ampere_power_util.sh
@@ -1,8 +1,6 @@
 #!/bin/bash
 
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
-source /usr/sbin/gpio-defs.sh
-
+# shellcheck disable=SC2046
 # Usage of this utility
 function usage() {
 	echo "Usage:"
@@ -32,9 +30,9 @@
 soft_off() {
 	# Trigger shutdown_req
 	touch /run/openbmc/host@0-softpoweroff
-	gpioset -l 0 "$S0_SHD_REQ_L"=1
+	gpioset $(gpiofind host0-shd-req-n)=0
 	sleep 1s
-	gpioset -l 0 "$S0_SHD_REQ_L"=0
+	gpioset $(gpiofind host0-shd-req-n)=1
 
 	# Wait for shutdown_ack from the host in 30 seconds
 	cnt=30
@@ -78,9 +76,9 @@
 		fi
 	fi
 	echo "Triggering sysreset pin"
-	gpioset -l 0 "$S0_SYSRESET_L"=1
+	gpioset $(gpiofind host0-sysreset-n)=0
 	sleep 1
-	gpioset -l 0 "$S0_SYSRESET_L"=0
+	gpioset $(gpiofind host0-sysreset-n)=1
 }
 
 if [ $# -lt 2 ]; then
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
deleted file mode 100644
index 4414f79..0000000
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-
-# shellcheck disable=SC2034
-# Index of GPIO device in gpioget/gpioset
-GPIO_CHIP0_IDX=0
-GPIO_CHIP1_IDX=1
-
-# Base of GPIO chip in /sys/class/gpio
-GPIO_CHIP0_BASE=512
-
-### Power control configuration
-# Power control gpios
-S0_SHD_REQ_L=49
-S0_SHD_ACK_L=50
-S0_REBOOT_ACK_L=75
-S0_SYSRESET_L=91
-S1_SYSRESET_L=92
-
-
-### Table 1: GPIO Assignments
-BMC_I2C_BACKUP_SEL=8
-S0_CPU_FW_BOOT_OK=48
-CPU_BMC_OVERTEMP_L=51
-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
-S1_SCP_AUTH_FAILURE=205
-BMC_OK=228
-SLAVE_PRESENT_L=230
-
-### Common GPIOs
-SYS_PSON_L=42
-BMC_READY=229
-
-### OCP power selection
-OCP_AUX_PWREN=139
-OCP_MAIN_PWREN=140
-
-### 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
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
index cf6e90d..0609536 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
@@ -1,33 +1,72 @@
 #!/bin/bash
 
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
-source /usr/sbin/gpio-defs.sh
+# Base of GPIO chip in /sys/class/gpio
+GPIO_CHIP0_BASE=512
+GPIO_CHIP1_BASE=780
 
-function gpio_number() {
-	GPIO_BASE=$(cat /sys/class/gpio/gpiochip"$GPIO_CHIP0_BASE"/base)
-	echo $((GPIO_BASE + $1))
-}
+AST2X00_GPIO_BASE=(
+    "$GPIO_CHIP0_BASE"
+    "$GPIO_CHIP1_BASE"
+)
 
-# Configure GPIO as output and set its value
 function gpio_configure_output() {
-	gpioId=$(gpio_number "$1")
-	echo "$gpioId" > /sys/class/gpio/export
-	echo out > /sys/class/gpio/gpio"${gpioId}"/direction
-	echo "$2" > /sys/class/gpio/gpio"${gpioId}"/value
-	echo "$gpioId" > /sys/class/gpio/unexport
+	echo "$1" > /sys/class/gpio/export
+	echo out > /sys/class/gpio/gpio"$1"/direction
+	echo "$2" > /sys/class/gpio/gpio"$1"/value
+	echo "$1" > /sys/class/gpio/unexport
 }
 
 function gpio_get_val() {
-	gpioId=$(gpio_number "$1")
-	echo "$gpioId" > /sys/class/gpio/export
-	cat /sys/class/gpio/gpio"$gpioId"/value
-	echo "$gpioId" > /sys/class/gpio/unexport
+	echo "$1" > /sys/class/gpio/export
+	cat /sys/class/gpio/gpio"$1"/value
+	echo "$1" > /sys/class/gpio/unexport
 }
 
 # Configure GPIO as input
 function gpio_configure_input() {
-	gpioId=$(gpio_number "$1")
-	echo "$gpioId" > /sys/class/gpio/export
-	echo "in" > /sys/class/gpio/gpio"${gpioId}"/direction
-	echo "$gpioId" > /sys/class/gpio/unexport
+	echo "$1" > /sys/class/gpio/export
+	echo "in" > /sys/class/gpio/gpio"$1"/direction
+	echo "$1" > /sys/class/gpio/unexport
+}
+
+function gpio_name_set()
+{
+    str=$(gpiofind "$1")
+    #Verify error code when run gpiofind
+    if [ "$?" == '1' ]; then
+        echo "Invalid gpio name $1"
+    else
+        gpioid=$(echo "$str"|cut -c 9)
+        offset=$(echo "$str"|cut -d " " -f 2)
+        gpioPin=$(("$offset" + ${AST2X00_GPIO_BASE[$gpioid]}))
+        gpio_configure_output "$gpioPin" "$2"
+    fi
+}
+
+function gpio_name_get()
+{
+    str=$(gpiofind "$1")
+    #Verify error code when run gpiofind
+    if [ "$?" == '1' ]; then
+        echo "Invalid gpio name $1"
+    else
+        offset=$(echo "$str"|cut -d " " -f 2)
+        gpioid=$(echo "$str"|cut -c 9)
+        gpioPin=$(("$offset" + ${AST2X00_GPIO_BASE[$gpioid]}))
+        gpio_get_val "$gpioPin"
+    fi
+}
+
+function gpio_name_input()
+{
+    str=$(gpiofind "$1")
+    #Verify error code when run gpiofind
+    if [ "$?" == '1' ]; then
+        echo "Invalid gpio name $1"
+    else
+        gpioid=$(echo "$str"|cut -c 9)
+        offset=$(echo "$str"|cut -d " " -f 2)
+        gpioPin=$(("$offset" + ${AST2X00_GPIO_BASE[$gpioid]}))
+        gpio_configure_input "$gpioPin"
+    fi
 }
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh
index f5bc966..5cb70f4 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh
@@ -1,9 +1,6 @@
 #!/bin/bash
 
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh
-source /usr/sbin/gpio-defs.sh
-# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh
-source /usr/sbin/gpio-lib.sh
+# shellcheck disable=SC2046
 
 function usage() {
 	echo "usage: ampere_gpio_utils.sh [power] [on|off]";
@@ -15,12 +12,12 @@
 
 set_gpio_power_on() {
 	echo "Setting GPIO before Power on"
-	val=$(gpio_get_val "$S0_CPU_FW_BOOT_OK")
+	val=$(gpioget $(gpiofind host0-ready))
 	if [ "$val" == 1 ]; then
 		exit
 	fi
-	gpio_configure_output "$SPI0_PROGRAM_SEL" 1
-	gpio_configure_output "$SPI0_BACKUP_SEL" 0
+	gpioset $(gpiofind spi0-program-sel)=1
+	gpioset $(gpiofind spi0-backup-sel)=0
 }
 
 if [ $# -lt 2 ]; then
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/ampere_scp_failover.sh b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/ampere_scp_failover.sh
index c1c16ab..889bf41 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/ampere_scp_failover.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/ampere_scp_failover.sh
@@ -9,16 +9,13 @@
 # shellcheck disable=SC1091
 # shellcheck disable=SC2046
 
-source /usr/sbin/gpio-lib.sh
-source /usr/sbin/gpio-defs.sh
-
 # Check the I2C_BACKUP_SEL
-I2C_BACKUP_SEL=$(gpio_get_val "$BMC_I2C_BACKUP_SEL")
+I2C_BACKUP_SEL=$(gpioget $(gpiofind i2c-backup-sel))
 if [ "${I2C_BACKUP_SEL}" == "1" ]; then
 	# If it is HIGH, set it LOW. Then reset the Host to boot from
 	# the failover Boot EEPROM.
 	echo "scp-failover: switch HOST to failover boot EEPROM"
-	gpioset $(gpiofind BMC_SELECT_EEPROM)=0
+	gpioset $(gpiofind i2c-backup-sel)=0
 
 	# Reset the Host to boot on the failover EEPROM
 	ampere_power_util.sh mb force_reset
@@ -27,7 +24,7 @@
 	obmcutil chassisoff
 
 	echo "scp-failover: switch HOST back to the main Boot EEPROM"
-	gpioset $(gpiofind BMC_SELECT_EEPROM)=1
+	gpioset $(gpiofind i2c-backup-sel)=1
 
 	# Log event
 	ampere_add_redfishevent.sh OpenBMC.0.1.GeneralFirmwareSecurityViolation.Critical "SCP Authentication failure"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
index 66c3dcb..bc03dd8 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
@@ -1,37 +1,35 @@
 [
     {
         "Name": "REBOOT_ACK",
-	"ChipId": "0",
-	"GpioNum": 75,
+        "LineName": "host0-reboot-ack-n",
         "EventMon": "FALLING",
         "Target": "obmc-host-force-warm-reboot@0.target",
         "Continue": true
     },
     {
         "Name": "SHUTDOWN_ACK",
-	"ChipId": "0",
-	"GpioNum": 50,
+        "LineName": "host0-shd-ack-n",
         "EventMon": "FALLING",
         "Target": "ampere-host-shutdown-ack@0.service",
         "Continue": true
     },
     {
         "Name": "S0_OVERTEMP",
-        "LineName": "S0_OVERTEMP_L",
+        "LineName": "s0-overtemp-n",
         "EventMon": "FALLING",
         "Target": "ampere_overtemp@0.service",
         "Continue": true
     },
     {
         "Name": "S1_OVERTEMP",
-        "LineName": "S1_OVERTEMP_L",
+        "LineName": "s1-overtemp-n",
         "EventMon": "FALLING",
         "Target": "ampere_overtemp@1.service",
         "Continue": true
     },
     {
         "Name": "S0_HIGHTEMP",
-        "LineName": "S0_HIGHTEMP_L",
+        "LineName": "s0-hightemp-n",
         "EventMon": "BOTH",
         "Targets": {
           "FALLING": ["ampere_hightemp_start@0.service"],
@@ -41,7 +39,7 @@
     },
     {
         "Name": "S1_HIGHTEMP",
-        "LineName": "S1_HIGHTEMP_L",
+        "LineName": "s1-hightemp-n",
         "EventMon": "BOTH",
         "Targets": {
           "FALLING": ["ampere_hightemp_start@1.service"],
@@ -51,21 +49,21 @@
     },
     {
         "Name": "S0_SCP_AUTH_FAIL",
-        "LineName": "S0_SCP_AUTH_FAIL_L",
+        "LineName": "s0-sys-auth-failure-n",
         "EventMon": "FALLING",
         "Target": "ampere_scp_failover.service",
         "Continue": true
     },
     {
         "Name": "PSU1_VIN_GOOD",
-        "LineName": "PSU1_VIN_GOOD",
+        "LineName": "ps0-vin-good",
         "EventMon": "RISING",
         "Target": "psu_hotswap_reset@0.service",
         "Continue": true
     },
     {
         "Name": "PSU2_VIN_GOOD",
-        "LineName": "PSU2_VIN_GOOD",
+        "LineName": "ps1-vin-good",
         "EventMon": "RISING",
         "Target": "psu_hotswap_reset@1.service",
         "Continue": true
diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf
deleted file mode 100644
index fd7a392..0000000
--- a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-ssif/ssifbridge-override.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-[Service]
-ExecStopPost=/bin/sh -c "/usr/bin/gpioset 0 228=0"
-ExecStartPost=/bin/sh -c "/usr/bin/gpioset 0 228=1"
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend b/meta-ampere/meta-mitchell/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend
deleted file mode 100644
index e03cc21..0000000
--- a/meta-ampere/meta-mitchell/recipes-phosphor/ipmi/phosphor-ipmi-ssif_%.bbappend
+++ /dev/null
@@ -1,11 +0,0 @@
-FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
-
-SRC_URI += " file://ssifbridge-override.conf"
-
-FILES:${PN} += "${systemd_system_unitdir}/ssifbridge.service.d"
-
-do_install:append() {
-    install -d ${D}${systemd_system_unitdir}/ssifbridge.service.d
-    install -m 644 ${WORKDIR}/ssifbridge-override.conf \
-        ${D}${systemd_system_unitdir}/ssifbridge.service.d
-}