From f2258b4b909e8beb0b27378bb90ce3767660dfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Olguy=20Can=C3=A9us?= Date: Fri, 30 Oct 2020 15:05:28 -0700 Subject: [PATCH] ELBERT: Enhance pim_enable.sh (#105) Summary: ELBERT: Fix PIM8DDM gpio mapping The UCD pins on pim8ddm and pim16q are different, so fixing our pim_enable scripts to toggle this. Also, setting FULL_POWER to 0 currently does nothing, so removing this for now. power_off_pim will simply turn FPGA off. We are tracking investigating improvements to this separately to assess if we need to control power domain as well to reduce power. Testing: pimreset many times pim8ddm/pim16q mixed card system. Pull Request resolved: https://github.com/facebookexternal/openbmc.arista/pull/105 Reviewed By: mikechoifb fbshipit-source-id: 313fbf2e1b --- .../openbmc-utils/files/board-utils.sh | 34 +++++++++++---- .../openbmc-utils/files/pim_enable.sh | 41 ++++++++++++++----- 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/board-utils.sh b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/board-utils.sh index 527d6b5cfab6..d1fa76269205 100644 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/board-utils.sh +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/board-utils.sh @@ -101,15 +101,34 @@ wedge_power_off_board() { power_on_pim() { pim=$1 - old_pwr_value=$(gpio_get PIM"${pim}"_FULL_POWER_EN keepdirection) old_rst_value=$(gpio_get PIM"${pim}"_FPGA_RESET_L keepdirection) - if [ "$old_pwr_value" -eq 1 ] && [ "$old_rst_value" -eq 1 ]; then - logger pim_enable: PIM"${pim}" already powered on + if [ "$old_rst_value" -eq 1 ]; then # already powered on, skip return fi - gpio_set PIM"${pim}"_FULL_POWER_EN 1 # full power on + + # Skip power_on if we are still powercycling + if [ "$(head -n 1 "$SMBCPLD_SYSFS_DIR"/pim_reset)" != '0x0' ]; then + logger pim_enable: skipping power_on_pim. PIM"$pim" is still powercycling + return + fi + + # Skip power_on if the FPGA is still being programmed + pim_major=$(head -n 1 "$SMBCPLD_SYSFS_DIR"/pim"$pim"_fpga_rev_major) + if [ "$((pim_major))" -eq 255 ]; then + logger pim_enable: skipping power_on_pim. PIM"$pim" is fpga loading is not complete + return + fi + + fpga_done_value=$(gpio_get PIM"${pim}"_FPGA_DONE keepdirection) + if [ "$fpga_done_value" -eq 0 ]; then + logger pim_enable: skipping power_on_pim. PIM"$pim" is FPGA_DONE is not ready + return + fi + + sleep 0.5 # Give FPGA some time to finish initialization gpio_set PIM"${pim}"_FPGA_RESET_L 1 # FPGA out of reset + sleep 0.1 skip_pim_off_cache=$2 pim_off_cache="/tmp/.pim${pim}_powered_off" @@ -121,15 +140,14 @@ power_on_pim() { power_off_pim() { pim=$1 - old_pwr_value=$(gpio_get PIM"${pim}"_FULL_POWER_EN keepdirection) old_rst_value=$(gpio_get PIM"${pim}"_FPGA_RESET_L keepdirection) - if [ "$old_pwr_value" -eq 0 ] && [ "$old_rst_value" -eq 0 ]; then - logger pim_enable: PIM"${pim}" already powered off + if [ "$old_rst_value" -eq 0 ]; then # already powered off, skip return fi + gpio_set PIM"${pim}"_FPGA_RESET_L 0 # FPGA in reset - gpio_set PIM"${pim}"_FULL_POWER_EN 0 # full power off + sleep 0.1 skip_pim_off_cache=$2 pim_off_cache="/tmp/.pim${pim}_powered_off" diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/pim_enable.sh b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/pim_enable.sh index 60de30c6a849..042df9ae2582 100644 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/pim_enable.sh +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/pim_enable.sh @@ -31,23 +31,41 @@ pim_found=(0 0 0 0 0 0 0 0) pim_bus=(16 17 18 23 20 21 22 19) dpm_addr=4e +try_create_gpio() { + chip="$1" + pin_id="$2" + gpioname="$3" + + # Export GPIO if it doesn't exist + gpio_num=$(gpio_name2value "$gpioname") + if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then + gpio_export_by_offset "${chip}" "$pin_id" "$gpioname" + fi +} + create_pim_gpio() { local pim pim=$1 chip=$2 - # Check if GPIO name has already been exported - gpio_num=$(gpio_name2value PIM"${pim}"_FULL_POWER_EN) - if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then - gpio_export_by_offset "${chip}" 4 PIM"${pim}"_FULL_POWER_EN + fru="$(peutil "$pim" 2>&1)" + if echo "$fru" | grep -q '88-16CD'; then + pim_type='PIM16Q' + try_create_gpio "$chip" 22 PIM"$pim"_FPGA_RESET_L # GPIO17 PIN26 + try_create_gpio "$chip" 4 PIM"$pim"_FULL_POWER_EN # GPIO9 PIN14 + try_create_gpio "$chip" 20 PIM"$pim"_FPGA_DONE # GPIO15 PIN24 + try_create_gpio "$chip" 21 PIM"$pim"_FPGA_INIT # GPIO16 PIN25 + elif echo "$fru" | grep -q '88-8D'; then + pim_type='PIM8DDM' + try_create_gpio "$chip" 22 PIM"$pim"_FPGA_RESET_L # GPIO17 PIN26 + try_create_gpio "$chip" 8 PIM"$pim"_FULL_POWER_EN # GPI1 PIN22 + try_create_gpio "$chip" 20 PIM"$pim"_FPGA_DONE # GPIO15 PIN24 + try_create_gpio "$chip" 21 PIM"$pim"_FPGA_INIT # GPIO16 PIN25 + else + logger pim_enable: Could not identify PIM"${pim}" model + return fi - - gpio_num=$(gpio_name2value PIM"${pim}"_FPGA_RESET_L) - if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then - gpio_export_by_offset "${chip}" 22 PIM"${pim}"_FPGA_RESET_L - fi - - logger pim_enable: registered PIM"${pim}" with GPIO chip "${chip}" + logger pim_enable: registered "${pim_type}" PIM"${pim}" with GPIO chip "${chip}" } # Clear pimserial endpoint cache if pim doesn't exist but the pimserial file does @@ -83,6 +101,7 @@ while true; do fi fi done + # 2. For discovered gpios, try turning it on for i in "${pim_index[@]}" do