1#!/bin/bash 2 3# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions 4source /usr/libexec/yosemite4-common-functions 5 6export STATE_OFF=0 7export STATE_ON=1 8export STATE_UNKNOWN=-1 9export MANAGEMENT_BOARD_IO_EXP_BUS_NUM="34" 10export SPIDER_BOARD_IO_EXP_BUS_NUM="28" 11export IO_EXP_SLOT_PWR_CTRL_ADDR="21" 12export IO_EXP_SLED_PWR_CTRL_ADDR="21" 13export IO_EXP_BIC_PWR_CTRL_ADDR="24" 14export CHASSIS_BUS_NAME="xyz.openbmc_project.State.Chassis" 15export CHASSIS_OBJ_PATH="/xyz/openbmc_project/state/chassis" 16export CHASSIS_INTF_NAME="xyz.openbmc_project.State.Chassis" 17export CHASSIS_PROPERTY_NAME="CurrentPowerState" 18export CHASSIS_ON_PROPERTY="xyz.openbmc_project.State.Chassis.PowerState.On" 19export CHASSIS_OFF_PROPERTY="xyz.openbmc_project.State.Chassis.PowerState.Off" 20export HOST_BUS_NAME="xyz.openbmc_project.State.Host" 21export HOST_OBJ_PATH="/xyz/openbmc_project/state/host" 22export HOST_INTF_NAME="xyz.openbmc_project.State.Host" 23export HOST_PROPERTY_NAME="CurrentHostState" 24export HOST_ON_PROPERTY="xyz.openbmc_project.State.Host.HostState.Running" 25export HOST_OFF_PROPERTY="xyz.openbmc_project.State.Host.HostState.Off" 26 27MANAGEMENT_BOARD_VERSION=$(get_product_version Management_Board) 28if [ "$MANAGEMENT_BOARD_VERSION" = "DVT" ] || [ "$MANAGEMENT_BOARD_VERSION" = "EVT" ]; then 29 MANAGEMENT_BOARD_IO_EXP_BUS_NUM="13" 30fi 31 32gpio_get() 33{ 34 RETRY=3 35 while [ $RETRY -gt 0 ] 36 do 37 if gpioget "$1" "$2" 38 then 39 return 0 40 fi 41 RETRY=$((RETRY-1)) 42 sleep 0.5 43 done 44 echo "gpioget failed" 45} 46 47gpio_set() 48{ 49 RETRY=3 50 while [ $RETRY -gt 0 ] 51 do 52 if gpioset "$1" "$2" 53 then 54 return 0 55 fi 56 RETRY=$((RETRY-1)) 57 sleep 0.5 58 done 59 echo "gpioset failed" 60} 61 62add_sel() 63{ 64 MESSAGE="$*" 65 66 busctl call \ 67 xyz.openbmc_project.Logging /xyz/openbmc_project/logging \ 68 xyz.openbmc_project.Logging.Create Create "ssa{ss}" "$MESSAGE" \ 69 xyz.openbmc_project.Logging.Entry.Level.Error 0 70} 71 72get_ac_on_status() 73{ 74 RETRY=20 75 while [ $RETRY -gt 0 ] 76 do 77 if [ "$(gpio_get "$1" "$2")" == "$STATE_ON" ] 78 then 79 echo "$STATE_ON" 80 return 0 81 fi 82 RETRY=$((RETRY-1)) 83 sleep 1 84 done 85 echo "$STATE_OFF" 86} 87 88