blob: 44ed0dcc5da26e5f3584063e27574c67a12d78b5 [file] [log] [blame]
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +05301#!/bin/bash
2
3export POWER_BTN_HIGH=0xFF
4export POWER_BTN_LOW=0xFE
Delphine CC Chiu0528ecd2022-11-03 15:40:43 +08005export RESET_BTN_HIGH=0xFF
6export RESET_BTN_LOW=0xFD
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +05307export power_seq=( "$POWER_BTN_HIGH" "$POWER_BTN_LOW" "$POWER_BTN_HIGH" )
Delphine CC Chiu0528ecd2022-11-03 15:40:43 +08008export reset_seq=( "$RESET_BTN_HIGH" "$RESET_BTN_LOW" "$RESET_BTN_HIGH")
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +05309export SERVICE="xyz.openbmc_project.Ipmi.Channel.Ipmb"
10export OBJECT_PATH="/xyz/openbmc_project/Ipmi/Channel/Ipmb"
11export INTERFACE="org.openbmc.Ipmb"
12export DATA_LEN=0x05
13export NETFN=0x06
14export LUN=0x00
15export CMD=0x52
16export STATE_OFF=0
17export STATE_ON=1
Delphine CC Chiu17539d82023-03-09 15:27:47 +080018export STATE_UNKNOWN=-1
19export CPLD_BUS_NUM=12
20export CPLD_PWR_CTRL_ADDR=0xf
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +053021export POW_ON_SLOT=0x01
22export POW_OFF_SLOT=0x00
Karthikeyan Pasupathi36f035b2022-08-28 17:35:29 +053023export PWRGD_SYS_PWROK_INDEX=12
Delphine CC Chiubed86692023-02-22 13:17:37 +080024export IANA="0x15 0xA0 0x0"
25export IANA_LEN=3
26export CHASSIS_BUS_NAME="xyz.openbmc_project.State.Chassis"
27export CHASSIS_OBJ_PATH="/xyz/openbmc_project/state/chassis"
28export CHASSIS_INTF_NAME="xyz.openbmc_project.State.Chassis"
29export CHASSIS_PROPERTY_NAME="CurrentPowerState"
30export HOST_BUS_NAME="xyz.openbmc_project.State.Host"
31export HOST_OBJ_PATH="/xyz/openbmc_project/state/host"
32export HOST_INTF_NAME="xyz.openbmc_project.State.Host"
33export HOST_PROPERTY_NAME="CurrentHostState"
Delphine CC Chiu17539d82023-03-09 15:27:47 +080034export CHASSIS_ON="xyz.openbmc_project.State.Chassis.PowerState.On"
35export CHASSIS_OFF="xyz.openbmc_project.State.Chassis.PowerState.Off"
36export HOST_ON="xyz.openbmc_project.State.Host.HostState.Running"
37export HOST_OFF="xyz.openbmc_project.State.Host.HostState.Off"
BonnieLo-wiwynn052ee412023-03-31 14:27:50 +080038export IPMB_CMD_COMPLETE_CODE_INDEX=2
Delphine CC Chiubed86692023-02-22 13:17:37 +080039
Delphine CC Chiu17539d82023-03-09 15:27:47 +080040host-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
53chassis-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}