Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | export POWER_BTN_HIGH=0xFF |
| 4 | export POWER_BTN_LOW=0xFE |
Delphine CC Chiu | 0528ecd | 2022-11-03 15:40:43 +0800 | [diff] [blame] | 5 | export RESET_BTN_HIGH=0xFF |
| 6 | export RESET_BTN_LOW=0xFD |
Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 7 | export power_seq=( "$POWER_BTN_HIGH" "$POWER_BTN_LOW" "$POWER_BTN_HIGH" ) |
Delphine CC Chiu | 0528ecd | 2022-11-03 15:40:43 +0800 | [diff] [blame] | 8 | export reset_seq=( "$RESET_BTN_HIGH" "$RESET_BTN_LOW" "$RESET_BTN_HIGH") |
Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 9 | export SERVICE="xyz.openbmc_project.Ipmi.Channel.Ipmb" |
| 10 | export OBJECT_PATH="/xyz/openbmc_project/Ipmi/Channel/Ipmb" |
| 11 | export INTERFACE="org.openbmc.Ipmb" |
| 12 | export DATA_LEN=0x05 |
| 13 | export NETFN=0x06 |
| 14 | export LUN=0x00 |
| 15 | export CMD=0x52 |
| 16 | export STATE_OFF=0 |
| 17 | export STATE_ON=1 |
Delphine CC Chiu | 17539d8 | 2023-03-09 15:27:47 +0800 | [diff] [blame] | 18 | export STATE_UNKNOWN=-1 |
| 19 | export CPLD_BUS_NUM=12 |
| 20 | export CPLD_PWR_CTRL_ADDR=0xf |
Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 21 | export POW_ON_SLOT=0x01 |
| 22 | export POW_OFF_SLOT=0x00 |
Karthikeyan Pasupathi | 36f035b | 2022-08-28 17:35:29 +0530 | [diff] [blame] | 23 | export PWRGD_SYS_PWROK_INDEX=12 |
Delphine CC Chiu | bed8669 | 2023-02-22 13:17:37 +0800 | [diff] [blame] | 24 | export IANA="0x15 0xA0 0x0" |
| 25 | export IANA_LEN=3 |
| 26 | export CHASSIS_BUS_NAME="xyz.openbmc_project.State.Chassis" |
| 27 | export CHASSIS_OBJ_PATH="/xyz/openbmc_project/state/chassis" |
| 28 | export CHASSIS_INTF_NAME="xyz.openbmc_project.State.Chassis" |
| 29 | export CHASSIS_PROPERTY_NAME="CurrentPowerState" |
| 30 | export HOST_BUS_NAME="xyz.openbmc_project.State.Host" |
| 31 | export HOST_OBJ_PATH="/xyz/openbmc_project/state/host" |
| 32 | export HOST_INTF_NAME="xyz.openbmc_project.State.Host" |
| 33 | export HOST_PROPERTY_NAME="CurrentHostState" |
Delphine CC Chiu | 17539d8 | 2023-03-09 15:27:47 +0800 | [diff] [blame] | 34 | export CHASSIS_ON="xyz.openbmc_project.State.Chassis.PowerState.On" |
| 35 | export CHASSIS_OFF="xyz.openbmc_project.State.Chassis.PowerState.Off" |
| 36 | export HOST_ON="xyz.openbmc_project.State.Host.HostState.Running" |
| 37 | export HOST_OFF="xyz.openbmc_project.State.Host.HostState.Off" |
BonnieLo-wiwynn | 052ee41 | 2023-03-31 14:27:50 +0800 | [diff] [blame] | 38 | export IPMB_CMD_COMPLETE_CODE_INDEX=2 |
Delphine CC Chiu | bed8669 | 2023-02-22 13:17:37 +0800 | [diff] [blame] | 39 | |
Delphine CC Chiu | 17539d8 | 2023-03-09 15:27:47 +0800 | [diff] [blame] | 40 | host-power-status() |
| 41 | { |
| 42 | SLOT_ID=$1 |
| 43 | |
| 44 | response="$(busctl call "$SERVICE" "$OBJECT_PATH" "$INTERFACE" sendRequest yyyyay "$SLOT_ID" 0x38 "$LUN" 0x03 0x03 0x15 0xa0 0x00)" |
| 45 | result=$(echo "$response" | cut -d" " -f "$PWRGD_SYS_PWROK_INDEX") |
| 46 | res="$(( "$result" & 0x80 ))" |
| 47 | status="$(( "$res" >> 7 ))" |
| 48 | |
| 49 | echo "$status" |
| 50 | return 0 |
| 51 | } |
| 52 | |
| 53 | chassis-power-status() |
| 54 | { |
| 55 | slot=$1 |
| 56 | status=-1 |
| 57 | |
| 58 | if [ "$slot" -le 4 ] |
| 59 | then |
| 60 | response="$(i2cget -y "$CPLD_BUS_NUM" "$CPLD_PWR_CTRL_ADDR" 0x25)" |
| 61 | res="$(( "$response" >> slot ))" |
| 62 | status="$(( "$res" & 0x01 ))" |
| 63 | fi |
| 64 | |
| 65 | echo "$status" |
| 66 | return 0 |
| 67 | } |