Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Provide source directive to shellcheck. |
| 4 | # shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/power-cmd |
| 5 | source /usr/libexec/power-cmd |
| 6 | |
| 7 | SLOT_ID=$(( $1-1 << 2 )) |
| 8 | # Host Power On |
| 9 | host-power-on() |
| 10 | { |
| 11 | for pwr_cmd in "${power_seq[@]}" |
| 12 | do |
| 13 | result="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID $NETFN $LUN $CMD $DATA_LEN 0x01 0x42 0x01 0x00 "$pwr_cmd")" |
| 14 | echo "$result" |
| 15 | if [ "$pwr_cmd" == $POWER_BTN_LOW ] |
| 16 | then |
| 17 | sleep 2 |
| 18 | fi |
| 19 | done |
| 20 | echo "Host power on" |
| 21 | exit 0; |
| 22 | } |
| 23 | |
| 24 | # Check Host Response and Status |
| 25 | host-power-status() |
| 26 | { |
| 27 | response="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID 0x38 $LUN 0x03 0x03 0x15 0xa0 0x00)" |
| 28 | |
| 29 | result=$(echo "$response" | cut -d" " -f $PWRGD_SYS_PWROK_INDEX) |
| 30 | res="$(( "$result" & 0x80 ))" |
| 31 | pgood="$(( "$res" >> 7 ))" |
| 32 | if [ "$pgood" == $STATE_OFF ] |
| 33 | then |
| 34 | host-power-on |
| 35 | fi |
| 36 | echo "Power is already on" |
| 37 | exit 1; |
| 38 | } |
| 39 | host-power-status |