Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
SUMMARY = "Phosphor OpenBMC Mori BIOS Firmware Upgrade Command"
|
||||
DESCRIPTION = "Phosphor OpenBMC Mori BIOS Firmware Upgrade Comman Daemon"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
DEPENDS:append = " systemd phosphor-ipmi-flash"
|
||||
PROVIDES:append = " virtual/bios-update"
|
||||
PR = "r1"
|
||||
|
||||
SRC_URI = " \
|
||||
file://phosphor-ipmi-flash-bios-update.service \
|
||||
file://config-bios.json \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} = "phosphor-ipmi-flash-bios-update.service"
|
||||
|
||||
inherit systemd obmc-phosphor-systemd
|
||||
|
||||
do_install () {
|
||||
install -d ${D}${datadir}/phosphor-ipmi-flash
|
||||
install -m 0644 ${WORKDIR}/config-bios.json \
|
||||
${D}${datadir}/phosphor-ipmi-flash
|
||||
install -d ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-bios-update.service \
|
||||
${D}${systemd_system_unitdir}
|
||||
}
|
||||
|
||||
RDEPENDS:${PN}:append = " libsystemd mori-fw"
|
||||
|
||||
RPROVIDES:${PN}:append = " virtual/bios-update"
|
||||
|
||||
FILES:${PN}:append = " ${datadir}/phosphor-ipmi-flash/config-bios.json"
|
||||
@@ -0,0 +1,19 @@
|
||||
[{
|
||||
"blob": "/flash/bios",
|
||||
"handler": {
|
||||
"type": "file",
|
||||
"path": "/run/initramfs/bios-image"
|
||||
},
|
||||
"actions": {
|
||||
"preparation": {
|
||||
"type": "skip"
|
||||
},
|
||||
"verification": {
|
||||
"type": "skip"
|
||||
},
|
||||
"update": {
|
||||
"type": "systemd",
|
||||
"unit": "phosphor-ipmi-flash-bios-update.service"
|
||||
}
|
||||
}
|
||||
}]
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=Phosphor-ipmi-flash update BIOS firmware service
|
||||
|
||||
[Service]
|
||||
ExecStart=mori-fw.sh bios /run/initramfs/bios-image
|
||||
Type=oneshot
|
||||
@@ -0,0 +1,21 @@
|
||||
SUMMARY = "Phosphor OpenBMC Mori BMC Firmware Upgrade Command"
|
||||
DESCRIPTION = "Phosphor OpenBMC Mori BMC Firmware Upgrade Comman Daemon"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
DEPENDS:append = " phosphor-ipmi-flash"
|
||||
PROVIDES:append = " virtual/bmc-update"
|
||||
PR = "r1"
|
||||
|
||||
SRC_URI = "file://config-bmc.json"
|
||||
|
||||
do_install () {
|
||||
install -d ${D}${datadir}/phosphor-ipmi-flash
|
||||
install -m 0644 ${WORKDIR}/config-bmc.json \
|
||||
${D}${datadir}/phosphor-ipmi-flash
|
||||
}
|
||||
|
||||
RDEPENDS:${PN}:append = " mori-fw"
|
||||
|
||||
RPROVIDES:${PN}:append = " virtual/bmc-update"
|
||||
|
||||
FILES:${PN}:append = " ${datadir}/phosphor-ipmi-flash/config-bmc.json"
|
||||
@@ -0,0 +1,20 @@
|
||||
[{
|
||||
"blob": "/flash/image",
|
||||
"handler": {
|
||||
"type": "file",
|
||||
"path": "/run/initramfs/image-bmc"
|
||||
},
|
||||
"actions": {
|
||||
"preparation": {
|
||||
"type": "skip"
|
||||
},
|
||||
"verification": {
|
||||
"type": "skip"
|
||||
},
|
||||
"update": {
|
||||
"type": "systemd",
|
||||
"unit": "reboot.target",
|
||||
"mode": "replace-irreversibly"
|
||||
}
|
||||
}
|
||||
}]
|
||||
@@ -0,0 +1,43 @@
|
||||
SUMMARY = "Phosphor OpenBMC Mori CPLD Firmware Upgrade Command"
|
||||
DESCRIPTION = "Phosphor OpenBMC Mori CPLD Firmware Upgrade Comman Daemon"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
DEPENDS:append = " systemd phosphor-ipmi-flash"
|
||||
PROVIDES:append = " virtual/cpld-update"
|
||||
PR = "r1"
|
||||
|
||||
SRC_URI = " \
|
||||
file://phosphor-ipmi-flash-bmccpld-update.service \
|
||||
file://phosphor-ipmi-flash-mbcpld-update.service \
|
||||
file://config-bmccpld.json \
|
||||
file://config-mbcpld.json \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} = " \
|
||||
phosphor-ipmi-flash-bmccpld-update.service \
|
||||
phosphor-ipmi-flash-mbcpld-update.service \
|
||||
"
|
||||
|
||||
inherit systemd obmc-phosphor-systemd
|
||||
|
||||
do_install () {
|
||||
install -d ${D}${datadir}/phosphor-ipmi-flash
|
||||
install -m 0644 ${WORKDIR}/config-bmccpld.json \
|
||||
${D}${datadir}/phosphor-ipmi-flash
|
||||
install -m 0644 ${WORKDIR}/config-mbcpld.json \
|
||||
${D}${datadir}/phosphor-ipmi-flash
|
||||
install -d ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-bmccpld-update.service \
|
||||
${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-mbcpld-update.service \
|
||||
${D}${systemd_system_unitdir}
|
||||
}
|
||||
|
||||
RDEPENDS:${PN}:append = " libsystemd mori-fw"
|
||||
|
||||
RPROVIDES:${PN}:append = " virtual/cpld-update"
|
||||
|
||||
FILES:${PN}:append = " \
|
||||
${datadir}/phosphor-ipmi-flash/config-bmccpld.json \
|
||||
${datadir}/phosphor-ipmi-flash/config-mbcpld.json \
|
||||
"
|
||||
@@ -0,0 +1,19 @@
|
||||
[{
|
||||
"blob": "/flash/bmccpld",
|
||||
"handler": {
|
||||
"type": "file",
|
||||
"path": "/run/initramfs/bmc-cpld.svf"
|
||||
},
|
||||
"actions": {
|
||||
"preparation": {
|
||||
"type": "skip"
|
||||
},
|
||||
"verification": {
|
||||
"type": "skip"
|
||||
},
|
||||
"update": {
|
||||
"type": "systemd",
|
||||
"unit": "phosphor-ipmi-flash-bmccpld-update.service"
|
||||
}
|
||||
}
|
||||
}]
|
||||
@@ -0,0 +1,20 @@
|
||||
[{
|
||||
"blob": "/flash/mbcpld",
|
||||
"handler": {
|
||||
"type": "file",
|
||||
"path": "/run/initramfs/mb-cpld.svf"
|
||||
},
|
||||
"actions": {
|
||||
"preparation": {
|
||||
"type": "skip"
|
||||
},
|
||||
"verification": {
|
||||
"type": "skip"
|
||||
},
|
||||
"update": {
|
||||
"type": "systemd",
|
||||
"unit": "phosphor-ipmi-flash-mbcpld-update.service"
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Phosphor-ipmi-flash update BMC CPLD firmware service
|
||||
|
||||
[Service]
|
||||
ExecStart=mori-fw.sh bmccpld /run/initramfs/bmc-cpld.svf
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
||||
WantedBy=phosphor-ipmi-flash-bmccpld-update.target
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Phosphor-ipmi-flash update MB CPLD firmware service
|
||||
|
||||
[Service]
|
||||
ExecStart=mori-fw.sh mbcpld /run/initramfs/mb-cpld.svf
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
||||
WantedBy=phosphor-ipmi-flash-mbcpld-update.target
|
||||
@@ -0,0 +1,30 @@
|
||||
SUMMARY = "Phosphor OpenBMC mori Firmware Upgrade Command"
|
||||
DESCRIPTION = "Phosphor OpenBMC mori Firmware Upgrade Comman Daemon"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
DEPENDS:append = " systemd phosphor-ipmi-flash"
|
||||
PR = "r1"
|
||||
|
||||
SRC_URI = " \
|
||||
file://mori-fw.sh \
|
||||
file://mori-fw-ver.service \
|
||||
file://mori-fw-ver.sh \
|
||||
file://mori-lib.sh \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} = "mori-fw-ver.service"
|
||||
|
||||
inherit systemd obmc-phosphor-systemd
|
||||
|
||||
do_install () {
|
||||
install -d ${D}${sbindir}
|
||||
install -d ${D}${libexecdir}/${PN}
|
||||
install -m 0755 ${WORKDIR}/mori-fw.sh ${D}${sbindir}/mori-fw.sh
|
||||
install -m 0755 ${WORKDIR}/mori-fw-ver.sh \
|
||||
${D}${libexecdir}/${PN}/mori-fw-ver.sh
|
||||
install -m 0755 ${WORKDIR}/mori-lib.sh ${D}${libexecdir}/${PN}/mori-lib.sh
|
||||
install -d ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/mori-fw-ver.service ${D}${systemd_system_unitdir}
|
||||
}
|
||||
|
||||
RDEPENDS:${PN}:append = " libsystemd bash"
|
||||
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Firmware Version Daemon
|
||||
Wants=host-powerctrl.service
|
||||
After=host-powerctrl.service
|
||||
|
||||
[Service]
|
||||
RemainAfterExit=yes
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/mori-fw/mori-fw-ver.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Disable check for splitting
|
||||
# shellcheck disable=SC2207
|
||||
# Provide source directive to shellcheck.
|
||||
# shellcheck source=meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh
|
||||
source /usr/libexec/mori-fw/mori-lib.sh
|
||||
|
||||
BMC_CPLD_VER_FILE="/run/cpld0.version"
|
||||
MB_CPLD_VER_FILE="/run/cpld1.version"
|
||||
ver=''
|
||||
|
||||
function fw_rev() {
|
||||
case $1 in
|
||||
cpldb)
|
||||
rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x00 i 5))
|
||||
ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
|
||||
;;
|
||||
cpldm)
|
||||
rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5))
|
||||
ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
fw_rev cpldb
|
||||
echo "BMC CPLD version : ${ver}"
|
||||
echo "${ver}" > "${BMC_CPLD_VER_FILE}"
|
||||
fw_rev cpldm
|
||||
echo "MB CPLD version : ${ver}"
|
||||
echo "${ver}" > "${MB_CPLD_VER_FILE}"
|
||||
@@ -0,0 +1,184 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Provide source directive to shellcheck.
|
||||
# shellcheck source=meta-fii/meta-mori/recipes-mori/mori-fw-utility/mori-fw/mori-lib.sh
|
||||
# Disable check for globbing and word splitting within double quotes
|
||||
# shellcheck disable=SC2086
|
||||
source /usr/libexec/mori-fw/mori-lib.sh
|
||||
|
||||
function fwbios() {
|
||||
ret=0
|
||||
if [ ! -f "$1" ]; then
|
||||
echo " Cannot find the" "$1" "image file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
setup_bios_access
|
||||
|
||||
# write to the mtd device
|
||||
BIOS_MTD=$(grep "hnor" /proc/mtd | sed -n 's/^\(.*\):.*/\1/p')
|
||||
{
|
||||
flock -x 200
|
||||
echo "Flashing BIOS @/dev/${BIOS_MTD}"
|
||||
if ! flashcp -v $1 /dev/${BIOS_MTD} ; then
|
||||
echo "Flashing the bios failed " >&2
|
||||
ret=1
|
||||
fi
|
||||
} 200>$RST_LOCK_FILE
|
||||
|
||||
cleanup_bios_access
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
function fwbmccpld() {
|
||||
ret=0
|
||||
if [ ! -s "$1" ]; then
|
||||
echo "Image file" "$1" "is empty or nonexistent, BMC CPLD update failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# MB_JTAG_MUX 0:CPU 1:MB
|
||||
# BMC_JTAG_MUX 0:GF/MB 1:BMC
|
||||
set_gpio_ctrl MB_JTAG_MUX_SEL 0
|
||||
set_gpio_ctrl BMC_JTAG_MUX_SEL 1
|
||||
|
||||
{
|
||||
flock -x 200
|
||||
# 1st condition checks if the svf file is valid
|
||||
# 2nd condition checks flashing logs for flash errors
|
||||
if ! mesg=$(loadsvf -d /dev/jtag0 -s $1 -m 0 2>&1) \
|
||||
|| echo "$mesg" | grep -i -e error -e fail ; then
|
||||
echo "$mesg" | grep -i -e error -e fail
|
||||
echo "BMC CPLD update failed"
|
||||
ret=1
|
||||
else
|
||||
echo "BMC CPLD update successful"
|
||||
fi
|
||||
} 200>$RST_LOCK_FILE
|
||||
return $ret
|
||||
}
|
||||
|
||||
function fwmbcpld() {
|
||||
ret=0
|
||||
if [ ! -s "$1" ]; then
|
||||
echo "Image file" "$1" "is empty or nonexistent, MB CPLD update failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# MB_JTAG_MUX 0:CPU 1:MB
|
||||
# BMC_JTAG_MUX 0:GF/MB 1:BMC
|
||||
set_gpio_ctrl MB_JTAG_MUX_SEL 1
|
||||
set_gpio_ctrl BMC_JTAG_MUX_SEL 0
|
||||
|
||||
{
|
||||
flock -x 200
|
||||
# 1st condition checks if the svf file is valid
|
||||
# 2nd condition checks flashing logs for flash errors
|
||||
if ! mesg=$(loadsvf -d /dev/jtag0 -s $1 -m 0 2>&1) \
|
||||
|| echo "$mesg" | grep -i -e error -e fail ; then
|
||||
echo "MB CPLD update failed"
|
||||
ret=1
|
||||
else
|
||||
echo "MB CPLD update successful"
|
||||
fi
|
||||
} 200>$RST_LOCK_FILE
|
||||
set_gpio_ctrl MB_JTAG_MUX_SEL 0
|
||||
echo "MB CPLD update successful"
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
function fwbootstrap() {
|
||||
# to flash the CPU EEPROM
|
||||
#unbind bootstrap EEPROM
|
||||
echo ${I2C_CPU_EEPROM[0]}-00${I2C_CPU_EEPROM[1]} > /sys/bus/i2c/drivers/at24/unbind
|
||||
|
||||
#switch access to BMC
|
||||
set_gpio_ctrl CPU_EEPROM_SEL 0
|
||||
|
||||
if [ "$(bootstrap_flash -b ${I2C_CPU_EEPROM[0]} -s 0x${I2C_CPU_EEPROM[1]} -p -f $1)" -ne 0 ]; then
|
||||
echo "CPU bootstrap EEPROM update failed" >&2
|
||||
return 1
|
||||
fi
|
||||
wait
|
||||
|
||||
#bind bootstrap EEPROM
|
||||
echo ${I2C_CPU_EEPROM[0]}-00${I2C_CPU_EEPROM[1]} > /sys/bus/i2c/drivers/at24/bind
|
||||
|
||||
#switch back access to CPU
|
||||
set_gpio_ctrl CPU_EEPROM_SEL 1
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
function fwmb_pwr_seq(){
|
||||
#$1 PS seq config file
|
||||
ret=0
|
||||
if [[ ! -e "$1" ]]; then
|
||||
echo "The file $1 does not exist"
|
||||
return 1
|
||||
fi
|
||||
echo "${I2C_MB_PWRSEQ[0]}"-00"${I2C_MB_PWRSEQ[1]}" > /sys/bus/i2c/drivers/adm1266/unbind
|
||||
{
|
||||
flock -x 200
|
||||
#Parameters passed to adm1266_fw_fx to be used to flash PS
|
||||
#1st I2C bus number of PS's
|
||||
#2nd PS seq config file
|
||||
if [ "$(mb_power_sequencer_flash ${I2C_MB_PWRSEQ[0]} $1)" -ne 0 ]; then
|
||||
|
||||
echo "The power seq flash failed" >&2
|
||||
ret=1
|
||||
else
|
||||
echo "${I2C_MB_PWRSEQ[0]}"-00"${I2C_MB_PWRSEQ[1]}" > /sys/bus/i2c/drivers/adm1266/bind
|
||||
fi
|
||||
} 200>$RST_LOCK_FILE
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
if [[ ! $(which flashcp) ]]; then
|
||||
echo "flashcp utility not installed"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! $(which loadsvf) ]]; then
|
||||
echo "loadsvf utility not installed"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! $(which mb_power_sequencer_flash) ]]; then
|
||||
echo "mb_power_sequencer_flash utility not installed"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! $(which bootstrap_flash) ]]; then
|
||||
echo "bootstrap_flash utility not installed"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e /dev/jtag0 ]]; then
|
||||
echo "Jtag device driver not functional"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
bios)
|
||||
fwbios "$2"
|
||||
;;
|
||||
bmccpld)
|
||||
fwbmccpld "$2"
|
||||
;;
|
||||
mbcpld)
|
||||
fwmbcpld "$2"
|
||||
;;
|
||||
bootstrap)
|
||||
fwbootstrap "$2"
|
||||
;;
|
||||
mbseq)
|
||||
fwmb_pwr_seq "$2"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
ret=$?
|
||||
|
||||
rm -f "$2"
|
||||
|
||||
exit $ret
|
||||
@@ -0,0 +1,139 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Disable check for usage of the definitions within mori-lib.sh
|
||||
#shellcheck disable=SC2034
|
||||
|
||||
# get_gpio_num
|
||||
# Dynamically obtains GPIO number from chip base and I2C expanders
|
||||
# line-name
|
||||
function get_gpio_num() {
|
||||
#shellcheck disable=SC2207
|
||||
CHIP_PIN=($(gpiofind "$1" | awk '{print substr ($1, 9 ), $2 }'))
|
||||
#shellcheck disable=SC2128
|
||||
if [ -z "$CHIP_PIN" ]; then
|
||||
echo "Could not find GPIO with name: $1"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "${CHIP_PIN[0]}" -gt 7 ]; then
|
||||
BUS_ADDR=$(gpiodetect | grep gpiochip"${CHIP_PIN[0]}" | \
|
||||
grep -o '\[.*]' | tr -d ' \[\]')
|
||||
GPIO_BASE_DIR=$(cd /sys/bus/i2c/devices/"$BUS_ADDR"/gpio/ || \
|
||||
exit; ls -1 -v)
|
||||
# Check that there is a single gpiobank per i2c device
|
||||
GPIO_BANKS=$(cd /sys/bus/i2c/devices/"$BUS_ADDR"/ || \
|
||||
exit ; ls -1 -d -v gpiochip*)
|
||||
# Determine which GPIO_BASE to use based on the place of the GPIO_BANK
|
||||
# in comparision to GPIO_BANKS
|
||||
# gpiochip# is set in reverse order of numbering for location of
|
||||
# GPIO_BASE_DIR
|
||||
count=$(echo "$GPIO_BANKS" | wc -w)
|
||||
for X in ${GPIO_BANKS}
|
||||
do
|
||||
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)")
|
||||
break
|
||||
fi
|
||||
count=$((count-1))
|
||||
done
|
||||
tmp="/sys/bus/i2c/devices/$BUS_ADDR/gpio/${GPIO_BASE_DIR[0]}/base"
|
||||
GPIO_BASE=$(cat "$tmp")
|
||||
echo "$((GPIO_BASE+CHIP_PIN[1]))"
|
||||
else
|
||||
echo "$((CHIP_PIN[0]*32+CHIP_PIN[1]))"
|
||||
fi
|
||||
}
|
||||
|
||||
# set_gpio_ctrl
|
||||
# line-name, high(1)/low(0)
|
||||
function set_gpio_ctrl() {
|
||||
#shellcheck disable=SC2046
|
||||
gpioset $(gpiofind "$1")="$2"
|
||||
}
|
||||
|
||||
# get_gpio_ctrl
|
||||
# line-name
|
||||
function get_gpio_ctrl() {
|
||||
GPIO_NUM=$(get_gpio_num "$1")
|
||||
echo "$GPIO_NUM" > /sys/class/gpio/export
|
||||
# GPIOs added by drivers use different path for value most but not all
|
||||
# drivers follow this trend
|
||||
# Try reading like traditional GPIO, if fails, try reading in driver format
|
||||
if ! cat /sys/class/gpio/gpio"$GPIO_NUM"/value 2> /dev/null ; then
|
||||
cat /sys/class/gpio/"$1"/value
|
||||
fi
|
||||
echo "$GPIO_NUM" > /sys/class/gpio/unexport
|
||||
}
|
||||
|
||||
|
||||
function Does_File_Exist() {
|
||||
local FILE=$1
|
||||
|
||||
if [[ ! -f "${FILE}" ]]; then
|
||||
echo "${FILE} file does not exist" >&2
|
||||
return 1
|
||||
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
|
||||
# The array is (<bus> <address>), where address is in hexadecimal.
|
||||
I2C_BMC_CPLD=(13 76)
|
||||
I2C_MB_CPLD=(0 76)
|
||||
I2C_FANCTRL=(35 2c)
|
||||
I2C_BMC_PWRSEQ=(48 59)
|
||||
I2C_MB_PWRSEQ=(40 40)
|
||||
I2C_CPU_EEPROM=(19 50)
|
||||
|
||||
# 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"
|
||||
Reference in New Issue
Block a user