1#!/bin/bash 2# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions 3source /usr/libexec/yosemite4-common-functions 4echo "Start rescan-fru-oct-setting" 5# We observed that the rescan service would be execute during BMC 6# boot up, and the entity-manager might remove and add inventories 7# again. It caused pldmd fail to get inventories sometimes. 8# Therefore, we temporary add bmc-ready check before we clarify the 9# and fix entity-manager unexpected behavior. 10bmc_ready=$(busctl get-property xyz.openbmc_project.State.BMC /xyz/openbmc_project/state/bmc0 xyz.openbmc_project.State.BMC CurrentBMCState | awk '{print $2}' | tr -d '"') 11if [ "$bmc_ready" != "xyz.openbmc_project.State.BMC.BMCState.Ready" ]; then 12 echo "BMC is not ready, exiting..." 13 exit 0 14fi 15 16sleep 2 17bus=$(($1 + 15)) 18echo "Start rescan slot $1 fru bus $bus." 19# rescan eeprom for fru information 20busctl call xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice xyz.openbmc_project.FruDeviceManager ReScanBus q $bus --timeout=120 21echo "End rescan slot $1 fru bus $bus for fru removal." 22# wait for fru device to be ready 23sleep 10 24# check if Wailua Falls is present 25wailua_falls_present=$(busctl tree xyz.openbmc_project.FruDevice | grep Wailua_Falls) 26# set 48V/12V HSC OCP values 27if [ -n "$wailua_falls_present" ]; then 28 set_gpio P48V_OCP_GPIO1 0 29 set_gpio P48V_OCP_GPIO2 0 30 set_gpio P48V_OCP_GPIO3 0 31 set_gpio HSC_OCP_SLOT_ODD_GPIO1 1 32 set_gpio HSC_OCP_SLOT_ODD_GPIO2 0 33 set_gpio HSC_OCP_SLOT_ODD_GPIO3 0 34 set_gpio HSC_OCP_SLOT_EVEN_GPIO1 1 35 set_gpio HSC_OCP_SLOT_EVEN_GPIO2 0 36 set_gpio HSC_OCP_SLOT_EVEN_GPIO3 0 37else 38 set_gpio P48V_OCP_GPIO1 1 39 set_gpio P48V_OCP_GPIO2 0 40 set_gpio P48V_OCP_GPIO3 0 41 set_gpio HSC_OCP_SLOT_ODD_GPIO1 0 42 set_gpio HSC_OCP_SLOT_ODD_GPIO2 1 43 set_gpio HSC_OCP_SLOT_ODD_GPIO3 0 44 set_gpio HSC_OCP_SLOT_EVEN_GPIO1 0 45 set_gpio HSC_OCP_SLOT_EVEN_GPIO2 1 46 set_gpio HSC_OCP_SLOT_EVEN_GPIO3 0 47fi 48echo "End slot $1 rescan-fru-oct-setting" 49