summaryrefslogtreecommitdiff
path: root/meta-fii
diff options
context:
space:
mode:
authorKyle Nieman <kyle.nieman@fii-na.com>2023-04-18 19:09:08 +0300
committerVivekanand Veeracholan <vveerach@google.com>2023-07-01 01:28:58 +0300
commite35ee53d018610b54784168ee9c118fa0be5d459 (patch)
tree3a4bff1b04fa1109bef9b68e2ef78a4b752de757 /meta-fii
parent75da98cb79a684abcf4af88858a1c3d3d474a423 (diff)
downloadopenbmc-e35ee53d018610b54784168ee9c118fa0be5d459.tar.xz
meta-fii: meta-mori: Add BIOS accessing library functions
The BMC accesses the BIOS SPI during flashing, but the BMC will potentially need to access it while the host is running. Add library functions that performs a handshake to request access to it. Update current BIOS SPI access to use the functions. Also fix shellcheck error. Tested: Flashed BMC image on unit. Ensured that BIOS flash is still successful. Change-Id: Icc91802647a6967694fca3e57bbc56f2c1db9189 Signed-off-by: Kyle Nieman <kyle.nieman@fii-na.com>
Diffstat (limited to 'meta-fii')
-rw-r--r--meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-fw.sh18
-rw-r--r--meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh48
2 files changed, 49 insertions, 17 deletions
diff --git a/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-fw.sh b/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-fw.sh
index a0f11544e5..4b0ab09377 100644
--- a/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-fw.sh
+++ b/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-fw.sh
@@ -7,23 +7,13 @@
source /usr/libexec/mori-fw/mori-lib.sh
function fwbios() {
- KERNEL_FIU_ID="c0000000.spi"
- KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU"
ret=0
if [ ! -f "$1" ]; then
echo " Cannot find the" "$1" "image file"
return 1
fi
- # switch the SPI mux from Host to BMC
- set_gpio_ctrl FM_BIOS_FLASH_SPI_MUX_R_SEL 1
-
- # rescan the spi bus
- if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
- echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
- sleep 1
- fi
- echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/bind
+ setup_bios_access
# write to the mtd device
BIOS_MTD=$(grep "hnor" /proc/mtd | sed -n 's/^\(.*\):.*/\1/p')
@@ -34,11 +24,7 @@ function fwbios() {
ret=1
fi
- # switch the SPI mux from BMC to Host
- if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
- echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
- fi
- set_gpio_ctrl FM_BIOS_FLASH_SPI_MUX_R_SEL 0
+ cleanup_bios_access
return $ret
}
diff --git a/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh b/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh
index 9c443bf718..45303c6296 100644
--- a/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh
+++ b/meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh
@@ -33,7 +33,7 @@ function get_gpio_num() {
if [[ $(gpiofind "$1" | cut -d " " -f 1) == "$X" ]]; then
# Used to select the correct GPIO_BASE value
#shellcheck disable=SC2086
- GPIO_BASE_DIR=$(echo ${GPIO_BASE_DIR} | cut -d " " -f $count)
+ GPIO_BASE_DIR=("$(echo ${GPIO_BASE_DIR} | cut -d " " -f $count)")
break
fi
count=$((count-1))
@@ -85,6 +85,48 @@ function Does_File_Exist() {
fi
}
+function cleanup_bios_access() {
+ # Run only if setup_bios_access was previously ran
+ if Does_File_Exist /run/bios_access &> /dev/null ; then
+ # switch the SPI mux from BMC to Host
+ if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
+ echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
+ fi
+ set_gpio_ctrl FM_BIOS_FLASH_SPI_MUX_R_SEL 0
+
+ # Indicate to host that BMC is finished accessing SPI
+ set_gpio_ctrl S0_BMC_SPI_NOR_ACCESS 0
+
+ rm /run/bios_access
+ fi
+}
+
+function setup_bios_access() {
+ # Run only if setup_bios_access was not previously ran without cleanup
+ if ! Does_File_Exist /run/bios_access &> /dev/null ; then
+ echo "BMC is accessing BIOS" > /run/bios_access
+
+ # rescan the spi bus
+ if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
+ echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
+ usleep 100
+ fi
+
+ # Wait until the host is finished accessing the SPI
+ while [[ $(get_gpio_ctrl S0_SOC_SPI_NOR_ACCESS) == 1 ]]
+ do
+ sleep 1
+ done
+ # Indicate to host that BMC is accessing SPI
+ set_gpio_ctrl S0_BMC_SPI_NOR_ACCESS 1
+
+ # switch the SPI mux from Host to BMC
+ set_gpio_ctrl FM_BIOS_FLASH_SPI_MUX_R_SEL 1
+
+ echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/bind
+ fi
+}
+
# Start definitions
# I2C Definitions
@@ -101,3 +143,7 @@ I2C_HOTSWAP_CTRL=(25 1f)
# File Path Definition
# File path used to prevent hotswapping
RST_LOCK_FILE="/etc/FW_FLASH_ONGOING"
+
+# Device name and driver path used for BIOS SPI
+KERNEL_FIU_ID="c0000000.spi"
+KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU"