From 509991d6a5f34772788ca6d8401c19109e6280a6 Mon Sep 17 00:00:00 2001 From: "Thang Q. Nguyen" Date: Tue, 20 Jul 2021 15:48:50 +0700 Subject: meta-ampere: mtjade: flash UEFI firmware at 4MB offset UEFI firmware for Ampere Altra-based platform starts at offset 0x400000 but currently the firmware image is flashed start at offset 0. This makes the Host fail to boot. This commit supports offset option for the mtd-util's flashcp utility and update the script to flash UEFI firmware starting at offset 0x400000. Tested: 1. Turn on the Host. 2. Flash UEFI firmware. Wait for the flash complete and check if Host can boot successfully. 4. Turn off the Host. 5. Flash UEFI firmware. Wait for the flash complete. 6. Turn on the Host and check if Host can boot successfully. Signed-off-by: Tung Nguyen Signed-off-by: Thang Q. Nguyen Change-Id: I0d48bfd0a7b7350b46a98bf10fe4de3887f09f02 --- .../flash/ampere-flash-utils/ampere_flash_bios.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'meta-ampere/meta-jade/recipes-ampere') 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 876671c1b..7a9ace30e 100755 --- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh +++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh @@ -15,6 +15,8 @@ # limitations under the License. do_flash () { + OFFSET=$1 + # Check the PNOR partition available HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') if [ -z "$HOST_MTD" ]; @@ -30,18 +32,10 @@ do_flash () { echo "Fail to probe Host SPI-NOR device" exit 1 fi - - echo "--- Flashing firmware to @/dev/$HOST_MTD" - flash_eraseall /dev/$HOST_MTD - flashcp -v $IMAGE /dev/$HOST_MTD - - echo "--- Unbind the ASpeed SMC driver" - echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/unbind - else - echo "--- Flashing firmware to @/dev/$HOST_MTD" - flash_eraseall /dev/$HOST_MTD - flashcp -v $IMAGE /dev/$HOST_MTD fi + + echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET" + flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET } @@ -84,7 +78,7 @@ if [[ $? -ne 0 ]]; then fi # Flash the firmware -do_flash +do_flash 0x400000 # Switch the host SPI bus to HOST." echo "--- Switch the host SPI bus to HOST." @@ -99,5 +93,5 @@ if [ "$chassisstate" == 'On' ]; then sleep 5 echo "Turn on the Host" - obmcutil chassison + obmcutil poweron fi -- cgit v1.2.3 From fb214784edbc1da7ba155a1cddf7b3f6d0bbfb66 Mon Sep 17 00:00:00 2001 From: ThuBaNguyen Date: Thu, 8 Jul 2021 14:20:43 +0700 Subject: meta-ampere: power control: restructure source code ampere-hostctrl package includes the generic codes and the platform specific codes. The generic sources are applied for all of the Ampere platforms, they are the service files and the scripts to setting the GPIO pins. The platform specific sources are the GPIO pin config file and the gpio monitor config files. This commit moves the platform specific files to the platform code. Tested: 1. Do the power control actions use ipmitool, BMC web and Redfish. 2. Make sure the server states are changed as expected. Signed-off-by: ThuBaNguyen Change-Id: Ic0e261109f7a5dfaf38c883bff0afedab763a0b6 --- .../recipes-ac01/host/ampere-hostctrl.bb | 26 +--- .../ampere-host-shutdown-ack@.service | 8 -- .../recipes-ac01/host/files/ampere_power_util.sh | 144 -------------------- .../recipes-ac01/host/files/obmc/gpio/reboot_ack | 4 - .../recipes-ac01/host/files/obmc/gpio/shutdown_ack | 4 - meta-ampere/meta-jade/conf/machine/mtjade.conf | 1 + .../recipes-ampere/platform/mtjade-utils.bb | 18 +++ .../platform/mtjade-utils/ampere_power_util.sh | 147 +++++++++++++++++++++ .../platform/mtjade-utils/gpio-defs.sh | 32 +++++ .../recipes-phosphor/gpio/host-gpio-handling.bb | 23 ++++ .../ampere-host-shutdown-ack@.service | 8 ++ .../gpio/host-gpio-handling/obmc/gpio/reboot_ack | 4 + .../gpio/host-gpio-handling/obmc/gpio/shutdown_ack | 4 + .../packagegroups/packagegroup-obmc-apps.bbappend | 4 + 14 files changed, 244 insertions(+), 183 deletions(-) delete mode 100644 meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service delete mode 100644 meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh delete mode 100644 meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack delete mode 100644 meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack create mode 100644 meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack (limited to 'meta-ampere/meta-jade/recipes-ampere') diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb index 4a44d1b2f..cfefa8d94 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb @@ -7,41 +7,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca inherit systemd inherit obmc-phosphor-systemd -# For now, monitoring shutdown_ack and reboot_ack are the only usecases -OBMC_HOST_MONITOR_INSTANCES = "shutdown_ack reboot_ack" -SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/shutdown_ack obmc/gpio/reboot_ack" - S = "${WORKDIR}" SRC_URI = " \ - file://ampere_power_util.sh \ file://ampere-host-force-reset@.service \ - file://ampere-host-shutdown-ack@.service \ " -DEPENDS = "systemd virtual/obmc-gpio-monitor" -RDEPENDS_${PN} = "bash virtual/obmc-gpio-monitor" - SYSTEMD_PACKAGES = "${PN}" SYSTEMD_SERVICE_${PN} = " \ ampere-host-force-reset@.service \ - ampere-host-shutdown-ack@.service \ " -# overwrite force reboot +# append force reboot HOST_WARM_REBOOT_FORCE_TGT = "ampere-host-force-reset@.service" +HOST_WARM_REBOOT_FORCE_INSTMPL = "ampere-host-force-reset@{0}.service" HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target" -HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_TGT}" +HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_INSTMPL}" SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}" -TMPL = "phosphor-gpio-monitor@.service" -INSTFMT = "phosphor-gpio-monitor@{0}.service" -TGT = "multi-user.target" -FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" -SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_MONITOR_INSTANCES')}" - -do_install() { - install -d ${D}/usr/sbin - install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ampere_power_util.sh -} - diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service deleted file mode 100644 index 6588191aa..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown-ack@.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Ampere Computing LLC host shutdown ACK -Conflicts=obmc-chassis-poweron@0.target - -[Service] -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb shutdown_ack -SyslogIdentifier=ampere_host_shutdown_ack diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh b/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh deleted file mode 100644 index aa742104f..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash -# Usage of this utility -function usage() { - echo "usage: power-util mb [on|status|cycle|reset|graceful_reset|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 -} - -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" -<<<<<<< HEAD - fi -} - -graceful_shutdown() { - if [ -f "/run/openbmc/host@0-request" ]; then - echo "shutdown host immediately" - power_off - else - echo "Triggering graceful shutdown" - gpioset -l 0 49=1 - sleep 1 - gpioset -l 0 49=0 - sleep 30s -======= - sleep 3 - systemctl start obmc-chassis-poweroff@0.target ->>>>>>> 397e033ef... meta-ampere: power control: refactor host power control - fi -} - -soft_off() { - # Trigger shutdown_req - touch /run/openbmc/host@0-softpoweroff - gpioset -l 0 49=1 - sleep 1s - gpioset -l 0 49=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 0 91=1 - sleep 1 - gpioset -l 0 91=0 -} - -if [ $# -lt 2 ]; then - echo "Total number of parameter=$#" - echo "Insufficient parameter" - usage; - exit 0; -fi - -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 - -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; -fi - -exit 0; diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack b/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack deleted file mode 100644 index a8ad98ee7..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack +++ /dev/null @@ -1,4 +0,0 @@ -DEVPATH=/dev/input/event0 -KEY=75 -POLARITY=1 -TARGET=obmc-host-force-warm-reboot@0.target diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack b/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack deleted file mode 100644 index 18cc87246..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack +++ /dev/null @@ -1,4 +0,0 @@ -DEVPATH=/dev/input/event0 -KEY=50 -POLARITY=1 -TARGET=ampere-host-shutdown-ack@0.service diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf index e749af6de..558a6f404 100644 --- a/meta-ampere/meta-jade/conf/machine/mtjade.conf +++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf @@ -29,6 +29,7 @@ OBMC_MACHINE_FEATURES += "\ VOLATILE_LOG_DIR = "no" OBMC_IMAGE_EXTRA_INSTALL_append = "\ + mtjade-utils \ ampere-usbnet \ ampere-flash-utils \ ampere-mac-update \ diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb new file mode 100644 index 000000000..184d643f6 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb @@ -0,0 +1,18 @@ +SUMMARY = "Ampere Platform Environment Definitions" +DESCRIPTION = "Ampere Platform Environment Definitions" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = " \ + file://gpio-defs.sh \ + file://ampere_power_util.sh \ + " + +RDEPENDS_${PN} = "bash" + +do_install() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/gpio-defs.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ +} \ No newline at end of file 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 new file mode 100644 index 000000000..4ad07a68f --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh @@ -0,0 +1,147 @@ +#!/bin/bash +#ampere_platform_config.sh is platform configuration file +source /usr/sbin/gpio-defs.sh + +# Usage of this utility +function usage() { + echo "usage: power-util mb [on|status|cycle|reset|graceful_reset|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 +} + +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" +<<<<<<< HEAD + fi +} + +graceful_shutdown() { + if [ -f "/run/openbmc/host@0-request" ]; then + echo "shutdown host immediately" + power_off + else + echo "Triggering graceful shutdown" + gpioset -l 0 49=1 + sleep 1 + gpioset -l 0 49=0 + sleep 30s +======= + sleep 3 + systemctl start obmc-chassis-poweroff@0.target +>>>>>>> 397e033ef... meta-ampere: power control: refactor host power control + 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 + + # 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 [ $# -lt 2 ]; then + echo "Total number of parameter=$#" + echo "Insufficient parameter" + usage; + exit 0; +fi + +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 + +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; +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 new file mode 100644 index 000000000..fce59d581 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh @@ -0,0 +1,32 @@ +# 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=792 +GPIO_CHIP1_BASE=780 + +### 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 + + +### Table 1: GPIO Assignments +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 + +### 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 diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb new file mode 100644 index 000000000..4358b1242 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb @@ -0,0 +1,23 @@ +SUMMARY = "Ampere Computing LLC Host Gpio Handling" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit obmc-phosphor-systemd + +DEPENDS += "virtual/obmc-gpio-monitor" +RDEPENDS_${PN} += "virtual/obmc-gpio-monitor" + +OBMC_HOST_ACK_MONITOR_INSTANCES = "reboot_ack shutdown_ack" + +SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/reboot_ack \ + obmc/gpio/shutdown_ack \ + " + +TMPL = "phosphor-gpio-monitor@.service" +INSTFMT = "phosphor-gpio-monitor@{0}.service" +TGT = "multi-user.target" +FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" + +SYSTEMD_SERVICE_${PN} += "ampere-host-shutdown-ack@.service" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_ACK_MONITOR_INSTANCES')}" diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service new file mode 100644 index 000000000..6588191aa --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Ampere Computing LLC host shutdown ACK +Conflicts=obmc-chassis-poweron@0.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_power_util.sh mb shutdown_ack +SyslogIdentifier=ampere_host_shutdown_ack diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack new file mode 100644 index 000000000..a8ad98ee7 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack @@ -0,0 +1,4 @@ +DEVPATH=/dev/input/event0 +KEY=75 +POLARITY=1 +TARGET=obmc-host-force-warm-reboot@0.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack new file mode 100644 index 000000000..18cc87246 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack @@ -0,0 +1,4 @@ +DEVPATH=/dev/input/event0 +KEY=50 +POLARITY=1 +TARGET=ampere-host-shutdown-ack@0.service 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 3af702292..ca86a4a21 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 @@ -1,2 +1,6 @@ RDEPENDS_${PN}-extras_append_mtjade = " webui-vue phosphor-image-signing phosphor-virtual-sensor" RDEPENDS_${PN}-inventory_append_mtjade = " fault-monitor id-button psu-hotswap-reset" + +RDEPENDS_${PN}-inventory_append_mtjade = " \ + host-gpio-handling \ + " -- cgit v1.2.3 From 7b4528285147286f72769333cfde8c0d07ed11d1 Mon Sep 17 00:00:00 2001 From: ThuBaNguyen Date: Sun, 6 Jun 2021 14:36:07 +0700 Subject: meta-ampere: host-check: verify the host state When phosphor-state-manager handles the power action to turn on the host, phosphor-state-manager does not use the software interfaces to verify the host state. It set the host state to running after all of required services of the power action target are done. The power on watchdog is used to verify the host state and handle the failure in the host state changing. But Mt.Jade platforms do not handle power on watchdog. This causes the CurrentHostState dbus property is Running before the host is ready. In Mt.Jade platform, the SCP drives S0_FW_BOOT_OK to high when the host is already on. This GPIO can be used to identify the host state. One service should be added to the required list. This service checks the host state in power on and triggers obmc-host-quiesce@%i.target when the host is failed to boot. ampere-host-check package adds ampere-host-on-host-check@.service for that purpose. Tested: 1. Boot up BMC with the host is off/on. Check CurrentHostState. 2. Call Ipmitool power off/on. Check the CurrentHostState. 3. Call Ipmitool chassis power off/on. Check the CurrentHostState. 4. Call Ipmitool power cycle. Check the CurrentHostState. 5. Call Ipmitool chassis power cycle. Check the CurrentHostState. 6. Power off the host. Set power policty to Always-on. AC power. The host should be on. And CurrentHostState should be Running. 7. Power on the host. Set power policty to Always-off. AC power. The host should be off. And CurrentHostState should be Off. Change-Id: I9b0b346883a5f0203bf078453065c18ae4603311 Signed-off-by: ThuBaNguyen --- .../recipes-ac01/host/ampere-hostctrl.bb | 8 ++++ .../ampere-host-on-host-check@.service | 13 +++++++ .../recipes-ampere/platform/mtjade-utils.bb | 4 ++ .../platform/mtjade-utils/ampere_host_check.sh | 45 ++++++++++++++++++++++ .../platform/mtjade-utils/gpio-lib.sh | 30 +++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh (limited to 'meta-ampere/meta-jade/recipes-ampere') diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb index cfefa8d94..5c4b6a012 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb @@ -11,6 +11,7 @@ S = "${WORKDIR}" SRC_URI = " \ file://ampere-host-force-reset@.service \ + file://ampere-host-on-host-check@.service \ " SYSTEMD_PACKAGES = "${PN}" @@ -24,4 +25,11 @@ HOST_WARM_REBOOT_FORCE_INSTMPL = "ampere-host-force-reset@{0}.service" HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target" HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_INSTMPL}" SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${HOST_WARM_REBOOT_FORCE_TGT}" +HOST_ON_RESET_HOSTTMPL = "ampere-host-on-host-check@.service" +HOST_ON_RESET_HOSTINSTMPL = "ampere-host-on-host-check@{0}.service" +HOST_ON_RESET_HOSTTGTFMT = "obmc-host-startmin@{0}.target" +HOST_ON_RESET_HOSTFMT = "../${HOST_ON_RESET_HOSTTMPL}:${HOST_ON_RESET_HOSTTGTFMT}.requires/${HOST_ON_RESET_HOSTINSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_ON_RESET_HOSTFMT', 'OBMC_HOST_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${HOST_ON_RESET_HOSTTMPL}" diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service new file mode 100644 index 000000000..36e5a642c --- /dev/null +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Check Host%i status before obmc-host-startmin +Wants=obmc-host-started@%i.target +After=obmc-host-started@%i.target +Conflicts=obmc-host-stop@%i.target +Conflicts=phosphor-reset-host-check@%i.service +OnFailure=obmc-host-quiesce@%i.target +OnFailureJobMode=flush +ConditionPathExists=!/run/openbmc/host@%i-on + +[Service] +Type=oneshot +ExecStart=/usr/sbin/ampere_host_check.sh 1 0 diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb index 184d643f6..159ccdd64 100644 --- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb @@ -6,13 +6,17 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca SRC_URI = " \ file://gpio-defs.sh \ + file://gpio-lib.sh \ file://ampere_power_util.sh \ + file://ampere_host_check.sh \ " RDEPENDS_${PN} = "bash" do_install() { 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_host_check.sh ${D}/${sbindir}/ } \ No newline at end of file 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 new file mode 100644 index 000000000..9eeeeca5a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +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 +fi + +# Time out to check S0_FW_BOOT_OK is 60 seconds +cnt=60 +val=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 +done + +exit 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 new file mode 100644 index 000000000..fcc2d5411 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function gpio_number() { + GPIO_BASE=$(cat /sys/class/gpio/gpio*/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 +} + +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 +} + +# 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 +} -- cgit v1.2.3 From 9dccc52b92ae7a112469112029be7f08d55517b5 Mon Sep 17 00:00:00 2001 From: ThuBaNguyen Date: Wed, 4 Aug 2021 19:41:04 +0700 Subject: meta-ampere: power control: correct the script The power functions are failed to work. There is one mistake in merging ampere_power_utils.sh script. This commit fixes the mistake. Tested: 1. Power off the host when it is on. 2. The host state should be changed to off. Signed-off-by: ThuBaNguyen Change-Id: Iaa253e4b8d0f645a2b7097501e8c602d693cb37a --- .../platform/mtjade-utils/ampere_power_util.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'meta-ampere/meta-jade/recipes-ampere') 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 4ad07a68f..2c8ba3d91 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 @@ -4,7 +4,7 @@ source /usr/sbin/gpio-defs.sh # Usage of this utility function usage() { - echo "usage: power-util mb [on|status|cycle|reset|graceful_reset|force_reset|soft_off]"; + echo "usage: power-util mb [status|shutdown_ack|force_reset|soft_off]"; } power_status() { @@ -22,24 +22,8 @@ shutdown_ack() { touch /run/openbmc/host@0-softpoweroff-shutdown-ack else echo "Receive shutdown ACK triggered" -<<<<<<< HEAD - fi -} - -graceful_shutdown() { - if [ -f "/run/openbmc/host@0-request" ]; then - echo "shutdown host immediately" - power_off - else - echo "Triggering graceful shutdown" - gpioset -l 0 49=1 - sleep 1 - gpioset -l 0 49=0 - sleep 30s -======= sleep 3 systemctl start obmc-chassis-poweroff@0.target ->>>>>>> 397e033ef... meta-ampere: power control: refactor host power control fi } -- cgit v1.2.3 From 33109174ab92b491001a95d5e51ec7f04e7e8e6c Mon Sep 17 00:00:00 2001 From: ThuBaNguyen Date: Fri, 2 Jul 2021 15:39:57 +0700 Subject: meta-ampere: mtjade: add mtjade-gpio-config package The OCP module in Mt.Jade platform supports the GPIO pins to set the power state. The SPI0 module also supports the GPIO pins to config SPI mode. These gpio pins have to be set to the right states before power off/on. The mtjade-gpio-config package will support that. Tested: 1. Power off/on the host. 2. The OCP and SPI0 gpio pins should be in the corrected states. Signed-off-by: ThuBaNguyen Change-Id: I46bca50222b0428f73aa9c05003f650f6ec0cc0b --- meta-ampere/meta-jade/conf/machine/mtjade.conf | 1 + .../recipes-ampere/platform/mtjade-gpio-config.bb | 44 ++++++++++++++++++++++ .../ampere-gpio-poweroff@.service | 10 +++++ .../ampere-gpio-poweron@.service | 10 +++++ .../mtjade-gpio-config/ampere_gpio_utils.sh | 43 +++++++++++++++++++++ .../platform/mtjade-utils/gpio-defs.sh | 8 ++++ .../platform/mtjade-utils/gpio-lib.sh | 3 +- 7 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service create mode 100644 meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh (limited to 'meta-ampere/meta-jade/recipes-ampere') diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf index 558a6f404..8c43cbd60 100644 --- a/meta-ampere/meta-jade/conf/machine/mtjade.conf +++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf @@ -33,6 +33,7 @@ OBMC_IMAGE_EXTRA_INSTALL_append = "\ ampere-usbnet \ ampere-flash-utils \ ampere-mac-update \ + mtjade-gpio-config \ " PREFERRED_PROVIDER_virtual/obmc-chassis-mgmt = "packagegroup-ampere-apps" diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb new file mode 100644 index 000000000..69fedd67a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb @@ -0,0 +1,44 @@ +SUMMARY = "Ampere Computing LLC Utilities" +DESCRIPTION = "Ampere Utilities for Mt.Jade systems" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit systemd +inherit obmc-phosphor-systemd + +S = "${WORKDIR}" + +SRC_URI = " \ + file://ampere_gpio_utils.sh \ + " + +DEPENDS = "systemd" +RDEPENDS_${PN} = "bash" + +SYSTEMD_PACKAGES = "${PN}" + +SYSTEMD_SERVICE_${PN} = " \ + ampere-gpio-poweroff@.service \ + ampere-gpio-poweron@.service \ + " + +# chassis power on +CHASSIS_POWERON_SVC = "ampere-gpio-poweron@.service" +CHASSIS_POWERON_INSTMPL = "ampere-gpio-poweron@{0}.service" +CHASSIS_POWERON_TGTFMT = "obmc-chassis-poweron@{0}.target" +CHASSIS_POWERON_FMT = "../${CHASSIS_POWERON_SVC}:${CHASSIS_POWERON_TGTFMT}.requires/${CHASSIS_POWERON_INSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWERON_FMT', 'OBMC_CHASSIS_INSTANCES')}" + +# chassis power off +CHASSIS_POWEROFF_SVC = "ampere-gpio-poweroff@.service" +CHASSIS_POWEROFF_INSTMPL = "ampere-gpio-poweroff@{0}.service" +CHASSIS_POWEROFF_TGTFMT = "obmc-chassis-poweroff@{0}.target" +CHASSIS_POWEROFF_FMT = "../${CHASSIS_POWEROFF_SVC}:${CHASSIS_POWEROFF_TGTFMT}.requires/${CHASSIS_POWEROFF_INSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWEROFF_FMT', 'OBMC_CHASSIS_INSTANCES')}" + +do_install() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/ampere_gpio_utils.sh ${D}/${sbindir}/ +} + diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service new file mode 100644 index 000000000..78862eb32 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Ampere set GPIOs before power off +Requires=op-wait-power-off@%i.service +Before=op-wait-power-off@%i.service +Conflicts=obmc-chassis-poweron@%i.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_gpio_utils.sh power off +SyslogIdentifier=ampere_gpio_utils \ No newline at end of file diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service new file mode 100644 index 000000000..09aa58826 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Ampere set GPIOs before power on +Requires=op-wait-power-on@%i.service +Before=op-wait-power-on@%i.service +Conflicts=obmc-chassis-poweroff@%i.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_gpio_utils.sh power on +SyslogIdentifier=ampere_gpio_utils 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 new file mode 100644 index 000000000..8e4f455bf --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh @@ -0,0 +1,43 @@ +#!/bin/bash +source /usr/sbin/gpio-defs.sh +source /usr/sbin/gpio-lib.sh + +function usage() { + 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 +} + +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 +} + +if [ $# -lt 2 ]; then + 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; +else + echo "Invalid parameter1=$1" + usage; + exit 0; +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 fce59d581..7c887d409 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 @@ -30,3 +30,11 @@ 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 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 fcc2d5411..8d1aa61d7 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,7 +1,8 @@ #!/bin/bash +source /usr/sbin/gpio-defs.sh function gpio_number() { - GPIO_BASE=$(cat /sys/class/gpio/gpio*/base) + GPIO_BASE=$(cat /sys/class/gpio/gpiochip$GPIO_CHIP0_BASE/base) echo $((${GPIO_BASE} + $1)) } -- cgit v1.2.3