blob: 234423e46e08d41d84675077d29ff273dcdde4b2 [file] [log] [blame]
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +05301#!/bin/bash
2
3# Provide source directive to shellcheck.
4# shellcheck source=meta-facebook/recipes-phosphor/state/phosphor-state-manager/greatlakes/power-cmd
5source /usr/libexec/power-cmd
6
7SLOT_ID=$(( $1-1 << 2 ))
8# Host Power On
9host-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
25host-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}
39host-power-status