From 79eefc6f71c8052982e259d97527302442e1c8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Olguy=20Can=C3=A9us?= Date: Fri, 9 Oct 2020 15:22:00 -0700 Subject: [PATCH] ELBERT: SCM fpga upgrade keeps x86 state (#95) Summary: ELBERT: SCM fpga upgrade keeps x86 state Previously, SCM fpga upgrades would reset the x86 enable register to the default which is x86 off. To prevent this, we need to latch and restore the x86 reset signal when programming scm fpga. Testing: Before this image: an upgrade would cause x86 to go down until reboot/powercycle After this image: Downgrade/Upgraded and confirmed that x86 stays up. Repeated 30 times. Pull Request resolved: https://github.com/facebookexternal/openbmc.arista/pull/95 Reviewed By: benwei13 fbshipit-source-id: d69748af68 --- .../openbmc-utils/files/fpga_util.sh | 18 +++++++++++++++++- .../openbmc-utils/files/setup_i2c.sh | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh index c3899367d4ee..aa4c638a0b2e 100644 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh @@ -6,6 +6,7 @@ CPLD_JTAG_SEL_L="CPLD_JTAG_SEL_L" JTAG_TRST_L="JTAG_TRST_L" +SCM_FPGA_LATCH_L="SCM_FPGA_LATCH_L" JTAG_EN="${SCMCPLD_SYSFS_DIR}/jtag_en" PROGRAM_SEL="${SCMCPLD_SYSFS_DIR}/program_sel" SPI_CTRL="${SMBCPLD_SYSFS_DIR}/spi_ctrl" @@ -16,6 +17,7 @@ SMB_SPIDEV="spidev1.1" SCM_PROGRAM=false SMB_PROGRAM=false +CACHED_SCM_PWR_ON_SYSFS="0x1" trap disconnect_program_paths INT TERM QUIT EXIT @@ -33,10 +35,20 @@ disconnect_program_paths() { # Return values to defaults gpio_set_value $CPLD_JTAG_SEL_L 1 gpio_set_value $JTAG_TRST_L 0 - if [ "$SCM_PROGRAM" = false ]; then + if [ "$SCM_PROGRAM" = true ]; then + # Give SCM cpld time to come back on SMBus + sleep 2 + # Restore x86 power state + echo "$CACHED_SCM_PWR_ON_SYSFS" > "$SCM_PWR_ON_SYSFS" || { + echo "Failed to recover CPU power state." + } + sleep 1 + gpio_set_value $SCM_FPGA_LATCH_L 1 + else echo 0 > "$JTAG_EN" echo 1 > "$PROGRAM_SEL" fi + if [ "$SMB_PROGRAM" = false ]; then echo 0 > "$SPI_CTRL" echo 0 > "$JTAG_CTRL" @@ -44,6 +56,10 @@ disconnect_program_paths() { } connect_scm_jtag() { + # Store initial state of x86 power in order to restore after programming + CACHED_SCM_PWR_ON_SYSFS="$(head -n 1 "$SCM_PWR_ON_SYSFS" 2> /dev/null)" + gpio_set_value $SCM_FPGA_LATCH_L 0 + gpio_set_value $CPLD_JTAG_SEL_L 0 gpio_set_value $JTAG_TRST_L 1 echo 0 > "$JTAG_EN" diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/setup_i2c.sh b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/setup_i2c.sh index 3e57aac336ac..1c09e37c73d9 100644 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/setup_i2c.sh +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/setup_i2c.sh @@ -91,6 +91,7 @@ i2c_device_add 7 0x50 24c512 # SMBus 9 SCM DPM UCD90320 hwmon_device_add 9 0x11 ucd90320 +gpio_export_by_offset 9-0011 13 SCM_FPGA_LATCH_L # SMBus 10 SCM POWER i2c_device_add 10 0x30 cpupwr