Skip to content

Commit

Permalink
meta-ampere: mtmitchell: support IPMI OEM command enable Scan Dump
Browse files Browse the repository at this point in the history
Support Enable/Disable scandump mode, this mode will stop SoC monitorring
mode. This mode will be recoved after A/C the system.

Tested:
1. Get scandump mode status
   $ ipmitool raw 0x3c 0x26
     00
2. Enable scandump mode
   $ ipmitool raw 0x3c 0x25 0x01
3. Get scandump mode status
   $ ipmitool raw 0x3c 0x26
     01
4. Check if system firmware hang service is disabled.
5. Check there is no Eventlog from Host is created
6. Disable scandump mode
   $ ipmitool raw 0x3c 0x25 0x00
7. Check if system firmware hang service is enabled
8. This will be recoved after A/C the system.

Signed-off-by: Hieu Huynh <[email protected]>
  • Loading branch information
hieuhuynh-ampere authored and thangqn-ampere committed May 19, 2023
1 parent 7abcb6e commit 9198120
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRC_URI:append = " \
file://ampere_fanctrl.sh \
file://ampere_pldm_effecter_trigger.sh \
file://ampere_spi_util.sh \
file://ampere_scandump_mode.sh \
"

do_install:append() {
Expand All @@ -23,4 +24,5 @@ do_install:append() {
install -m 0755 ${WORKDIR}/ampere_fanctrl.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_pldm_effecter_trigger.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_spi_util.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_scandump_mode.sh ${D}/${sbindir}/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# Helper script to support enable/disable Scandump Mode
# Author : Hieu Huynh ([email protected])
#
# To enable Scandump mode:
# ampere_scandump_mode.sh enable
#
# To disable Scandump mode:
# ampere_scandump_mode.sh disable
#
# To get Scandump mode status:
# ampere_scandump_mode.sh getstatus

enable_scandump_mode() {
echo "Enable Scandump mode"
# Disable Mpro hang detection
systemctl stop ampere-sysfw-hang-handler.service

# Disable PLDM service
systemctl stop pldmd.service

# Enable scandump mode in CPLD
# Get Port0 value
p0_val=$(i2cget -f -y 15 0x22 0x02)
p0_val=$(("$p0_val" | (1 << 4)))
# Set Port0[4] value to "1" to mask all CPU’s GPIOs, set Port0[4].
i2cset -f -y 15 0x22 0x02 $p0_val

p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" & ~(1 << 4)))
# Config CPLD's IOepx Port0[4] from input to output, clear IOepx Port0[4].
i2cset -f -y 15 0x22 0x06 $p0_IOexp_val
}

diable_scandump_mode() {
echo "Disable Scandump mode"

# Disable scandump mode in CPLD
# Get Port0 value
p0_val=$(i2cget -f -y 15 0x22 0x02)
p0_val=$(("$p0_val" & ~(1 << 4)))
# Set Port0[4] value to "0" to unmask all CPU’s GPIOs, clear Port0[4].
i2cset -f -y 15 0x22 0x02 $p0_val

p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" | (1 << 4)))
# Config CPLD's IOepx Port0[4] from output to input, set IOepx Port0[4].
i2cset -f -y 15 0x22 0x06 $p0_IOexp_val

# Enable Mpro hang detection
systemctl start ampere-sysfw-hang-handler.service

# Enable PLDM service
systemctl start pldmd.service
}

getstatus() {
# Get CPLD's IOepx Port0[4], if this bit is "0" scandump mode is enabled.
p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" & (1 << 4)))
if [[ "$p0_IOexp_val" == "0" ]]; then
echo "Scandump mode is enabled"
exit 1
else
echo "Scandump mode is disabled"
exit 0
fi
}

# Usage of this utility
usage() {
echo "Usage:"
echo " - To enable Scandump mode"
echo " $(basename "$0") enable"
echo " - To disable Scandump mode"
echo " $(basename "$0") disable"
echo " - To get Scandump mode status"
echo " $(basename "$0") getstatus"
exit 0
}

if [[ $1 == "enable" ]]; then
enable_scandump_mode
elif [[ $1 == "disable" ]]; then
diable_scandump_mode
elif [[ $1 == "getstatus" ]]; then
getstatus
else
echo "Invalid mode"
usage
fi

exit 0

0 comments on commit 9198120

Please sign in to comment.