summaryrefslogtreecommitdiff
path: root/meta-ampere
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ampere')
-rw-r--r--meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb30
-rw-r--r--meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service13
-rw-r--r--meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh93
-rwxr-xr-xmeta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh37
-rw-r--r--meta-ampere/meta-common/recipes-phosphor/ipmi/ampere-ipmi-oem.bb2
-rw-r--r--meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet.bb28
-rw-r--r--meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/00-bmc-usb0.network (renamed from meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network)0
-rw-r--r--meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere-usbnet.service12
-rw-r--r--meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere_usbnet.sh21
-rw-r--r--meta-ampere/meta-jade/conf/machine/mtjade.conf3
-rwxr-xr-xmeta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh19
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh33
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh3
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh50
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh51
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh191
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh3
-rw-r--r--meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh32
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0001-aspeed-scu-Switch-PWM-pin-to-GPIO-input-mode.patch87
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0002-aspeed-Disable-internal-PD-resistors-for-GPIOs.patch45
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0003-aspeed-support-passing-system-reset-status-to-kernel.patch180
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0004-aspeed-add-gpio-support.patch518
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0005-aspeed-Enable-SPI-master-mode.patch33
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0006-aspeed-support-Mt.Jade-platform-init.patch175
-rw-r--r--meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend10
-rwxr-xr-xmeta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh25
-rw-r--r--meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh4
-rw-r--r--meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh10
-rwxr-xr-xmeta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh20
-rwxr-xr-x[-rw-r--r--]meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh14
-rw-r--r--meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend1
31 files changed, 295 insertions, 1448 deletions
diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb
deleted file mode 100644
index 3045fa557..000000000
--- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb
+++ /dev/null
@@ -1,30 +0,0 @@
-SUMMARY = "Ampere Computing LLC Add Ethernet over USB gadget device"
-DESCRIPTION = "Add Ethernet over USB gadget device for Ampere systems"
-PR = "r1"
-
-LICENSE = "Apache-2.0"
-S = "${WORKDIR}"
-
-LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
-
-inherit systemd
-inherit obmc-phosphor-systemd
-
-DEPENDS = "systemd"
-RDEPENDS:${PN} = "bash"
-
-SYSTEMD_PACKAGES = "${PN}"
-SYSTEMD_SERVICE:${PN} = " \
- ampere_add_usbnet_gadget.service \
- "
-
-SRC_URI += "file://00-bmc-usb0.network"
-SRC_URI += "file://ampere_add_usbnet_gadget.sh"
-
-do_install:append() {
- install -d ${D}${sbindir}
- install -d ${D}/etc/systemd/network
- install -m 744 ${WORKDIR}/ampere_add_usbnet_gadget.sh ${D}${sbindir}/
- install -m 644 ${WORKDIR}/00-bmc-usb0.network \
- ${D}/etc/systemd/network/
-}
diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service
deleted file mode 100644
index 428263a89..000000000
--- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Ampere adds Ethernet over USB gadget device
-Wants=systemd-networkd.service
-Before=systemd-networkd.service
-After=phosphor-ipmi-host.service
-
-[Service]
-ExecStart=/usr/bin/env ampere_add_usbnet_gadget.sh
-SyslogIdentifier=ampere_add_usbnet_gadget.sh
-Type=oneshot
-
-[Install]
-WantedBy=systemd-networkd.service
diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh
deleted file mode 100644
index c4c2c273f..000000000
--- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/bin/sh
-
-# Add an Ethernet over USB gadget device and connect to a port of Aspeed USB
-# virtual hub. If can't find any free port on virtual hub, exit with failure.
-# If can't find the virtual hub, exit with failure.
-
-# Author: Thinh Hung Pham <thinh.pham@amperecomputing.com>
-# Signed-off-by: Chanh Nguyen <chnguyen@amperecomputing.com>
-
-UDC_SYSPATH=/sys/class/udc
-VHUB_DEVICE=1e6a0000.usb-vhub:p
-GADGET_CONFIG_SYSPATH=/sys/kernel/config/usb_gadget
-USBNET=usbnet
-# The number of port on AST2500 USB virtual hub
-NUM_PORT_USB_HUB=5
-# idVendor = 0x1d6b: Linux Foundation
-VENDORID=0x1d6b
-# idProduct = 0x0103: NCM (Ethernet) Gadget
-PRODUCTID=0x0103
-# Language code = 0x409: English – United States
-LANGUAGEID=0x409
-SERIALNUMBER=cafecafe
-MANUFACTURER=Aspeed
-FUNCTION=ecm.usb0
-
-if [ ! -d ${GADGET_CONFIG_SYSPATH} ]; then
- # GADGET_CONFIG_SYSPATH is not exist
- # Return 1 so that systemd knows the service failed to start
- echo "ERROR: ${GADGET_CONFIG_SYSPATH} : doesn't exist!"
- exit 1
-fi
-
-find_free_vhub_port(){
- for ((i=1;i<=${NUM_PORT_USB_HUB};i++))
- do
- state=$(cat ${UDC_SYSPATH}/${VHUB_DEVICE}${i}/state)
- func=$(cat ${UDC_SYSPATH}/${VHUB_DEVICE}${i}/function)
- if [ "${state}" == "not attached" -a "${func}" == "" ]; then
- FREEUDC=${VHUB_DEVICE}${i}
- break
- fi
- done
- if [ ${i} -eq 6 ]; then
- # Can't find a free port
- # Return 1 so that systemd knows the service failed to start
- echo "ERROR: Can't find a free port !"
- exit 1
- fi
-}
-
-if [ -d ${GADGET_CONFIG_SYSPATH}/${USBNET} ]; then
- cd ${GADGET_CONFIG_SYSPATH}/${USBNET}
-else
- # Create the gadget
- mkdir ${GADGET_CONFIG_SYSPATH}/${USBNET}
- cd ${GADGET_CONFIG_SYSPATH}/${USBNET}
-
- # Configure the gadget
- echo ${VENDORID} > idVendor
- echo ${PRODUCTID} > idProduct
- mkdir strings/${LANGUAGEID}
- echo ${SERIALNUMBER} > strings/${LANGUAGEID}/serialnumber
- echo ${MANUFACTURER} > strings/${LANGUAGEID}/manufacturer
- echo ${USBNET} > strings/${LANGUAGEID}/product
-
- # Create the configuration
- mkdir configs/c.1
- mkdir configs/c.1/strings/${LANGUAGEID}
-
- # Create the function
- mkdir functions/${FUNCTION}
-
- # Associate the function with its configuration
- ln -s functions/${FUNCTION} configs/c.1
-fi
-
-# Find an available virtual hub port
-find_free_vhub_port
-
-# Enable the gadget
-echo ${FREEUDC} > UDC
-
-if [[ $? -ne 0 ]]; then
- # End
- cd - > /dev/null
- # Virtual HUB is not available
- # Return 1 so that systemd knows the service failed to start
- exit 1
-fi
-
-# End
-cd - > /dev/null
-
diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
index af3e2bead..cc39f30fc 100755
--- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
+++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
@@ -21,31 +21,29 @@
usage () {
echo "Usage:"
- echo " $(basename $0) <image path> "
+ echo " $(basename "$0") <image path> "
echo "Where:"
echo " <image path>: the path link to folder, which include image file and MANIFEST"
echo "Example:"
- echo " $(basename $0) /tmp/images/ghdh1393"
+ echo " $(basename "$0") /tmp/images/ghdh1393"
}
IMG_PATH="$1"
-if [ ! -d $IMG_PATH ]; then
- echo $IMG_PATH
+if [ ! -d "$IMG_PATH" ]; then
echo "The folder $IMG_PATH does not exist"
usage
exit 1
fi
MANIFEST_PATH="${IMG_PATH}/MANIFEST"
-if [ ! -f $MANIFEST_PATH ]; then
- echo $MANIFEST_PATH
+if [ ! -f "$MANIFEST_PATH" ]; then
echo "The MANIFEST file $MANIFEST_PATH does not exist"
usage
exit 1
fi
-EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' ${MANIFEST_PATH} | cut -d "=" -f 2)
+EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' "${MANIFEST_PATH}" | cut -d "=" -f 2)
# If the ExtendedVersion is empty, set default to update UEFI/EDKII on primary device
if [ -z "$EXTENDED_VERSION" ]
@@ -56,28 +54,28 @@ fi
# Assign the command based on the ExtendedVersion
case ${EXTENDED_VERSION} in
"primary")
- export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
- export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 1'
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
+ CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 1"
;;
"secondary")
- export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
- export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 2'
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
+ CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 2"
;;
"scp-primary")
- export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
- export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1'
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1"
;;
"scp-secondary")
- export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
- export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2'
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2"
;;
"fru")
- export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.bin" \))
- export CMD='/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE'
+ IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.bin" \))
+ CMD="/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE"
;;
*)
@@ -91,11 +89,10 @@ if [ -z "$IMAGE" ]
then
echo "ERROR: The image file: No such file or directory"
exit 1
-else
- eval $CMD
fi
-if [[ $? -ne 0 ]]; then
+if ! eval "$CMD";
+then
echo "ERROR: The firmware update not successfull"
exit 1
fi
diff --git a/meta-ampere/meta-common/recipes-phosphor/ipmi/ampere-ipmi-oem.bb b/meta-ampere/meta-common/recipes-phosphor/ipmi/ampere-ipmi-oem.bb
index e0a6819b6..68852b4ae 100644
--- a/meta-ampere/meta-common/recipes-phosphor/ipmi/ampere-ipmi-oem.bb
+++ b/meta-ampere/meta-common/recipes-phosphor/ipmi/ampere-ipmi-oem.bb
@@ -16,7 +16,7 @@ LIBRARY_NAMES = "libzampoemcmds.so"
S = "${WORKDIR}/git"
SRC_URI = "git://github.com/openbmc/ampere-ipmi-oem.git"
-SRCREV = "1463f7013a17699081c1fbf506ee8d57827d1088"
+SRCREV = "4c556399c7161d3742cad978fd64e8ad0fd0aa0a"
HOSTIPMI_PROVIDER_LIBRARY += "${LIBRARY_NAMES}"
NETIPMI_PROVIDER_LIBRARY += "${LIBRARY_NAMES}"
diff --git a/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet.bb b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet.bb
new file mode 100644
index 000000000..d1dff35ec
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet.bb
@@ -0,0 +1,28 @@
+SUMMARY = "Enable USB ethernet"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+DEPENDS += "systemd"
+RDEPENDS:${PN} += "libsystemd bash"
+
+inherit allarch systemd
+
+SRC_URI += "file://ampere-usbnet.service \
+ file://ampere_usbnet.sh \
+ file://00-bmc-usb0.network"
+
+do_install() {
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 ${WORKDIR}/ampere-usbnet.service ${D}${systemd_unitdir}/system
+
+ install -d ${D}${sysconfdir_native}/systemd/network/
+ install -m 0644 ${WORKDIR}/00-bmc-usb0.network ${D}${sysconfdir_native}/systemd/network
+
+ install -d ${D}/${sbindir}
+ install -m 755 ${WORKDIR}/ampere_usbnet.sh ${D}/${sbindir}
+}
+
+NATIVE_SYSTEMD_SUPPORT = "1"
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = "ampere-usbnet.service"
diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/00-bmc-usb0.network
index 640fe04b9..640fe04b9 100644
--- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network
+++ b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/00-bmc-usb0.network
diff --git a/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere-usbnet.service b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere-usbnet.service
new file mode 100644
index 000000000..349954325
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere-usbnet.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Ampere Ethernet over USB gadget device
+After=phosphor-ipmi-host.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/ampere_usbnet.sh
+ExecStop=/usr/bin/usb-ctrl ecm usbnet off
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere_usbnet.sh b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere_usbnet.sh
new file mode 100644
index 000000000..fd2dce610
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-phosphor/network/ampere-usbnet/ampere_usbnet.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+ENV_MAC_ADDR=$(fw_printenv eth1addr)
+if [ -z "$ENV_MAC_ADDR" ]; then
+ ENV_MAC_ADDR=$(fw_printenv ethaddr)
+fi
+
+MAC_ADDR=$(echo "$ENV_MAC_ADDR" | cut -d "=" -f 2)
+
+if [ -n "$MAC_ADDR" ]; then
+ # Generate MAC Address from eth1addr using locally administered MAC
+ # https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local_(U/L_bit
+ SUBMAC=$(echo "$MAC_ADDR" | cut -d ":" -f 2-6)
+ /usr/bin/usb-ctrl ecm usbnet on "06:$SUBMAC" "02:$SUBMAC"
+else
+ /usr/bin/usb-ctrl ecm usbnet on
+fi
+
+# Use NCM (Ethernet) Gadget instead of FunctionFS Gadget
+echo 0x0103 > /sys/kernel/config/usb_gadget/usbnet/idProduct
+echo "OpenBMC usbnet Device" > /sys/kernel/config/usb_gadget/usbnet/strings/0x409/product
diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf
index b42557566..633efa012 100644
--- a/meta-ampere/meta-jade/conf/machine/mtjade.conf
+++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf
@@ -5,6 +5,7 @@ UBOOT_MACHINE = "ast_g5_phy_config"
require conf/machine/include/ast2500.inc
require conf/machine/include/obmc-bsp-common.inc
require conf/distro/include/phosphor-isolation.inc
+require conf/distro/include/phosphor-aspeed-spi-master-mode.inc
# Reformat SPI flash layout to 64MB
FLASH_SIZE = "65536"
@@ -15,7 +16,7 @@ FLASH_RWFS_OFFSET = "43008"
OBMC_POWER_SUPPLY_INSTANCES = "0 1"
-OBMC_MACHINE_FEATURES += "\
+MACHINE_FEATURES += "\
obmc-phosphor-chassis-mgmt \
obmc-phosphor-flash-mgmt \
obmc-chassis-state-mgmt \
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 7a9ace30e..b7f4bc52e 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
@@ -18,7 +18,7 @@ do_flash () {
OFFSET=$1
# Check the PNOR partition available
- HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
# If the PNOR partition is not available, then bind again driver
@@ -26,7 +26,7 @@ do_flash () {
echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/bind
sleep 2
- HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+ HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
echo "Fail to probe Host SPI-NOR device"
@@ -35,18 +35,17 @@ do_flash () {
fi
echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET"
- flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET
+ flashcp -v "$IMAGE" /dev/"$HOST_MTD" "$OFFSET"
}
if [ $# -eq 0 ]; then
- echo "Usage: $(basename $0) <BIOS image file>"
+ echo "Usage: $(basename "$0") <BIOS image file>"
exit 0
fi
IMAGE="$1"
-if [ ! -f $IMAGE ]; then
- echo $IMAGE
+if [ ! -f "$IMAGE" ]; then
echo "The image file $IMAGE does not exist"
exit 1
fi
@@ -70,9 +69,7 @@ fi
# Switch the host SPI bus to BMC"
echo "--- Switch the host SPI bus to BMC."
-gpioset 0 226=0
-
-if [[ $? -ne 0 ]]; then
+if ! gpioset 0 226=0; then
echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state"
exit 1
fi
@@ -82,9 +79,7 @@ do_flash 0x400000
# Switch the host SPI bus to HOST."
echo "--- Switch the host SPI bus to HOST."
-gpioset 0 226=1
-
-if [[ $? -ne 0 ]]; then
+if ! gpioset 0 226=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-mac-update/ampere_update_mac.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh
index 4e4d6f3e7..8182b4c8d 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh
@@ -5,43 +5,44 @@
ETHERNET_INTERFACE="eth1"
ETHERNET_NCSI="eth0"
ENV_ETH="eth1addr"
-ENV_MAC_ADDR=`fw_printenv | grep $ENV_ETH`
+ENV_MAC_ADDR=$(fw_printenv | grep $ENV_ETH)
# Workaround to dhcp NC-SI eth0 interface when BMC boot up
ifconfig ${ETHERNET_NCSI} down
ifconfig ${ETHERNET_NCSI} up
# Read FRU Board Custom Field 1 to get the MAC address
-CUSTOM_FIELD_1=`busctl get-property xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice/Mt_Jade_Motherboard xyz.openbmc_project.FruDevice BOARD_INFO_AM1`
-MAC_ADDR=`echo $CUSTOM_FIELD_1 | cut -d "\"" -f 2`
+CUSTOM_FIELD_1=$(busctl get-property xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice/Mt_Jade_Motherboard xyz.openbmc_project.FruDevice BOARD_INFO_AM1)
+MAC_ADDR=$(echo "$CUSTOM_FIELD_1" | cut -d "\"" -f 2)
# Check if BMC MAC address is exported
if [ -z "${MAC_ADDR}" ]; then
- echo "ERROR: No BMC MAC address is detected from FRU Inventory information!"
- # Return 1 so that systemd knows the service failed to start
- exit 1
+ echo "ERROR: No BMC MAC address is detected from FRU Inventory information!"
+ # Return 1 so that systemd knows the service failed to start
+ exit 1
fi
# Check if BMC MAC address is exported
if [[ $ENV_MAC_ADDR =~ $MAC_ADDR ]]; then
- echo "WARNING: BMC MAC address already exist!"
- exit 0
+ echo "WARNING: BMC MAC address already exist!"
+ exit 0
fi
# Request to update the MAC address
-fw_setenv ${ENV_ETH} ${MAC_ADDR}
+fw_setenv ${ENV_ETH} "${MAC_ADDR}"
-if [[ $? -ne 0 ]]; then
- echo "ERROR: Fail to set MAC address to ${ENV_ETH}"
- exit 1
+if fw_setenv ${ENV_ETH} "${MAC_ADDR}";
+then
+ echo "ERROR: Fail to set MAC address to ${ENV_ETH}"
+ exit 1
fi
# Request to restart the service
ifconfig ${ETHERNET_INTERFACE} down
-ifconfig ${ETHERNET_INTERFACE} hw ether ${MAC_ADDR}
-if [[ $? -ne 0 ]]; then
- echo "ERROR: Can not update MAC ADDR to ${ETHERNET_INTERFACE}"
- exit 1
+if ! ifconfig ${ETHERNET_INTERFACE} hw ether "${MAC_ADDR}";
+then
+ echo "ERROR: Can not update MAC ADDR to ${ETHERNET_INTERFACE}"
+ exit 1
fi
ifconfig ${ETHERNET_INTERFACE} up
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 a2578fa2f..c3772fb9a 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,5 +1,6 @@
#!/bin/bash
+# shellcheck source=/dev/null
source /usr/sbin/gpio-lib.sh
# GPIOAC3 BMC_SPI0_BACKUP_SEL Boot from MAIN SPI-HOST
@@ -29,7 +30,7 @@ gpio_configure_output 229 1
# =======================================================
# Below GPIOs are controlled by other services so just
# initialize in A/C power only.
-cmdline=`cat /proc/cmdline`
+cmdline=$(cat /proc/cmdline)
if [[ $cmdline == *resetreason=power* ]]; then
# BMC_GPIOR2_EXT_HIGHTEMP_L
gpio_configure_output 138 1
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 8e4f455bf..1a098f446 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,43 +1,45 @@
#!/bin/bash
+
+# shellcheck source=/dev/null
source /usr/sbin/gpio-defs.sh
source /usr/sbin/gpio-lib.sh
function usage() {
- echo "usage: ampere_gpio_utils.sh [power] [on|off]";
+ echo "usage: ampere_gpio_utils.sh [power] [on|off]";
}
set_gpio_power_off() {
- echo "Setting GPIO before Power off"
- gpio_configure_output $OCP_AUX_PWREN 1
- gpio_configure_output $OCP_MAIN_PWREN 0
- gpio_configure_output $SPI0_PROGRAM_SEL 0
+ echo "Setting GPIO before Power off"
+ gpio_configure_output "$OCP_AUX_PWREN" 1
+ gpio_configure_output "$OCP_MAIN_PWREN" 0
+ gpio_configure_output "$SPI0_PROGRAM_SEL" 0
}
set_gpio_power_on() {
- echo "Setting GPIO before Power on"
- gpio_configure_output $OCP_AUX_PWREN 1
- gpio_configure_output $OCP_MAIN_PWREN 1
- gpio_configure_output $SPI0_PROGRAM_SEL 1
- gpio_configure_output $SPI0_BACKUP_SEL 0
+ echo "Setting GPIO before Power on"
+ gpio_configure_output "$OCP_AUX_PWREN" 1
+ gpio_configure_output "$OCP_MAIN_PWREN" 1
+ gpio_configure_output "$SPI0_PROGRAM_SEL" 1
+ gpio_configure_output "$SPI0_BACKUP_SEL" 0
}
if [ $# -lt 2 ]; then
- echo "Total number of parameter=$#"
- echo "Insufficient parameter"
- usage;
- exit 0;
+ echo "Total number of parameter=$#"
+ echo "Insufficient parameter"
+ usage;
+ exit 0;
fi
-if [ $1 == "power" ]; then
- if [ $2 == "on" ]; then
- set_gpio_power_on
- elif [ $2 == "off" ]; then
- set_gpio_power_off
- fi
- exit 0;
+if [ "$1" == "power" ]; then
+ if [ "$2" == "on" ]; then
+ set_gpio_power_on
+ elif [ "$2" == "off" ]; then
+ set_gpio_power_off
+ fi
+ exit 0;
else
- echo "Invalid parameter1=$1"
- usage;
- exit 0;
+ echo "Invalid parameter1=$1"
+ usage;
+ exit 0;
fi
exit 0;
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh
index 9eeeeca5a..024336d20 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh
@@ -1,45 +1,38 @@
#!/bin/bash
+# shellcheck source=/dev/null
source /usr/sbin/gpio-defs.sh
source /usr/sbin/gpio-lib.sh
-host_status() {
- st=$(busctl get-property xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host CurrentHostState | cut -d"." -f6)
- if [ "$st" == "Running\"" ]; then
- echo "on"
- else
- echo "off"
- fi
-}
-
createFile=$1
-setState=$2
-if [ $(host_status) == "on" ]; then
- exit 0
+# Check current Host status. Do nothing when the Host is currently ON
+st=$(busctl get-property xyz.openbmc_project.State.Host \
+ /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host \
+ CurrentHostState | cut -d"." -f6)
+if [ "$st" == "Running\"" ]; then
+ exit 0
fi
# Time out to check S0_FW_BOOT_OK is 60 seconds
cnt=60
val=0
-while [ $cnt -gt 0 ];
+while [ "$cnt" -gt 0 ];
do
- val=$(gpio_get_val $S0_CPU_FW_BOOT_OK)
- cnt=$((cnt - 1))
- echo "$cnt S0_CPU_FW_BOOT_OK = $val"
- if [ $val == 1 ]; then
- # Sleep 5 second before the host is ready
- sleep 5
- if [ $createFile == 1 ]; then
- if [ ! -d "/run/openbmc" ]; then
- mkdir -p /run/openbmc
- fi
- echo "Creating /run/openbmc/host@0-on"
- touch /run/openbmc/host@0-on
- fi
- exit 0
- fi
- sleep 1
+ val=$(gpio_get_val "$S0_CPU_FW_BOOT_OK")
+ cnt=$((cnt - 1))
+ echo "$cnt S0_CPU_FW_BOOT_OK = $val"
+ if [ "$val" == 1 ]; then
+ # Sleep 5 second before the host is ready
+ sleep 5
+ if [ "$createFile" == 1 ]; then
+ mkdir -p /run/openbmc
+ echo "Creating /run/openbmc/host@0-on"
+ touch /run/openbmc/host@0-on
+ fi
+ exit 0
+ fi
+ sleep 1
done
exit 1
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh
index 2c8ba3d91..d9ca2ed08 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh
@@ -1,131 +1,120 @@
#!/bin/bash
-#ampere_platform_config.sh is platform configuration file
+
+# shellcheck source=/dev/null
source /usr/sbin/gpio-defs.sh
# Usage of this utility
function usage() {
- echo "usage: power-util mb [status|shutdown_ack|force_reset|soft_off]";
+ echo "Usage:"
+ echo " ampere_power_util.sh mb [status|shutdown_ack|force_reset|soft_off]";
}
power_status() {
- st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6)
- if [ "$st" == "On\"" ]; then
- echo "on"
- else
- echo "off"
- fi
+ st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6)
+ if [ "$st" == "On\"" ]; then
+ echo "on"
+ else
+ echo "off"
+ fi
}
shutdown_ack() {
- if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
- echo "Receive shutdown ACK triggered after softportoff the host."
- touch /run/openbmc/host@0-softpoweroff-shutdown-ack
- else
- echo "Receive shutdown ACK triggered"
- sleep 3
- systemctl start obmc-chassis-poweroff@0.target
- fi
+ if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
+ echo "Receive shutdown ACK triggered after softportoff the host."
+ touch /run/openbmc/host@0-softpoweroff-shutdown-ack
+ else
+ echo "Receive shutdown ACK triggered"
+ sleep 3
+ systemctl start obmc-chassis-poweroff@0.target
+ fi
}
soft_off() {
- # Trigger shutdown_req
- touch /run/openbmc/host@0-softpoweroff
- gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=1
- sleep 1s
- gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=0
+ # Trigger shutdown_req
+ touch /run/openbmc/host@0-softpoweroff
+ gpioset -l 0 "$S0_SHD_REQ_L"=1
+ sleep 1s
+ gpioset -l 0 "$S0_SHD_REQ_L"=0
- # Wait for shutdown_ack from the host in 30 seconds
- cnt=30
- while [ $cnt -gt 0 ];
- do
- # Wait for SHUTDOWN_ACK and create the host@0-softpoweroff-shutdown-ack
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- break
- fi
- sleep 1
- cnt=$((cnt - 1))
- done
- # Softpoweroff is successed
- sleep 2
- rm -rf /run/openbmc/host@0-softpoweroff
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- rm -rf /run/openbmc/host@0-softpoweroff-shutdown-ack
- fi
- echo 0
+ # Wait for shutdown_ack from the host in 30 seconds
+ cnt=30
+ while [ $cnt -gt 0 ];
+ do
+ # Wait for SHUTDOWN_ACK and create the host@0-softpoweroff-shutdown-ack
+ if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
+ break
+ fi
+ sleep 1
+ cnt=$((cnt - 1))
+ done
+ # Softpoweroff is successed
+ sleep 2
+ rm -rf /run/openbmc/host@0-softpoweroff
+ if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
+ rm -rf /run/openbmc/host@0-softpoweroff-shutdown-ack
+ fi
+ echo 0
}
force_reset() {
- if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
- # In graceful host reset, after trigger os shutdown,
- # the phosphor-state-manager will call force-warm-reset
- # in this case the force_reset should wait for shutdown_ack from host
- cnt=30
- while [ $cnt -gt 0 ];
- do
- if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
- break
- fi
- echo "Waiting for shutdown-ack count down $cnt"
- sleep 1
- cnt=$((cnt - 1))
- done
- # The host OS is failed to shutdown
- if [ $cnt == 0 ]; then
- echo "Shutdown-ack time out after 30s."
- exit 0
- fi
- fi
- echo "Triggering sysreset pin"
- gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=1
- sleep 1
- gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=0
+ if [ -f "/run/openbmc/host@0-softpoweroff" ]; then
+ # In graceful host reset, after trigger os shutdown,
+ # the phosphor-state-manager will call force-warm-reset
+ # in this case the force_reset should wait for shutdown_ack from host
+ cnt=30
+ while [ $cnt -gt 0 ];
+ do
+ if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then
+ break
+ fi
+ echo "Waiting for shutdown-ack count down $cnt"
+ sleep 1
+ cnt=$((cnt - 1))
+ done
+ # The host OS is failed to shutdown
+ if [ $cnt == 0 ]; then
+ echo "Shutdown-ack time out after 30s."
+ exit 0
+ fi
+ fi
+ echo "Triggering sysreset pin"
+ gpioset -l 0 "$S0_SYSRESET_L"=1
+ sleep 1
+ gpioset -l 0 "$S0_SYSRESET_L"=0
}
if [ $# -lt 2 ]; then
- echo "Total number of parameter=$#"
- echo "Insufficient parameter"
- usage;
- exit 0;
+ echo "Total number of parameter=$#"
+ echo "Insufficient parameter"
+ usage;
+ exit 0;
fi
-if [ $1 != "mb" ]; then
- echo "Invalid parameter1=$1"
- usage;
- exit 0;
+if [ "$1" != "mb" ]; then
+ echo "Invalid parameter1=$1"
+ usage;
+ exit 0;
fi
-# check if power guard enabled
-dir="/run/systemd/system/"
-file="reboot-guard.conf"
-units=("reboot" "poweroff" "halt")
-for unit in "${units[@]}"; do
- if [ -f ${dir}${unit}.target.d/${file} ]; then
- echo "PowerGuard enabled, cannot do power control, exit!!!"
- exit -1
- fi
-done
-
-if [ ! -d "/run/openbmc/" ]; then
- mkdir -p "/run/openbmc/"
-fi
+mkdir -p /run/openbmc/
-if [ $2 == "shutdown_ack" ]; then
- shutdown_ack
-elif [ $2 == "status" ]; then
- power_status
-elif [ $2 == "force_reset" ]; then
- force_reset
-elif [ $2 == "soft_off" ]; then
- ret=$(soft_off)
- if [ $ret == 0 ]; then
- echo "The host is already softoff"
- else
- echo "Failed to softoff the host"
- fi
- exit $ret;
+if [ "$2" == "shutdown_ack" ]; then
+ shutdown_ack
+elif [ "$2" == "status" ]; then
+ power_status
+elif [ "$2" == "force_reset" ]; then
+ force_reset
+elif [ "$2" == "soft_off" ]; then
+ ret=$(soft_off)
+ if [ "$ret" == 0 ]; then
+ echo "The host is already softoff"
+ else
+ echo "Failed to softoff the host"
+ fi
+ exit "$ret";
else
- echo "Invalid parameter2=$2"
- usage;
+ echo "Invalid parameter2=$2"
+ usage;
fi
exit 0;
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh
index 7c887d409..fc0edd6fc 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh
@@ -1,3 +1,6 @@
+#!/bin/sh
+
+# shellcheck disable=SC2034
# Index of GPIO device in gpioget/gpioset
GPIO_CHIP0_IDX=0
GPIO_CHIP1_IDX=1
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
index 8d1aa61d7..c8721fe97 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
@@ -1,31 +1,33 @@
#!/bin/bash
+
+# shellcheck source=/dev/null
source /usr/sbin/gpio-defs.sh
function gpio_number() {
- GPIO_BASE=$(cat /sys/class/gpio/gpiochip$GPIO_CHIP0_BASE/base)
- echo $((${GPIO_BASE} + $1))
+ GPIO_BASE=$(cat /sys/class/gpio/gpiochip"$GPIO_CHIP0_BASE"/base)
+ echo $((GPIO_BASE + $1))
}
# 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
+ 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
}
function gpio_get_val() {
- gpioId=$(gpio_number $1)
- echo $gpioId > /sys/class/gpio/export
- echo $(cat /sys/class/gpio/gpio$gpioId/value)
- echo $gpioId > /sys/class/gpio/unexport
+ gpioId=$(gpio_number "$1")
+ echo "$gpioId" > /sys/class/gpio/export
+ cat /sys/class/gpio/gpio"$gpioId"/value
+ echo "$gpioId" > /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
+ gpioId=$(gpio_number "$1")
+ echo "$gpioId" > /sys/class/gpio/export
+ echo "in" > /sys/class/gpio/gpio"${gpioId}"/direction
+ echo "$gpioId" > /sys/class/gpio/unexport
}
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0001-aspeed-scu-Switch-PWM-pin-to-GPIO-input-mode.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0001-aspeed-scu-Switch-PWM-pin-to-GPIO-input-mode.patch
deleted file mode 100644
index b714be4c6..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0001-aspeed-scu-Switch-PWM-pin-to-GPIO-input-mode.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From 03dcf584823b8b7db7d437257dbb45bd4b7f95b4 Mon Sep 17 00:00:00 2001
-From: Chanh Nguyen <chnguyen@amperecomputing.com>
-Date: Mon, 21 Dec 2020 07:01:14 +0000
-Subject: [PATCH] aspeed/scu : Switch PWM pin to GPIO input mode
-
-In hardware design, the PWM pins will be at a high level if they are
-configured in GPIO Input mode. This commit configures all PWM function
-pins to input GPIO mode. This will allow fans to run at full speed when BMC resets or in U-boot.
-
-Signed-off-by: Chanh Nguyen <chnguyen@amperecomputing.com>
----
- arch/arm/include/asm/arch-aspeed/ast_scu.h | 1 +
- arch/arm/mach-aspeed/ast-scu.c | 12 ++++++++++++
- board/aspeed/ast-g5/ast-g5.c | 10 ++++++++++
- include/configs/ast-g5-phy.h | 3 +++
- 4 files changed, 26 insertions(+)
-
-diff --git a/arch/arm/include/asm/arch-aspeed/ast_scu.h b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-index dcbc6730d4..d2c010a0dc 100644
---- a/arch/arm/include/asm/arch-aspeed/ast_scu.h
-+++ b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-@@ -45,5 +45,6 @@ extern u32 ast_scu_get_vga_memsize(void);
- extern void ast_scu_init_eth(u8 num);
- extern void ast_scu_multi_func_eth(u8 num);
- extern void ast_scu_multi_func_romcs(u8 num);
-+extern void ast_scu_switch_pwm_to_gpio_mode(void);
-
- #endif
-diff --git a/arch/arm/mach-aspeed/ast-scu.c b/arch/arm/mach-aspeed/ast-scu.c
-index 12de9b8036..ef90ef3805 100644
---- a/arch/arm/mach-aspeed/ast-scu.c
-+++ b/arch/arm/mach-aspeed/ast-scu.c
-@@ -443,6 +443,18 @@ void ast_scu_multi_func_eth(u8 num)
- }
- }
-
-+void ast_scu_switch_pwm_to_gpio_mode(void)
-+{
-+ ast_scu_write(ast_scu_read(AST_SCU_FUN_PIN_CTRL3) &
-+ ~SCU_FUN_PIN_VPIG2 &
-+ ~SCU_FUN_PIN_VPIG3 &
-+ ~SCU_FUN_PIN_VPIG4 &
-+ ~SCU_FUN_PIN_VPIG5 &
-+ ~SCU_FUN_PIN_VPIG6 &
-+ ~SCU_FUN_PIN_VPIG7,
-+ AST_SCU_FUN_PIN_CTRL3);
-+}
-+
- void ast_scu_multi_func_romcs(u8 num)
- {
- ast_scu_write(ast_scu_read(AST_SCU_FUN_PIN_CTRL3) |
-diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index e67a4bf8b2..fba22a728e 100644
---- a/board/aspeed/ast-g5/ast-g5.c
-+++ b/board/aspeed/ast-g5/ast-g5.c
-@@ -24,6 +24,16 @@ int board_init(void)
- return 0;
- }
-
-+#ifdef CONFIG_BOARD_LATE_INIT
-+int board_late_init(void)
-+{
-+ /* Switch PWM to GPIO mode to make FAN run in max speed */
-+ ast_scu_switch_pwm_to_gpio_mode();
-+
-+ return 0;
-+}
-+#endif
-+
- int dram_init(void)
- {
- u32 vga = ast_scu_get_vga_memsize();
-diff --git a/include/configs/ast-g5-phy.h b/include/configs/ast-g5-phy.h
-index 62ddb841e5..5443a26cab 100644
---- a/include/configs/ast-g5-phy.h
-+++ b/include/configs/ast-g5-phy.h
-@@ -30,4 +30,7 @@
- /* platform.S */
- #define CONFIG_DRAM_ECC_SIZE 0x10000000
-
-+/* Call board_late_init */
-+#define CONFIG_BOARD_LATE_INIT 1
-+
- #endif /* __AST_G5_PHY_CONFIG_H */
---
-2.25.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0002-aspeed-Disable-internal-PD-resistors-for-GPIOs.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0002-aspeed-Disable-internal-PD-resistors-for-GPIOs.patch
deleted file mode 100644
index 249d4398f..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0002-aspeed-Disable-internal-PD-resistors-for-GPIOs.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From c6e0470d82417b79b23f218c6db1099eb6e160af Mon Sep 17 00:00:00 2001
-From: "Thang Q. Nguyen" <thang@os.amperecomputing.com>
-Date: Wed, 23 Dec 2020 04:42:21 +0000
-Subject: [PATCH] aspeed: Disable internal PD resistors for GPIOs
-
-Configure SCU8C - Multi-function pin control 4 to disable internal pull
-down resistors for GPIOJ, GPIOG/GPIOAB, GPIOD/GPIOY, GPIOC/GPIOS as
-external resistors are already installed.
-
-Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
----
- board/aspeed/ast-g5/ast-g5.c | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
-
-diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index fba22a728e..9bf6c905fe 100644
---- a/board/aspeed/ast-g5/ast-g5.c
-+++ b/board/aspeed/ast-g5/ast-g5.c
-@@ -27,9 +27,23 @@ int board_init(void)
- #ifdef CONFIG_BOARD_LATE_INIT
- int board_late_init(void)
- {
-+ u32 val;
-+
- /* Switch PWM to GPIO mode to make FAN run in max speed */
- ast_scu_switch_pwm_to_gpio_mode();
-
-+ /*
-+ * Disable internal pull down resistor for GPIOJ,
-+ * GPIOG/GPIOAB, GPIOD/GPIOY, GPIOC/GPIOS as external pull up/down
-+ * resistors are installed already. Unlock SCU regs before writing.
-+ */
-+ writel(SCU_PROTECT_UNLOCK, AST_SCU_BASE);
-+ val = readl(AST_SCU_BASE + AST_SCU_FUN_PIN_CTRL4) | 0x024C0000;
-+ writel(val, AST_SCU_BASE + AST_SCU_FUN_PIN_CTRL4);
-+#ifdef CONFIG_AST_SCU_LOCK
-+ writel(0xaa, AST_SCU_BASE);
-+#endif
-+
- return 0;
- }
- #endif
---
-2.25.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0003-aspeed-support-passing-system-reset-status-to-kernel.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0003-aspeed-support-passing-system-reset-status-to-kernel.patch
deleted file mode 100644
index 0381b5d84..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0003-aspeed-support-passing-system-reset-status-to-kernel.patch
+++ /dev/null
@@ -1,180 +0,0 @@
-From af4353ab19aaf29dc68ff89a0d581102ca5be43c Mon Sep 17 00:00:00 2001
-From: "Thang Q. Nguyen" <thang@os.amperecomputing.com>
-Date: Wed, 6 Jan 2021 06:33:36 +0000
-Subject: [PATCH] aspeed: support passing system reset status to kernel via
- bootargs
-
-This is a backport of the patch file from
-openbmc/meta-yadro/meta-nicole/recipes-bsp/u-boot/
-to add the Aspeed reset reason to bootargs so kernel applications
-can query it.
-
-Test case: /proc/cmdline must contain:
- - resetreason=power after cold bmc boot
- - resetreason=watchdog after warm bmc reboot
-
-Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
-Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
----
- arch/arm/include/asm/arch-aspeed/ast_scu.h | 2 +-
- arch/arm/mach-aspeed/ast-scu.c | 6 +-
- board/aspeed/ast-g5/ast-g5.c | 81 ++++++++++++++++++++++
- 3 files changed, 87 insertions(+), 2 deletions(-)
-
-diff --git a/arch/arm/include/asm/arch-aspeed/ast_scu.h b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-index d2c010a0dc..f5c9126ec0 100644
---- a/arch/arm/include/asm/arch-aspeed/ast_scu.h
-+++ b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-@@ -29,7 +29,7 @@
- #define __AST_SCU_H
-
- extern void ast_scu_show_system_info (void);
--extern void ast_scu_sys_rest_info(void);
-+extern u32 ast_scu_sys_rest_info(void);
- extern void ast_scu_security_info(void);
- extern u32 ast_scu_revision_id(void);
- extern u32 ast_scu_get_vga_memsize(void);
-diff --git a/arch/arm/mach-aspeed/ast-scu.c b/arch/arm/mach-aspeed/ast-scu.c
-index ef90ef3805..c7ab66415f 100644
---- a/arch/arm/mach-aspeed/ast-scu.c
-+++ b/arch/arm/mach-aspeed/ast-scu.c
-@@ -494,22 +494,26 @@ void ast_scu_security_info(void)
- }
- }
-
--void ast_scu_sys_rest_info(void)
-+u32 ast_scu_sys_rest_info(void)
- {
- u32 rest = ast_scu_read(AST_SCU_SYS_CTRL);
-
- if (rest & SCU_SYS_EXT_RESET_FLAG) {
- printf("RST : External\n");
- ast_scu_write(SCU_SYS_EXT_RESET_FLAG, AST_SCU_SYS_CTRL);
-+ rest = SCU_SYS_EXT_RESET_FLAG;
- } else if (rest & SCU_SYS_WDT_RESET_FLAG) {
- printf("RST : Watchdog\n");
- ast_scu_write(SCU_SYS_WDT_RESET_FLAG, AST_SCU_SYS_CTRL);
-+ rest = SCU_SYS_WDT_RESET_FLAG;
- } else if (rest & SCU_SYS_PWR_RESET_FLAG) {
- printf("RST : Power On\n");
- ast_scu_write(SCU_SYS_PWR_RESET_FLAG, AST_SCU_SYS_CTRL);
-+ rest = SCU_SYS_PWR_RESET_FLAG;
- } else {
- printf("RST : CLK en\n");
- }
-+ return rest;
- }
-
- u32 ast_scu_get_vga_memsize(void)
-diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index 9bf6c905fe..9e27bce0f5 100644
---- a/board/aspeed/ast-g5/ast-g5.c
-+++ b/board/aspeed/ast-g5/ast-g5.c
-@@ -8,6 +8,8 @@
- */
-
- #include <common.h>
-+#include <stdlib.h>
-+#include <asm/arch/regs-scu.h>
- #include <netdev.h>
-
- #include <asm/arch/ast_scu.h>
-@@ -25,9 +27,76 @@ int board_init(void)
- }
-
- #ifdef CONFIG_BOARD_LATE_INIT
-+static void update_bootargs_cmd(const char *key, const char *value)
-+{
-+ int buf_len;
-+ char *buf;
-+ char *cmdline;
-+ char *end = NULL;
-+
-+ if (!key || (key[0] == '\0')) {
-+ printf("%s: Empty key not allowed\n", __func__);
-+ return;
-+ }
-+
-+ cmdline = getenv("bootargs");
-+
-+ /* Allocate space for maximum possible new command line */
-+ buf_len = (cmdline ? strlen(cmdline) : 0)
-+ + 1 /* spacebar as delimiter */
-+ + strlen(key)
-+ + (value ? 1 /* equal sign */ + strlen(value) : 0)
-+ + 1 /* terminating null */;
-+
-+ buf = calloc(buf_len, sizeof(char));
-+ if (!buf) {
-+ printf("%s: out of memory\n", __func__);
-+ return;
-+ }
-+
-+ if (cmdline)
-+ {
-+ char *start = strstr(cmdline, key);
-+
-+ /* Check for full word match. Match should be start of cmdline
-+ * or there should be space before match
-+ **/
-+ if (start && ((start == cmdline) || (*(start - 1) == ' '))) {
-+ strncat(buf, cmdline, (start - cmdline));
-+
-+ /* Find the end of the keyword[=value] pair,
-+ * including a single training space character, if any.
-+ * Skip the found substring, mark the tail of cmdline.
-+ **/
-+ end = strchr(start, ' ');
-+ if (end) {
-+ end++;
-+ }
-+ } else {
-+ strcat(buf, cmdline);
-+ strcat(buf, " ");
-+ }
-+ }
-+
-+ strcat(buf, key);
-+ if (value) {
-+ strcat(buf, "=");
-+ strcat(buf, value);
-+ }
-+
-+ if (end) {
-+ strcat(buf, " ");
-+ strcat(buf, end);
-+ }
-+
-+ setenv("bootargs", buf);
-+ free(buf);
-+}
-+
- int board_late_init(void)
- {
- u32 val;
-+ u32 reset_reason = ast_scu_sys_rest_info();
-
- /* Switch PWM to GPIO mode to make FAN run in max speed */
- ast_scu_switch_pwm_to_gpio_mode();
-@@ -44,6 +113,18 @@ int board_late_init(void)
- writel(0xaa, AST_SCU_BASE);
- #endif
-
-+ if (reset_reason & SCU_SYS_EXT_RESET_FLAG) {
-+ update_bootargs_cmd("resetreason", "external");
-+ } else if (reset_reason & SCU_SYS_WDT_RESET_FLAG) {
-+ update_bootargs_cmd("resetreason", "watchdog");
-+ } else if (reset_reason & SCU_SYS_PWR_RESET_FLAG) {
-+ update_bootargs_cmd("resetreason", "power");
-+ } else {
-+ char value[32];
-+ snprintf(value, sizeof(value) - 1, "0x%x", reset_reason);
-+ update_bootargs_cmd("resetreason", value);
-+ }
-+
- return 0;
- }
- #endif
---
-2.25.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0004-aspeed-add-gpio-support.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0004-aspeed-add-gpio-support.patch
deleted file mode 100644
index 2f8ff45bd..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0004-aspeed-add-gpio-support.patch
+++ /dev/null
@@ -1,518 +0,0 @@
-From 7372552ae247e4870fb6dc80df7610f86d736a57 Mon Sep 17 00:00:00 2001
-From: Chanh Nguyen <chanh@os.amperecomputing.com>
-Date: Tue, 9 Mar 2021 11:04:56 +0700
-Subject: [PATCH] aspeed: add gpio support
-
-This is an initial support for the parallel GPIO pins directly connected
-to the AHB on the Aspeed 2400/2500.
-
-This brings the functions and a shell command to manipulate the GPIO
-state. The GPIO value reading and writing work in non interrupt mode
-only.
-
-This is back ported from the patch file from
-meta-yadro/meta-nicole/recipes-bsp/u-boot/files/0003-aspeed-add-gpio-support.patch
-to support GPIO configuration
-
-Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
-Signed-off-by: Thang Q. Nguyen <thangqn@amperecomputing.com>
-Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
----
- arch/arm/include/asm/arch-aspeed/gpio.h | 65 ++++
- drivers/gpio/Makefile | 2 +
- drivers/gpio/aspeed_gpio.c | 386 ++++++++++++++++++++++++
- include/configs/ast-g5-phy.h | 1 +
- 4 files changed, 454 insertions(+)
- create mode 100644 arch/arm/include/asm/arch-aspeed/gpio.h
- create mode 100644 drivers/gpio/aspeed_gpio.c
-
-diff --git a/arch/arm/include/asm/arch-aspeed/gpio.h b/arch/arm/include/asm/arch-aspeed/gpio.h
-new file mode 100644
-index 0000000000..c63987e917
---- /dev/null
-+++ b/arch/arm/include/asm/arch-aspeed/gpio.h
-@@ -0,0 +1,65 @@
-+/*
-+ * SPDX-License-Identifier: GPL-2.0+
-+ * Copyright (C) 2020 YADRO.
-+ */
-+#ifndef _ASPEED_GPIO_H
-+#define _ASPEED_GPIO_H
-+
-+#define ASPEED_GPIO_PORT_A 0
-+#define ASPEED_GPIO_PORT_B 1
-+#define ASPEED_GPIO_PORT_C 2
-+#define ASPEED_GPIO_PORT_D 3
-+#define ASPEED_GPIO_PORT_E 4
-+#define ASPEED_GPIO_PORT_F 5
-+#define ASPEED_GPIO_PORT_G 6
-+#define ASPEED_GPIO_PORT_H 7
-+#define ASPEED_GPIO_PORT_I 8
-+#define ASPEED_GPIO_PORT_J 9
-+#define ASPEED_GPIO_PORT_K 10
-+#define ASPEED_GPIO_PORT_L 11
-+#define ASPEED_GPIO_PORT_M 12
-+#define ASPEED_GPIO_PORT_N 13
-+#define ASPEED_GPIO_PORT_O 14
-+#define ASPEED_GPIO_PORT_P 15
-+#define ASPEED_GPIO_PORT_Q 16
-+#define ASPEED_GPIO_PORT_R 17
-+#define ASPEED_GPIO_PORT_S 18
-+#define ASPEED_GPIO_PORT_T 19
-+#define ASPEED_GPIO_PORT_U 20
-+#define ASPEED_GPIO_PORT_V 21
-+#define ASPEED_GPIO_PORT_W 22
-+#define ASPEED_GPIO_PORT_X 23
-+#define ASPEED_GPIO_PORT_Y 24
-+#define ASPEED_GPIO_PORT_Z 25
-+#define ASPEED_GPIO_PORT_AA 26
-+#define ASPEED_GPIO_PORT_AB 27
-+#define ASPEED_GPIO_PORT_AC 28
-+
-+#define ASPEED_GPIO_PORT_SHIFT 3
-+#define ASPEED_GPIO_PIN_MASK 0x7
-+#define ASPEED_GPIO(port, pin) \
-+ ((ASPEED_GPIO_PORT_##port << ASPEED_GPIO_PORT_SHIFT) | \
-+ (pin & ASPEED_GPIO_PIN_MASK))
-+
-+/* Direction values */
-+#define ASPEED_GPIO_INPUT 0
-+#define ASPEED_GPIO_OUTPUT 1
-+
-+/* Trigger values */
-+#define ASPEED_GPIO_FALLING_EDGE 0
-+#define ASPEED_GPIO_RISING_EDGE 1
-+#define ASPEED_GPIO_LOW_LEVEL 2
-+#define ASPEED_GPIO_HIGH_LEVEL 3
-+#define ASPEED_GPIO_DUAL_EDGE 4
-+
-+/* Debounce values */
-+#define ASPEED_GPIO_DEBOUNCE_NONE 0
-+#define ASPEED_GPIO_DEBOUNCE_1 1
-+#define ASPEED_GPIO_DEBOUNCE_2 2
-+#define ASPEED_GPIO_DEBOUNCE_3 3
-+
-+#define gpio_status() gpio_info()
-+
-+extern void gpio_info(void);
-+
-+#endif /* #ifndef _ASPEED_GPIO_H */
-diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
-index 792d19186a..5f043e07ce 100644
---- a/drivers/gpio/Makefile
-+++ b/drivers/gpio/Makefile
-@@ -14,6 +14,8 @@ obj-$(CONFIG_DM_GPIO) += gpio-uclass.o
- obj-$(CONFIG_DM_PCA953X) += pca953x_gpio.o
- obj-$(CONFIG_DM_74X164) += 74x164_gpio.o
-
-+obj-$(CONFIG_ARCH_AST2400) += aspeed_gpio.o
-+obj-$(CONFIG_ARCH_AST2500) += aspeed_gpio.o
- obj-$(CONFIG_AT91_GPIO) += at91_gpio.o
- obj-$(CONFIG_ATMEL_PIO4) += atmel_pio4.o
- obj-$(CONFIG_INTEL_ICH6_GPIO) += intel_ich6_gpio.o
-diff --git a/drivers/gpio/aspeed_gpio.c b/drivers/gpio/aspeed_gpio.c
-new file mode 100644
-index 0000000000..dc07f5a520
---- /dev/null
-+++ b/drivers/gpio/aspeed_gpio.c
-@@ -0,0 +1,386 @@
-+/*
-+ * SPDX-License-Identifier: GPL-2.0+
-+ * Copyright (C) 2020 YADRO.
-+ */
-+
-+#include <common.h>
-+
-+#include <asm/arch/gpio.h>
-+#include <asm/arch/platform.h>
-+#include <asm/io.h>
-+#include <linux/ctype.h>
-+
-+typedef struct _ast_gpio_regs
-+{
-+ uint32_t base; /* data and direction registers */
-+ uint32_t intcfg; /* interrupt config */
-+ uint32_t debounce; /* debounce config */
-+ uint32_t cmdsrc; /* command source config */
-+ uint32_t data; /* data read register */
-+} ast_gpio_regs_t;
-+
-+static ast_gpio_regs_t ast_gpio_regs[] = {
-+ /* A/B/C/D */
-+ {AST_GPIO_BASE + 0x0000, AST_GPIO_BASE + 0x0008, AST_GPIO_BASE + 0x0040,
-+ AST_GPIO_BASE + 0x0060, AST_GPIO_BASE + 0x00C0},
-+ /* E/F/G/H */
-+ {AST_GPIO_BASE + 0x0020, AST_GPIO_BASE + 0x0028, AST_GPIO_BASE + 0x0048,
-+ AST_GPIO_BASE + 0x0068, AST_GPIO_BASE + 0x00C4},
-+ /* I/J/K/L */
-+ {AST_GPIO_BASE + 0x0070, AST_GPIO_BASE + 0x0098, AST_GPIO_BASE + 0x00B0,
-+ AST_GPIO_BASE + 0x0090, AST_GPIO_BASE + 0x00C8},
-+ /* M/N/O/P */
-+ {AST_GPIO_BASE + 0x0078, AST_GPIO_BASE + 0x00E8, AST_GPIO_BASE + 0x0100,
-+ AST_GPIO_BASE + 0x00E0, AST_GPIO_BASE + 0x00CC},
-+ /* Q/R/S/T */
-+ {AST_GPIO_BASE + 0x0080, AST_GPIO_BASE + 0x0118, AST_GPIO_BASE + 0x0130,
-+ AST_GPIO_BASE + 0x0110, AST_GPIO_BASE + 0x00D0},
-+ /* U/V/W/X */
-+ {AST_GPIO_BASE + 0x0088, AST_GPIO_BASE + 0x0148, AST_GPIO_BASE + 0x0160,
-+ AST_GPIO_BASE + 0x0140, AST_GPIO_BASE + 0x00D4},
-+ /* Y/Z/AA/AB */
-+ {AST_GPIO_BASE + 0x01E0, AST_GPIO_BASE + 0x0178, AST_GPIO_BASE + 0x0190,
-+ AST_GPIO_BASE + 0x0170, AST_GPIO_BASE + 0x00D8},
-+ /* AC */
-+ {AST_GPIO_BASE + 0x01E8, AST_GPIO_BASE + 0x01A8, AST_GPIO_BASE + 0x01C0,
-+ AST_GPIO_BASE + 0x01A0, AST_GPIO_BASE + 0x00DC},
-+};
-+
-+#define AST_GPIO_PINS_PER_PORT 8
-+#define AST_GPIO_PORTS_PER_REGISTER 4
-+
-+#define AST_GPIO_PORT(gpio) (gpio >> ASPEED_GPIO_PORT_SHIFT)
-+#define AST_GPIO_PIN(gpio) (gpio & ASPEED_GPIO_PIN_MASK)
-+#define AST_GPIO_SHIFT(gpio) \
-+ ((AST_GPIO_PORT(gpio) % AST_GPIO_PORTS_PER_REGISTER) * \
-+ AST_GPIO_PINS_PER_PORT + \
-+ AST_GPIO_PIN(gpio))
-+
-+#define AST_GPIO_REG_INDEX(gpio) \
-+ (AST_GPIO_PORT(gpio) / AST_GPIO_PORTS_PER_REGISTER)
-+
-+/**
-+ * @return Pointer to corresponding item from ast_gpio_regs table.
-+ */
-+#define AST_GPIO_REGS(gpio) \
-+ ((AST_GPIO_REG_INDEX(gpio) < ARRAY_SIZE(ast_gpio_regs)) \
-+ ? (ast_gpio_regs + AST_GPIO_REG_INDEX(gpio)) \
-+ : NULL)
-+
-+/**
-+ * @brief Set a corresponding bit in specified register.
-+ *
-+ * @param val - Required bit value
-+ * @param base - Register address
-+ * @param shift - Bit index.
-+ */
-+#define AST_GPIO_WRITE(val, base, shift) \
-+ writel(((val) ? readl(base) | (1 << (shift)) \
-+ : readl(base) & ~(1 << (shift))), \
-+ base)
-+
-+/**
-+ * @brief Get value of corresponging bit from specified register.
-+ *
-+ * @param base - Register address
-+ * @param shift - Bit index
-+ *
-+ * @return Bit value
-+ */
-+#define AST_GPIO_READ(base, shift) ((readl(base) >> (shift)) & 1)
-+
-+#define IS_VALID_GPIO(gpio) \
-+ ((gpio) >= ASPEED_GPIO(A, 0) && (gpio) <= ASPEED_GPIO(AC, 7))
-+
-+#define AST_GPIO_DIRECTION 0x04
-+#define AST_GPIO_INT_SENS0 0x04
-+#define AST_GPIO_INT_SENS1 0x08
-+#define AST_GPIO_INT_SENS2 0x0C
-+#define AST_GPIO_INT_STATUS 0x10
-+#define AST_GPIO_DEBOUNCE0 0x00
-+#define AST_GPIO_DEBOUNCE1 0x04
-+#define AST_GPIO_CMD_SRC0 0x00
-+#define AST_GPIO_CMD_SRC1 0x04
-+
-+/**
-+ * @brief Set a GPIO direction
-+ *
-+ * @param gpio GPIO line
-+ * @param direction GPIO direction (0 for input or 1 for output)
-+ *
-+ * @return 0 if ok, -1 on error
-+ */
-+static int ast_gpio_set_direction(unsigned gpio, unsigned direction)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (!regs)
-+ {
-+ printf("%s: Invalid GPIO!\n", __func__);
-+ return -1;
-+ }
-+
-+ AST_GPIO_WRITE(direction, regs->base + AST_GPIO_DIRECTION,
-+ AST_GPIO_SHIFT(gpio));
-+ return 0;
-+}
-+
-+/**
-+ * The 6 following functions are generic u-boot gpio implementation.
-+ * They are declared in `include/asm-generic/gpio.h`
-+ */
-+
-+int gpio_request(unsigned gpio, const char *label)
-+{
-+ return (IS_VALID_GPIO(gpio) ? 0 : -1);
-+}
-+
-+int gpio_free(unsigned gpio)
-+{
-+ return (IS_VALID_GPIO(gpio) ? 0 : -1);
-+}
-+
-+int gpio_get_value(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (!regs)
-+ {
-+ printf("%s: Invalid GPIO!\n", __func__);
-+ return -1;
-+ }
-+
-+ return AST_GPIO_READ(regs->base, AST_GPIO_SHIFT(gpio));
-+}
-+
-+int gpio_set_value(unsigned gpio, int value)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (!regs)
-+ {
-+ printf("%s: Invalid GPIO!\n", __func__);
-+ return -1;
-+ }
-+
-+ AST_GPIO_WRITE(value, regs->base, AST_GPIO_SHIFT(gpio));
-+ return 0;
-+}
-+
-+int gpio_direction_input(unsigned gpio)
-+{
-+ return ast_gpio_set_direction(gpio, ASPEED_GPIO_INPUT);
-+}
-+
-+int gpio_direction_output(unsigned gpio, int value)
-+{
-+ int rc = ast_gpio_set_direction(gpio, ASPEED_GPIO_OUTPUT);
-+ return (rc == 0 ? gpio_set_value(gpio, value) : rc);
-+}
-+
-+/**
-+ * @brief Convert a string to GPIO line. Used by `do_gpio()` from `cmd/gpio.c`
-+ *
-+ * @param str a GPIO name or line number
-+ *
-+ * @return GPIO line if ok, -1 on error
-+ */
-+int name_to_gpio(const char *str)
-+{
-+ int gpio = -1;
-+
-+ if (str)
-+ {
-+ if (isalpha(*str))
-+ {
-+ gpio = (toupper(*str) - 'A') << ASPEED_GPIO_PORT_SHIFT;
-+
-+ if (toupper(*str) == 'A' && toupper(*(str + 1)) >= 'A' &&
-+ toupper(*(str + 1)) <= 'C')
-+ {
-+ str++;
-+ gpio = (ASPEED_GPIO_PORT_AA + toupper(*str) - 'A')
-+ << ASPEED_GPIO_PORT_SHIFT;
-+ }
-+
-+ str++;
-+ if (*str >= '0' && *str <= '7' && !*(str + 1))
-+ {
-+ gpio += *str - '0';
-+ }
-+ else
-+ {
-+ gpio = -1;
-+ }
-+ }
-+ else if (isdigit(*str))
-+ {
-+ gpio = simple_strtoul(str, NULL, 0);
-+ }
-+ }
-+
-+ return gpio;
-+}
-+
-+/**
-+ * @return A GPIO direction in human readable format.
-+ */
-+static const char *ast_gpio_direction(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (regs)
-+ {
-+ int direction = AST_GPIO_READ(regs->base + AST_GPIO_DIRECTION,
-+ AST_GPIO_SHIFT(gpio));
-+ switch (direction)
-+ {
-+ case ASPEED_GPIO_INPUT:
-+ return "input";
-+ case ASPEED_GPIO_OUTPUT:
-+ return "output";
-+ default:
-+ break;
-+ }
-+ }
-+ return "error";
-+}
-+
-+/**
-+ * @return An interrupt trigger settings in human readable format.
-+ */
-+static const char *ast_gpio_trigger(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (regs)
-+ {
-+ unsigned shift = AST_GPIO_SHIFT(gpio);
-+ unsigned trigger =
-+ (AST_GPIO_READ(regs->intcfg + AST_GPIO_INT_SENS0, shift) << 0) |
-+ (AST_GPIO_READ(regs->intcfg + AST_GPIO_INT_SENS1, shift) << 1) |
-+ (AST_GPIO_READ(regs->intcfg + AST_GPIO_INT_SENS2, shift) << 2);
-+
-+ switch (trigger)
-+ {
-+ case ASPEED_GPIO_FALLING_EDGE:
-+ return "fall";
-+ case ASPEED_GPIO_RISING_EDGE:
-+ return "rise";
-+ case ASPEED_GPIO_LOW_LEVEL:
-+ return "low ";
-+ case ASPEED_GPIO_HIGH_LEVEL:
-+ return "high";
-+ default:
-+ return "both";
-+ }
-+ }
-+ return "error";
-+}
-+
-+/**
-+ * @return An interrupt status in human readable format.
-+ */
-+static const char *ast_gpio_int_status(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (regs)
-+ {
-+ unsigned shift = AST_GPIO_SHIFT(gpio);
-+ if (AST_GPIO_READ(regs->intcfg, shift))
-+ {
-+ return AST_GPIO_READ(regs->intcfg + AST_GPIO_INT_STATUS, shift)
-+ ? "pending"
-+ : "cleaned";
-+ }
-+ return "disabled";
-+ }
-+
-+ return "error";
-+}
-+
-+/**
-+ * @return A debounce value in human readable format.
-+ */
-+static const char *ast_gpio_debounce(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (regs)
-+ {
-+ unsigned shift = AST_GPIO_SHIFT(gpio);
-+ unsigned debounce =
-+ (AST_GPIO_READ(regs->debounce + AST_GPIO_DEBOUNCE0, shift) << 0) |
-+ (AST_GPIO_READ(regs->debounce + AST_GPIO_DEBOUNCE1, shift) << 1);
-+ switch (debounce)
-+ {
-+ case ASPEED_GPIO_DEBOUNCE_NONE:
-+ return "none";
-+ case ASPEED_GPIO_DEBOUNCE_1:
-+ return "timer1";
-+ case ASPEED_GPIO_DEBOUNCE_2:
-+ return "timer2";
-+ case ASPEED_GPIO_DEBOUNCE_3:
-+ return "timer3";
-+ default:
-+ break;
-+ }
-+ }
-+
-+ return "error";
-+}
-+
-+/**
-+ * @return A command source value in human readable format.
-+ */
-+static const char *ast_gpio_command_source(unsigned gpio)
-+{
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (regs)
-+ {
-+ /* Used one bit per gpio port */
-+ unsigned shift = AST_GPIO_SHIFT(gpio) - AST_GPIO_PIN(gpio);
-+ unsigned cmdsrc =
-+ (AST_GPIO_READ(regs->cmdsrc + AST_GPIO_CMD_SRC0, shift) << 0) |
-+ (AST_GPIO_READ(regs->cmdsrc + AST_GPIO_CMD_SRC1, shift) << 1);
-+
-+ switch (cmdsrc)
-+ {
-+ /* The single place where these values are used is here. */
-+ case 0x0:
-+ return "ARM";
-+ case 0x1:
-+ return "LPC";
-+ case 0x2:
-+ return "CoCPU";
-+ default:
-+ return "Unknown";
-+ }
-+ }
-+
-+ return "error";
-+}
-+
-+/**
-+ * @brief Show all GPIO pins statuses. Used by `do_gpio()` in `cmd/gpio.c`
-+ */
-+void gpio_info(void)
-+{
-+ unsigned first = ASPEED_GPIO(A, 0);
-+ unsigned last = ASPEED_GPIO(AC, 7);
-+ for (unsigned gpio = first; gpio <= last; gpio++)
-+ {
-+ unsigned port = AST_GPIO_PORT(gpio);
-+ unsigned pin = AST_GPIO_PIN(gpio);
-+ unsigned shift = AST_GPIO_SHIFT(gpio);
-+ ast_gpio_regs_t *regs = AST_GPIO_REGS(gpio);
-+ if (!regs)
-+ {
-+ printf("gpio %u is invalid!\n", gpio);
-+ continue;
-+ }
-+
-+ printf("gpio %c%c%c line %3d: %s, int: %s, %s, deb: %s, src: %s, "
-+ "val: %d/%d\n",
-+ (port >= ASPEED_GPIO_PORT_AA ? 'A' : ' '),
-+ ('A' + port % ASPEED_GPIO_PORT_AA), ('0' + pin), gpio,
-+ ast_gpio_direction(gpio), ast_gpio_trigger(gpio),
-+ ast_gpio_int_status(gpio), ast_gpio_debounce(gpio),
-+ ast_gpio_command_source(gpio), gpio_get_value(gpio),
-+ AST_GPIO_READ(regs->data, shift));
-+ }
-+}
-diff --git a/include/configs/ast-g5-phy.h b/include/configs/ast-g5-phy.h
-index 5443a26cab..ea7c66716a 100644
---- a/include/configs/ast-g5-phy.h
-+++ b/include/configs/ast-g5-phy.h
-@@ -32,5 +32,6 @@
-
- /* Call board_late_init */
- #define CONFIG_BOARD_LATE_INIT 1
-+#define CONFIG_CMD_GPIO 1 /* Enable gpio command in shell */
-
- #endif /* __AST_G5_PHY_CONFIG_H */
---
-2.17.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0005-aspeed-Enable-SPI-master-mode.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0005-aspeed-Enable-SPI-master-mode.patch
deleted file mode 100644
index 0dd736fba..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0005-aspeed-Enable-SPI-master-mode.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 0bf84de2a9db749bd61064cd47b96ef457725f54 Mon Sep 17 00:00:00 2001
-From: Chanh Nguyen <chanh@os.amperecomputing.com>
-Date: Wed, 10 Mar 2021 00:02:17 +0700
-Subject: [PATCH] aspeed: Enable SPI master mode
-
-Currently, some systems design the strap pin,
-which was shared pin with another function.
-That makes the board strapping does not reflect the intended use of the system.
-
-This patch will enable SPI master mode by default.
-
-Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
----
- board/aspeed/ast-g5/ast-g5.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index 9e27bce0f5..ed83d65136 100644
---- a/board/aspeed/ast-g5/ast-g5.c
-+++ b/board/aspeed/ast-g5/ast-g5.c
-@@ -125,6 +125,9 @@ int board_late_init(void)
- update_bootargs_cmd("resetreason", value);
- }
-
-+ /* enable SPI master */
-+ ast_scu_spi_master(1);
-+
- return 0;
- }
- #endif
---
-2.17.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0006-aspeed-support-Mt.Jade-platform-init.patch b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0006-aspeed-support-Mt.Jade-platform-init.patch
deleted file mode 100644
index 02a478362..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed/0006-aspeed-support-Mt.Jade-platform-init.patch
+++ /dev/null
@@ -1,175 +0,0 @@
-From 2c9ab641f2a7ea146a468ec4301c416010badff7 Mon Sep 17 00:00:00 2001
-From: Chanh Nguyen <chanh@os.amperecomputing.com>
-Date: Wed, 17 Mar 2021 14:11:18 +0700
-Subject: [PATCH] aspeed: support Mt.Jade platform init
-
-This commit adds platform init for Mt.Jade platform.
-
-Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
-Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
----
- arch/arm/include/asm/arch-aspeed/ast_scu.h | 1 +
- arch/arm/include/asm/arch-aspeed/regs-scu.h | 4 ++
- arch/arm/mach-aspeed/ast-scu.c | 18 +++++
- board/aspeed/ast-g5/ast-g5.c | 76 +++++++++++++++++++++
- include/configs/ast-g5-phy.h | 3 +
- 5 files changed, 102 insertions(+)
-
-diff --git a/arch/arm/include/asm/arch-aspeed/ast_scu.h b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-index f5c9126ec0..e2d06ccc1f 100644
---- a/arch/arm/include/asm/arch-aspeed/ast_scu.h
-+++ b/arch/arm/include/asm/arch-aspeed/ast_scu.h
-@@ -46,5 +46,6 @@ extern void ast_scu_init_eth(u8 num);
- extern void ast_scu_multi_func_eth(u8 num);
- extern void ast_scu_multi_func_romcs(u8 num);
- extern void ast_scu_switch_pwm_to_gpio_mode(void);
-+extern void ast_scu_switch_espi_to_gpio_mode(void);
-
- #endif
-diff --git a/arch/arm/include/asm/arch-aspeed/regs-scu.h b/arch/arm/include/asm/arch-aspeed/regs-scu.h
-index b714fa9234..704ad75b4e 100644
---- a/arch/arm/include/asm/arch-aspeed/regs-scu.h
-+++ b/arch/arm/include/asm/arch-aspeed/regs-scu.h
-@@ -76,6 +76,7 @@
- #define AST_SCU_FUN_PIN_CTRL7 0xA0 /* Multi-function Pin Control#7*/
- #define AST_SCU_FUN_PIN_CTRL8 0xA4 /* Multi-function Pin Control#8*/
- #define AST_SCU_FUN_PIN_CTRL9 0xA8 /* Multi-function Pin Control#9*/
-+#define AST_SCU_FUN_PIN_CTRL10 0xAC /* Multi-function Pin Control#10*/
- #define AST_SCU_MAC_CLK_DELAY_100M 0xB8 /* MAC interface clock delay 100M setting*/
- #define AST_SCU_MAC_CLK_DELAY_10M 0xBC /* MAC interface clock delay 10M setting*/
- #define AST_SCU_PWR_SAVING_EN 0xC0 /* Power Saving Wakeup Enable*/
-@@ -921,6 +922,9 @@
- #define SCU_FUN_PIN_ROMA19 (0x1 << 1)
- #define SCU_FUN_PIN_ROMA18 (0x1)
-
-+/* AST_SCU_FUN_PIN_CTRL10 0xAC - Multi-function Pin Control#10 */
-+#define SCU_FUN_PIN_ESPI(x) (0x1 << (x))
-+
- /* AST_SCU_PWR_SAVING_EN 0xC0 - Power Saving Wakeup Enable */
- /* AST_SCU_PWR_SAVING_CTRL 0xC4 - Power Saving Wakeup Control */
- /* AST_SCU_HW_STRAP2 0xD0 - Haardware strapping register set 2 */
-diff --git a/arch/arm/mach-aspeed/ast-scu.c b/arch/arm/mach-aspeed/ast-scu.c
-index c7ab66415f..71c043d3e8 100644
---- a/arch/arm/mach-aspeed/ast-scu.c
-+++ b/arch/arm/mach-aspeed/ast-scu.c
-@@ -554,3 +554,21 @@ void ast_scu_get_who_init_dram(void)
- break;
- }
- }
-+
-+void ast_scu_switch_espi_to_gpio_mode(void)
-+{
-+ /*
-+ * This Function to set the ESPI pin to GPIO mode
-+ * This allow to setting AC5_READY
-+ */
-+ ast_scu_write(ast_scu_read(AST_SCU_FUN_PIN_CTRL10) &
-+ ~SCU_FUN_PIN_ESPI(0) &
-+ ~SCU_FUN_PIN_ESPI(1) &
-+ ~SCU_FUN_PIN_ESPI(2) &
-+ ~SCU_FUN_PIN_ESPI(3) &
-+ ~SCU_FUN_PIN_ESPI(4) &
-+ ~SCU_FUN_PIN_ESPI(5) &
-+ ~SCU_FUN_PIN_ESPI(6) &
-+ ~SCU_FUN_PIN_ESPI(7),
-+ AST_SCU_FUN_PIN_CTRL10);
-+}
-diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index ed83d65136..edf7f050a8 100644
---- a/board/aspeed/ast-g5/ast-g5.c
-+++ b/board/aspeed/ast-g5/ast-g5.c
-@@ -163,3 +163,79 @@ void hw_watchdog_reset(void)
- writel(0x4755, AST_WDT2_BASE + 0x08);
- }
- #endif /* CONFIG_WATCHDOG */
-+
-+#ifdef CONFIG_BOARD_EARLY_INIT_F
-+int board_gpio_init(void)
-+{
-+ int pgood = 0;
-+
-+ /* GPIO_BMC_PSU_PG */
-+ pgood = gpio_get_value(44);
-+ /* GPIO_BMC_OCP_AUX_PWREN */
-+ gpio_direction_output(139, 1);
-+
-+ if (pgood)
-+ {
-+ /* GPIO_BMC_SYS_ATX_PSON_L */
-+ gpio_direction_output(42, 0);
-+ /* GPIO_BMC_OCP_MAIN_PWREN */
-+ gpio_direction_output(140, 1);
-+ }
-+ else
-+ {
-+ /* GPIO_BMC_SYS_ATX_PSON_L */
-+ gpio_direction_output(42, 1);
-+ /* GPIO_BMC_OCP_MAIN_PWREN */
-+ gpio_direction_output(140, 0);
-+ }
-+
-+ /* GPIOH7 GPIO_BMC_I2C6_RESET_L */
-+ gpio_direction_output(63, 1);
-+
-+ /* GPIOM4 S0_I2C9_ALERT_L */
-+ gpio_direction_input(100);
-+
-+ /* GPIOM5 S1_I2C9_ALERT_L */
-+ gpio_direction_input(101);
-+
-+ /* GPIOQ7 GPIO_BMC_VGA_FRONT_PRES_L */
-+ gpio_direction_input(135);
-+
-+ /* GPIOR1 GPIO_BMC_JTAG_SRST_L */
-+ gpio_direction_output(137, 1);
-+
-+ /* BMC_GPIOR2_EXT_HIGHTEMP_L */
-+ gpio_direction_output(138, 1);
-+
-+ /* GPIOS0 GPIO_S0_VRHOT_L */
-+ gpio_direction_input(144);
-+
-+ /* GPIOS1 GPIO_S1_VRHOT_L */
-+ gpio_direction_input(145);
-+
-+ /* GPIOS5 GPIO_BMC_VR_PMBUS_SEL_L */
-+ gpio_direction_output(149, 1);
-+
-+ /* GPIOY3 BMC_VGA_SEL */
-+ gpio_direction_output(195, 1);
-+
-+ /* GPIOAC1 GPIO_BMC_PCA9554_INT_L */
-+ gpio_direction_input(225);
-+
-+ /* GPIO_BMC_READY */
-+ gpio_direction_output(229, 1);
-+
-+ /* Enable I2C4 device access */
-+ gpio_direction_output(194, 1);
-+
-+ return 0;
-+}
-+
-+int board_early_init_f(void)
-+{
-+ ast_scu_switch_espi_to_gpio_mode();
-+ board_gpio_init();
-+
-+ return 0;
-+}
-+#endif /* CONFIG_BOARD_EARLY_INIT_F */
-diff --git a/include/configs/ast-g5-phy.h b/include/configs/ast-g5-phy.h
-index ea7c66716a..a5e389616b 100644
---- a/include/configs/ast-g5-phy.h
-+++ b/include/configs/ast-g5-phy.h
-@@ -34,4 +34,7 @@
- #define CONFIG_BOARD_LATE_INIT 1
- #define CONFIG_CMD_GPIO 1 /* Enable gpio command in shell */
-
-+/* Call board_early_init_f */
-+#define CONFIG_BOARD_EARLY_INIT_F 1
-+
- #endif /* __AST_G5_PHY_CONFIG_H */
---
-2.17.1
-
diff --git a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend b/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend
deleted file mode 100644
index bda3d9d71..000000000
--- a/meta-ampere/meta-jade/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend
+++ /dev/null
@@ -1,10 +0,0 @@
-FILESEXTRAPATHS:append:mtjade := "${THISDIR}/${PN}:"
-
-SRC_URI += " \
- file://0001-aspeed-scu-Switch-PWM-pin-to-GPIO-input-mode.patch \
- file://0002-aspeed-Disable-internal-PD-resistors-for-GPIOs.patch \
- file://0003-aspeed-support-passing-system-reset-status-to-kernel.patch \
- file://0004-aspeed-add-gpio-support.patch \
- file://0005-aspeed-Enable-SPI-master-mode.patch \
- file://0006-aspeed-support-Mt.Jade-platform-init.patch \
- "
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
index 58fffd8fe..f28589894 100755
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2020 Ampere Computing LLC
+# Copyright (c) 2021 Ampere Computing LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,24 +19,13 @@
# <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=/dev/null
+source /usr/sbin/gpio-lib.sh
+
if [ $# -lt 2 ]; then
exit 1
fi
-function set_gpio_active_low() {
- if [ $# -ne 2 ]; then
- echo "set_gpio_active_low: need both GPIO# and initial level";
- return;
- fi
-
- if [ ! -d /sys/class/gpio/gpio$1 ]; then
- echo $1 > /sys/class/gpio/export
- fi
- echo $2 > /sys/class/gpio/gpio$1/direction
-}
-
-GPIO_BASE=$(cat /sys/class/gpio/gpio*/base)
-
case "$1" in
1) GPIO_UARTx_MODE0=56
# CPU0 UART0 connects to BMC UART1
@@ -65,17 +54,17 @@ esac
# of requested console port.
# Example format: Accepted: 1; Connected: 1;
CONNECTED=$(systemctl --no-pager status obmc-console-ttyS${CONSOLE_PORT}-ssh.socket | grep -w Connected | cut -d ':' -f 3 | tr -d ' ;')
-if [ ! $CONNECTED -le 1 ]; then
+if [ ! "$CONNECTED" -le 1 ]; then
exit 0
fi
echo "Ampere UART MUX CTRL UART port $1 to mode $2"
case "$2" in
- 1) set_gpio_active_low $((${GPIO_BASE} + ${GPIO_UARTx_MODE0})) low
+ 1) gpio_configure_output "${GPIO_UARTx_MODE0}" 0
exit 0
;;
- 2) set_gpio_active_low $((${GPIO_BASE} + ${GPIO_UARTx_MODE0})) high
+ 2) gpio_configure_output "${GPIO_UARTx_MODE0}" 1
exit 0
;;
*) echo "Invalid UART mode selection"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
index fe2d5ab03..4e0a01350 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
@@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-set -euo pipefail
-
tty="$1"
uart=0
@@ -39,4 +37,4 @@ esac
# this value should be set to 1
/usr/sbin/ampere_uartmux_ctrl.sh ${uart} 2
-/usr/sbin/obmc-console-server --config /etc/obmc-console/server.${tty}.conf ${tty}
+/usr/sbin/obmc-console-server --config /etc/obmc-console/server."${tty}".conf "${tty}"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh b/meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh
index 8d3d54374..1e1cbc588 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/fault-monitor/toggle_fault_led.sh
@@ -22,14 +22,14 @@ PROPERTY="Asserted"
# Get current state
object=$(busctl tree $SERVICE --list | grep system_fault)
-state=$(busctl get-property $SERVICE $object $INTERFACE $PROPERTY \
+state=$(busctl get-property $SERVICE "$object" $INTERFACE $PROPERTY \
| awk '{print $NF;}')
-if [ "$state" == "false" ]; then
- target='true'
+if [ "$state" = "false" ]; then
+ target='true'
else
- target='false'
+ target='false'
fi
# Set target state
-busctl set-property $SERVICE $object $INTERFACE $PROPERTY b $target
+busctl set-property $SERVICE "$object" $INTERFACE $PROPERTY b $target
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
index d62c84ae1..06b2d55f1 100755
--- a/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh
@@ -22,24 +22,24 @@ PROPERTY="Asserted"
# Get enclosure_identify state
identify_object=$(busctl tree $SERVICE --list | grep -m 1 identify)
-identify_state=$(busctl get-property $SERVICE $identify_object $INTERFACE $PROPERTY \
- | awk '{print $NF;}')
+identify_state=$(busctl get-property $SERVICE "$identify_object" $INTERFACE $PROPERTY \
+ | awk '{print $NF;}')
# Get enclosure_identify_blink state
identify_blink_object=$(busctl tree $SERVICE --list | grep identify_blink)
-identify_blink_state=$(busctl get-property $SERVICE $identify_blink_object $INTERFACE $PROPERTY \
- | awk '{print $NF;}')
+identify_blink_state=$(busctl get-property $SERVICE "$identify_blink_object" $INTERFACE $PROPERTY \
+ | awk '{print $NF;}')
# Set state
-if [[ "$identify_state" == "false" && "$identify_blink_state" == "false" ]]; then
+if [ "$identify_state" = "false" ] && [ "$identify_blink_state" = "false" ]; then
# Turn on the UID LED
- busctl set-property $SERVICE $identify_object $INTERFACE $PROPERTY b true
-elif [[ "$identify_state" == "false" && "$identify_blink_state" == "true" ]]; then
+ busctl set-property $SERVICE "$identify_object" $INTERFACE $PROPERTY b true
+elif [ "$identify_state" = "false" ] && [ "$identify_blink_state" = "true" ]; then
# Turn off the UID LED when LED is blinking state
- busctl set-property $SERVICE $identify_blink_object $INTERFACE $PROPERTY b false
-elif [[ "$identify_state" == "true" && "$identify_blink_state" == "false" ]]; then
+ busctl set-property $SERVICE "$identify_blink_object" $INTERFACE $PROPERTY b false
+elif [ "$identify_state" = "true" ] && [ "$identify_blink_state" = "false" ]; then
# Turn off the UID LED
- busctl set-property $SERVICE $identify_object $INTERFACE $PROPERTY b false
+ busctl set-property $SERVICE "$identify_object" $INTERFACE $PROPERTY b false
else
echo "Invalid case! When identify_blink_state is true, the identify_state will set to false"
fi
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh b/meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh
index 65bff9dc1..37a3ce301 100644..100755
--- a/meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh
@@ -29,10 +29,10 @@ STATUS_MFR_SPECIFIC=0x80
# $1 will be the name of the psu
PSU=$1
-if [[ $PSU == 1 ]]; then
+if [ "$PSU" = 1 ]; then
HSC_PMBUS_NUM=$HSC1_PMBUS_NUM
HSC_SLAVE_ADDR=$HSC1_SLAVE_ADDR
-elif [[ $PSU == 2 ]]; then
+elif [ "$PSU" = 2 ]; then
HSC_PMBUS_NUM=$HSC2_PMBUS_NUM
HSC_SLAVE_ADDR=$HSC2_SLAVE_ADDR
else
@@ -43,22 +43,20 @@ fi
# Check HOST state
chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}')
-if [[ "$chassisstate" == 'Off' ]]; then
+if [ "$chassisstate" = 'Off' ]; then
echo "HOST is being OFF, so can't access the i2c $HSC_PMBUS_NUM. Please Turn ON HOST !"
exit 1
fi
# Check FET health problems
-data=$(i2cget -f -y $HSC_PMBUS_NUM $HSC_SLAVE_ADDR $STATUS_MFR_SPECIFIC)
-
-if [[ $? -ne 0 ]]; then
+if ! data=$(i2cget -f -y $HSC_PMBUS_NUM $HSC_SLAVE_ADDR $STATUS_MFR_SPECIFIC); then
echo "ERROR: Can't access the i2c. Please check /dev/i2c-$HSC_PMBUS_NUM"
exit 1
fi
psu_sts=$(((data & 0x80) != 0))
-if [[ $psu_sts == 1 ]]; then
+if [ $psu_sts = 1 ]; then
echo "PSU $PSU: FET health problems have been detected"
echo "Reset Hot swap output on PSU $PSU"
# Disable Hot swap output
@@ -71,4 +69,4 @@ if [[ $psu_sts == 1 ]]; then
else
echo "PSU $PSU: FET health problems have not been detected"
-fi \ No newline at end of file
+fi
diff --git a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
index 7136be64f..56db56883 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
+++ b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
@@ -2,6 +2,7 @@ RDEPENDS:${PN}-extras:append:mtjade = " \
webui-vue \
phosphor-image-signing \
phosphor-virtual-sensor \
+ phosphor-misc-usb-ctrl \
"
RDEPENDS:${PN}-inventory:append:mtjade = " \