meta-facebook: yosemite4: set powerstate to off during power cycling
Set property of corresponding powerstate to off when chassis/host is
powered off to represent the real state during power cycling.
Add 2 seconds delay before setting the chassis on property to wait for
the standby sensors to be ready to read.
Change-Id: I217101b4ccec8c6e382fcfe44be3618989cf9e59
Signed-off-by: Bright Cheng <bright.cheng.wiwynn@gmail.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle
index 4b63347..ff5cb6e 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle
@@ -146,6 +146,9 @@
echo "${msg}"
add_sel "${msg}"
fi
+ # Set chassis power state off
+ busctl set-property "$CHASSIS_BUS_NAME""$CHASSIS_ID" "$CHASSIS_OBJ_PATH""$CHASSIS_ID" "$CHASSIS_INTF_NAME" "$CHASSIS_PROPERTY_NAME" s "$CHASSIS_OFF_PROPERTY"
+
sleep 20
fi
if ! gpio_set "$GPIOCHIP_IO_EXP_SLOT_PWR_CTRL" "$IO_EXP_SLOT_PWR_CTRL"=0
@@ -169,6 +172,9 @@
fi
fi
enable_i3c_hub
+
+ # Wait for standby sensors to be ready
+ sleep 2
busctl set-property "$CHASSIS_BUS_NAME""$CHASSIS_ID" "$CHASSIS_OBJ_PATH""$CHASSIS_ID" "$CHASSIS_INTF_NAME" "$CHASSIS_PROPERTY_NAME" s "$CHASSIS_ON_PROPERTY"
/usr/libexec/phosphor-state-manager/wait-until-mctp-connection-done "$CHASSIS_ID" && systemctl restart "phosphor-discover-system-state@$CHASSIS_ID.service"
msg="Chassis$CHASSIS_ID cycle success"
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron
index fb4b3a9..f0c9c0d 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron
@@ -91,6 +91,9 @@
fi
fi
enable_i3c_hub
+
+ # Wait for standby sensors to be ready
+ sleep 2
busctl set-property "$CHASSIS_BUS_NAME""$CHASSIS_ID" "$CHASSIS_OBJ_PATH""$CHASSIS_ID" "$CHASSIS_INTF_NAME" "$CHASSIS_PROPERTY_NAME" s "$CHASSIS_ON_PROPERTY"
echo "Chassis$CHASSIS_ID is power on"
else
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/host-powercycle b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/host-powercycle
index 2e7d316..ad7852a 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/host-powercycle
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/host-powercycle
@@ -27,6 +27,10 @@
if [ "$host_status" == "$STATE_ON" ]; then
# Set state effecter state: Entity ID 0x0000 for host power control, 0x2 for power off
pldmtool raw -d 0x80 0x02 0x39 0x00 0x00 0x01 0x00 0x02 -m "$EID"
+
+ # Set host state to off
+ busctl set-property "$HOST_BUS_NAME""$CHASSIS_ID" "$HOST_OBJ_PATH""$CHASSIS_ID" "$HOST_INTF_NAME" "$HOST_PROPERTY_NAME" s "$HOST_OFF_PROPERTY"
+
# Wait for the host to power off
sleep 10s
@@ -34,6 +38,7 @@
get_host_status
if [ "$host_status" != "$STATE_OFF" ]; then
+ busctl set-property "$HOST_BUS_NAME""$CHASSIS_ID" "$HOST_OBJ_PATH""$CHASSIS_ID" "$HOST_INTF_NAME" "$HOST_PROPERTY_NAME" s "$HOST_ON_PROPERTY"
msg="Do power cycle fail, fail to set host$CHASSIS_ID power off"
echo "${msg}"
add_sel "${msg}"
@@ -55,6 +60,9 @@
add_sel "${msg}"
exit 1
fi
+
+ # Set host state to on
+ busctl set-property "$HOST_BUS_NAME""$CHASSIS_ID" "$HOST_OBJ_PATH""$CHASSIS_ID" "$HOST_INTF_NAME" "$HOST_PROPERTY_NAME" s "$HOST_ON_PROPERTY"
fi
msg="Host$1 power cycle success"
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
index 62a9395..ec7e9a9 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
@@ -17,6 +17,12 @@
export CHASSIS_PROPERTY_NAME="CurrentPowerState"
export CHASSIS_ON_PROPERTY="xyz.openbmc_project.State.Chassis.PowerState.On"
export CHASSIS_OFF_PROPERTY="xyz.openbmc_project.State.Chassis.PowerState.Off"
+export HOST_BUS_NAME="xyz.openbmc_project.State.Host"
+export HOST_OBJ_PATH="/xyz/openbmc_project/state/host"
+export HOST_INTF_NAME="xyz.openbmc_project.State.Host"
+export HOST_PROPERTY_NAME="CurrentHostState"
+export HOST_ON_PROPERTY="xyz.openbmc_project.State.Host.HostState.Running"
+export HOST_OFF_PROPERTY="xyz.openbmc_project.State.Host.HostState.Off"
MANAGEMENT_BOARD_VERSION=$(get_product_version Management_Board)
if [ "$MANAGEMENT_BOARD_VERSION" = "DVT" ] || [ "$MANAGEMENT_BOARD_VERSION" = "EVT" ]; then