Jordan Chang | 7cbff67 | 2023-03-03 15:53:28 +0800 | [diff] [blame^] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | HOST_SERVICE="xyz.openbmc_project.State.HostCondition.Gpio" |
| 4 | HOST_OBJPATH="/xyz/openbmc_project/Gpios/host0" |
| 5 | HOST_INTERFACE="xyz.openbmc_project.Condition.HostFirmware" |
| 6 | HOST_PROPERTY="CurrentFirmwareCondition" |
| 7 | |
| 8 | FAN_SERVICE="xyz.openbmc_project.State.FanCtrl" |
| 9 | FAN_OBJPATH="/xyz/openbmc_project/settings/fanctrl/zone1" |
| 10 | FAN_INTERFACE="xyz.openbmc_project.Control.Mode" |
| 11 | FAN_PROPERTY="FailSafe" |
| 12 | |
| 13 | PSU_SERVICE="xyz.openbmc_project.Inventory.Manager" |
| 14 | PSU0_PRESENT_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_PRSNT_L" |
| 15 | PSU1_PRESENT_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_PRSNT_L" |
| 16 | PSU0_POWER_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU0_POWER_OK" |
| 17 | PSU1_POWER_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/motherboard/PSU1_POWER_OK" |
| 18 | PSU_INTERFACE="xyz.openbmc_project.Inventory.Item" |
| 19 | PSU_PROPERTY="Present" |
| 20 | |
| 21 | CPLD_LED_offset1=0x80 |
| 22 | CPLD_LED_offset2=0x81 |
| 23 | CPLD_SYS_FAN_reg=0 |
| 24 | CPLD_PSU0_PSU1_reg=0 |
| 25 | |
| 26 | while true; do |
| 27 | #System status LED |
| 28 | system_status=$(busctl get-property ${HOST_SERVICE} ${HOST_OBJPATH} ${HOST_INTERFACE} ${HOST_PROPERTY} | awk '{print $2}' | tr -d "\"" | awk -F . '{print $NF}') |
| 29 | |
| 30 | if [ "${system_status}" == "Running" ]; then |
| 31 | #Solid Green |
| 32 | CPLD_SYS_reg=0x90 |
| 33 | else |
| 34 | #Solid Yellow |
| 35 | CPLD_SYS_reg=0x80 |
| 36 | fi |
| 37 | |
| 38 | #Fan status LED |
| 39 | fan_status=$(busctl get-property ${FAN_SERVICE} ${FAN_OBJPATH} ${FAN_INTERFACE} ${FAN_PROPERTY} | awk '{print $2}') |
| 40 | |
| 41 | if [ "${fan_status}" == "true" ]; then |
| 42 | #Blink Yellow |
| 43 | CPLD_FAN_reg=0xc |
| 44 | else |
| 45 | #Solid Green |
| 46 | CPLD_FAN_reg=0x9 |
| 47 | fi |
| 48 | |
| 49 | CPLD_SYS_FAN_reg=$((CPLD_SYS_reg | CPLD_FAN_reg)) |
| 50 | |
| 51 | #PSU0 status LED |
| 52 | psu0_prsnt_status=$(busctl get-property ${PSU_SERVICE} ${PSU0_PRESENT_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}') |
| 53 | |
| 54 | psu0_power_status=$(busctl get-property ${PSU_SERVICE} ${PSU0_POWER_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}') |
| 55 | |
| 56 | if [ "${psu0_prsnt_status}" == "true" ]; then |
| 57 | if [ "${psu0_power_status}" == "true" ]; then |
| 58 | #Solid Green |
| 59 | CPLD_PSU0_reg=0x9 |
| 60 | else |
| 61 | #Blink Yellow |
| 62 | CPLD_PSU0_reg=0xc |
| 63 | fi |
| 64 | else |
| 65 | CPLD_PSU0_reg=0x0 |
| 66 | fi |
| 67 | |
| 68 | #PSU1 status LED |
| 69 | psu1_prsnt_status=$(busctl get-property ${PSU_SERVICE} ${PSU1_PRESENT_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}') |
| 70 | |
| 71 | psu1_power_status=$(busctl get-property ${PSU_SERVICE} ${PSU1_POWER_OBJPATH} ${PSU_INTERFACE} ${PSU_PROPERTY} | awk '{print $2}') |
| 72 | |
| 73 | if [ "${psu1_prsnt_status}" == "true" ]; then |
| 74 | if [ "${psu1_power_status}" == "true" ]; then |
| 75 | #Solid Green |
| 76 | CPLD_PSU1_reg=0x90 |
| 77 | else |
| 78 | #Blink Yellow |
| 79 | CPLD_PSU1_reg=0xc0 |
| 80 | fi |
| 81 | else |
| 82 | CPLD_PSU1_reg=0x0 |
| 83 | fi |
| 84 | |
| 85 | CPLD_PSU0_PSU1_reg=$((CPLD_PSU0_reg | CPLD_PSU1_reg)) |
| 86 | |
| 87 | i2cset -f -y 2 0x40 "${CPLD_LED_offset1}" "${CPLD_SYS_FAN_reg}" > /dev/null 2>&1 |
| 88 | i2cset -f -y 2 0x40 "${CPLD_LED_offset2}" "${CPLD_PSU0_PSU1_reg}" > /dev/null 2>&1 |
| 89 | |
| 90 | sleep 2 |
| 91 | done |
| 92 | |
| 93 | exit 0 |