1#!/bin/sh 2# File which is managing GPIOS when detected. First parameter is which GPIOs that switched 3if [ "$1" = "up" ] 4then 5 busctl set-property xyz.openbmc_project.Chassis.Gpios /xyz/openbmc_project/chassis/gpios xyz.openbmc_project.Chassis.Gpios PGood b true 6 devmem 0x80fc0230 8 0x1 7 sleep 2 8 devmem 0x80fc0230 8 0x1 9 # Activate local UBM (front NVME drive) 10 11 devmem 0xd1000087 8 1 12 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 13 devmem 0xd1000087 8 2 14 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 15 devmem 0xd1000087 8 3 16 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 17 devmem 0xd1000087 8 4 18 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 19 devmem 0xd1000088 8 5 20 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 21 devmem 0xd1000087 8 6 22 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 23 devmem 0xd1000087 8 7 24 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 25 devmem 0xd1000087 8 8 26 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 27 devmem 0xd1000087 8 9 28 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 29 devmem 0xd1000087 8 0xa 30 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 31 devmem 0xd1000087 8 0xb 32 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 33 devmem 0xd1000087 8 0xc 34 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 35 devmem 0xd1000087 8 0xd 36 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 37 devmem 0xd1000087 8 0xe 38 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 39 devmem 0xd1000087 8 0xf 40 i2ctransfer -y 3 w4@0x40 0x34 0xbf 0x00 0xe8 41 42 devmem 0xd1000088 8 3 43 i2ctransfer -y 4 w4@0x40 0x34 0xbf 0x00 0xe8 44 devmem 0xd1000088 8 4 45 i2ctransfer -y 4 w4@0x40 0x34 0xbf 0x00 0xe8 46 47 devmem 0xd100008a 8 0x13 48 i2ctransfer -y 6 w4@0x40 0x34 0xbf 0x00 0xe8 49 devmem 0xd100008a 8 0x14 50 i2ctransfer -y 6 w4@0x40 0x34 0xbf 0x00 0xe8 51 52# systemctl restart xyz.openbmc_project.EntityManager.service 53# systemctl restart phosphor-pid-control.service 54else 55 if [ "$1" = "down" ] 56 then 57 busctl set-property xyz.openbmc_project.Chassis.Gpios /xyz/openbmc_project/chassis/gpios xyz.openbmc_project.Chassis.Gpios PGood b false 58 # We can re-init the system 59 devmem 0xd1000009 8 0x24 60 # We need to check the reason why we have been shutdown 61 shutdownReason=$(devmem 0x80000074 16) 62 # If bit 10 is set Software initiated a shutdown we need to restart 63 isSet2=$(( shutdownReason | 0xFBFF )) 64 if [ "$isSet2" = "65535" ] 65 then 66 echo "Restarting" >> /tmp/gpios 67 dbus-send --system --dest=xyz.openbmc_project.State.Host --print-reply --type=method_call /xyz/openbmc_project/state/host0 org.freedesktop.DBus.Properties.Set string:RequestedHostTransition variant:string:xyz.openbmc_project.State.Host.Transition.On 68 obmcutil poweron 69 fi 70 fi 71fi 72echo "$1" >> /tmp/gpios.txt 73