summaryrefslogtreecommitdiff
path: root/meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/host-poweroff
blob: 70e8474cedb7e625b293ee24bf7078b1b3e87c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash

# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/power-cmd
source /usr/libexec/phosphor-state-manager/power-cmd

SLOT_ID=$(( $1-1  << 2 ))

# Host Power Off
host-power-off()
{
        for pwr_cmd in "${power_seq[@]}"
        do
             result="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID $NETFN $LUN $CMD $DATA_LEN 0x01 0x42 0x01 0x00 "$pwr_cmd")"
             echo "$result"
             if [ "$pwr_cmd" == $POWER_BTN_LOW ]
             then
                     sleep 6
             fi
        done
        echo "Host power off"
        exit 0;
}

# Check Host Response and Status
host-power-status()
{
   response="$(busctl call $SERVICE $OBJECT_PATH $INTERFACE sendRequest yyyyay $SLOT_ID 0x38 $LUN 0x3 0x03 0x15 0xa0 0x00)"

   result=$(echo "$response" | cut -d" " -f $PWRGD_SYS_PWROK_INDEX)
   res="$(( "$result" & 0x80  ))"
   pgood="$(( "$res" >> 7 ))"
   if [ "$pgood" == $STATE_ON ]
   then
         host-power-off
   fi
   echo "Power is already off"
   exit 1;
}
host-power-status