meta-facebook: yosemite4: state: inform MGM CPLD the 12V status of slots
Add this for yosemite4n only to inform MGM CPLD the 12V status of slots
when doing 12V power control.
Tested:
Run all chassis-poweron/chassis-poweroff/chassis-powercycle pass.
Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: I8318af7136d88f122c4ba5878bfddb6a0390c7e0
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 f31f3d4..5566ba5 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
@@ -5,6 +5,9 @@
# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
source /usr/libexec/phosphor-state-manager/power-cmd
+# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
+source /usr/libexec/yosemite4-common-functions
+
#IO 0:7 input port for showing slot 1:8 power status
#IO 8:16 output port for controlling slot 1:8 power status
CHASSIS_ID=$1
@@ -12,11 +15,15 @@
IO_EXP_SLOT_PWR_CTRL=$((IO_EXP_SLOT_PWR_STATUS + 8))
IO_EXP_SLED_CYCLE=12
#IO_EXP_BIC_PWR_CTRL=32
+IO_EXP_SLOT_12V_STATUS=$((CHASSIS_ID + 23))
GPIOCHIP_IO_EXP_SLOT_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$SPIDER_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLOT_PWR_CTRL_ADDR/"*gpiochip*)
GPIOCHIP_IO_EXP_SLED_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$MANAGEMENT_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLED_PWR_CTRL_ADDR/"*gpiochip*)
#GPIOCHIP_IO_EXP_BIC_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$IO_EXP_SLOT_PWR_STATUS-00$IO_EXP_BIC_PWR_CTRL_ADDR/"*gpiochip*)
+check_nuvoton_board
+is_nuvoton_board=$?
+
chassis-power-cycle()
{
CHASSIS_ID=$1
@@ -26,6 +33,14 @@
chassis_status=$(gpio_get "$GPIOCHIP_IO_EXP_SLOT_PWR_CTRL" "$IO_EXP_SLOT_PWR_STATUS")
if [ "$chassis_status" == "$STATE_ON" ]
then
+ if [ "$is_nuvoton_board" -eq "1" ]
+ then
+ # inform management CPLD that the slot is 12V off
+ if ! gpio_set "$GPIOCHIP_IO_EXP_SLED_PWR_CTRL" "$IO_EXP_SLOT_12V_STATUS"=0
+ then
+ echo "Failed to inform management CPLD that slot$1 is 12V off"
+ fi
+ fi
sleep 1
if ! gpio_set "$GPIOCHIP_IO_EXP_SLOT_PWR_CTRL" "$IO_EXP_SLOT_PWR_CTRL"=1
then
@@ -43,6 +58,14 @@
chassis_status=$(gpio_get "$GPIOCHIP_IO_EXP_SLOT_PWR_CTRL" "$IO_EXP_SLOT_PWR_STATUS")
if [ "$chassis_status" == "$STATE_ON" ]
then
+ if [ "$is_nuvoton_board" -eq "1" ]
+ then
+ # inform management CPLD that the slot is 12V on
+ if ! gpio_set "$GPIOCHIP_IO_EXP_SLED_PWR_CTRL" "$IO_EXP_SLOT_12V_STATUS"=1
+ then
+ echo "Failed to inform management CPLD that slot$1 is 12V on"
+ fi
+ fi
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"
echo "Chassis$CHASSIS_ID cycle success"
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff
index 615c68e..3bfb5ec 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweroff
@@ -5,15 +5,23 @@
# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
source /usr/libexec/phosphor-state-manager/power-cmd
+# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
+source /usr/libexec/yosemite4-common-functions
+
#IO 0:7 input port for showing slot 1:8 power status
#IO 8:16 output port for controlling slot 1:8 power status
CHASSIS_ID=$1
IO_EXP_SLOT_PWR_STATUS=$((CHASSIS_ID - 1))
IO_EXP_SLOT_PWR_CTRL=$((IO_EXP_SLOT_PWR_STATUS + 8))
#IO_EXP_BIC_PWR_CTRL=32
+IO_EXP_SLOT_12V_STATUS=$((CHASSIS_ID + 23))
GPIOCHIP_IO_EXP_SLOT_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$SPIDER_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLOT_PWR_CTRL_ADDR/"*gpiochip*)
#GPIOCHIP_IO_EXP_BIC_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$IO_EXP_SLOT_PWR_STATUS-00$IO_EXP_BIC_PWR_CTRL_ADDR/"*gpiochip*)
+GPIOCHIP_IO_EXP_SLOT_12V_STATUS_CTRL=$(basename "/sys/bus/i2c/devices/$MANAGEMENT_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLED_PWR_CTRL_ADDR/"*gpiochip*)
+
+check_nuvoton_board
+is_nuvoton_board=$?
# Server 12v power off
chassis-power-off()
@@ -47,6 +55,14 @@
if [ "$chassis_status" == "$STATE_ON" ]
then
+ if [ "$is_nuvoton_board" -eq "1" ]
+ then
+ # inform management CPLD that the slot is 12V off
+ if ! gpio_set "$GPIOCHIP_IO_EXP_SLOT_12V_STATUS_CTRL" "$IO_EXP_SLOT_12V_STATUS"=0
+ then
+ echo "Failed to inform management CPLD that slot$1 is 12V off"
+ fi
+ fi
chassis-power-off
exit 0;
else
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 fd9860c..14b9bab 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
@@ -5,14 +5,21 @@
# Provide source directive to shellcheck.
# shellcheck source=meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/power-cmd
source /usr/libexec/phosphor-state-manager/power-cmd
+# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
+source /usr/libexec/yosemite4-common-functions
GPIOCHIP_IO_EXP_SLOT_PWR_CTRL=$(basename "/sys/bus/i2c/devices/$SPIDER_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLOT_PWR_CTRL_ADDR/"*gpiochip*)
+GPIOCHIP_IO_EXP_SLOT_12V_STATUS_CTRL=$(basename "/sys/bus/i2c/devices/$MANAGEMENT_BOARD_IO_EXP_BUS_NUM-00$IO_EXP_SLED_PWR_CTRL_ADDR/"*gpiochip*)
#IO 0:7 input port for showing slot 1:8 power status
#IO 8:16 output port for controlling slot 1:8 power status
CHASSIS_ID=$1
IO_EXP_SLOT_PWR_STATUS=$((CHASSIS_ID - 1))
IO_EXP_SLOT_PWR_CTRL=$((IO_EXP_SLOT_PWR_STATUS + 8))
+IO_EXP_SLOT_12V_STATUS=$((CHASSIS_ID + 23))
+
+check_nuvoton_board
+is_nuvoton_board=$?
# Server 12v power on
chassis-power-on()
@@ -27,6 +34,14 @@
chassis_status=$(gpio_get "$GPIOCHIP_IO_EXP_SLOT_PWR_CTRL" "$IO_EXP_SLOT_PWR_STATUS")
if [ "$chassis_status" == "$STATE_ON" ]
then
+ if [ "$is_nuvoton_board" -eq "1" ]
+ then
+ # inform management CPLD that the slot is 12V off
+ if ! gpio_set "$GPIOCHIP_IO_EXP_SLOT_12V_STATUS_CTRL" "$IO_EXP_SLOT_12V_STATUS"=1
+ then
+ echo "Failed to inform management CPLD that slot$1 is 12V off"
+ fi
+ fi
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$1 is power on"
else