11a69cc1eSPeterHo-wiwynn#!/bin/bash 21a69cc1eSPeterHo-wiwynn# shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions 31a69cc1eSPeterHo-wiwynnsource /usr/libexec/yosemite4-common-functions 4*c134a4c1SEric Yangecho "Start rescan-fru-oct-setting" 564273a49SPeterHo-wiwynn# We observed that the rescan service would be execute during BMC 664273a49SPeterHo-wiwynn# boot up, and the entity-manager might remove and add inventories 764273a49SPeterHo-wiwynn# again. It caused pldmd fail to get inventories sometimes. 864273a49SPeterHo-wiwynn# Therefore, we temporary add bmc-ready check before we clarify the 964273a49SPeterHo-wiwynn# and fix entity-manager unexpected behavior. 1064273a49SPeterHo-wiwynnbmc_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 '"') 1164273a49SPeterHo-wiwynnif [ "$bmc_ready" != "xyz.openbmc_project.State.BMC.BMCState.Ready" ]; then 1264273a49SPeterHo-wiwynn echo "BMC is not ready, exiting..." 1364273a49SPeterHo-wiwynn exit 0 1464273a49SPeterHo-wiwynnfi 1564273a49SPeterHo-wiwynn 16*c134a4c1SEric Yangsleep 2 171a69cc1eSPeterHo-wiwynnbus=$(($1 + 15)) 18*c134a4c1SEric Yangecho "Start rescan slot $1 fru bus $bus." 191a69cc1eSPeterHo-wiwynn# rescan eeprom for fru information 20*c134a4c1SEric Yangbusctl call xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice xyz.openbmc_project.FruDeviceManager ReScanBus q $bus --timeout=120 21*c134a4c1SEric Yangecho "End rescan slot $1 fru bus $bus for fru removal." 221a69cc1eSPeterHo-wiwynn# wait for fru device to be ready 231a69cc1eSPeterHo-wiwynnsleep 10 241a69cc1eSPeterHo-wiwynn# check if Wailua Falls is present 251a69cc1eSPeterHo-wiwynnwailua_falls_present=$(busctl tree xyz.openbmc_project.FruDevice | grep Wailua_Falls) 261a69cc1eSPeterHo-wiwynn# set 48V/12V HSC OCP values 271a69cc1eSPeterHo-wiwynnif [ -n "$wailua_falls_present" ]; then 281a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO1 0 291a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO2 0 301a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO3 0 311a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO1 1 321a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO2 0 331a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO3 0 341a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO1 1 351a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO2 0 361a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO3 0 371a69cc1eSPeterHo-wiwynnelse 381a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO1 1 391a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO2 0 401a69cc1eSPeterHo-wiwynn set_gpio P48V_OCP_GPIO3 0 411a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO1 0 421a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO2 1 431a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_ODD_GPIO3 0 441a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO1 0 451a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO2 1 461a69cc1eSPeterHo-wiwynn set_gpio HSC_OCP_SLOT_EVEN_GPIO3 0 471a69cc1eSPeterHo-wiwynnfi 48*c134a4c1SEric Yangecho "End slot $1 rescan-fru-oct-setting" 49