Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,26 @@
SUMMARY = "OpenBMC Quanta Detect Fan Fail Service"
DESCRIPTION = "OpenBMC Quanta Detect Fan Fail Daemon."
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "bash"
FILESEXTRAPATHS:append:gsj := "${THISDIR}/files:"
SRC_URI:append:gsj = " file://detect-fan-fail.sh \
file://detect-fan-fail.service \
"
do_install:append:gsj() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/detect-fan-fail.sh ${D}${bindir}/
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/detect-fan-fail.service ${D}${systemd_unitdir}/system
}
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "detect-fan-fail.service"
@@ -0,0 +1,10 @@
[Unit]
Description=Detect Fan Fail Manager
After=phosphor-pid-control.service
[Service]
ExecStart=/usr/bin/detect-fan-fail.sh
Restart=always
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,58 @@
#!/bin/bash
# get fan state by d-bus command
function get_fan_state() {
get_property_path='xyz.openbmc_project.Sensor.Threshold.Critical CriticalAlarmLow'
fan_state="$(busctl get-property "$1" "$2" "$get_property_path" | awk '{print $2}')"
echo "$fan_state"
}
# set fan pwm by d-bus command
function set_fan_value() {
set_property_path='xyz.openbmc_project.Control.FanPwm'
busctl set-property "$1" "$2" $set_property_path Target t 255
}
fan_tach_path=( '/xyz/openbmc_project/sensors/fan_tach/Fan0_0_RPM'
'/xyz/openbmc_project/sensors/fan_tach/Fan0_1_RPM'
'/xyz/openbmc_project/sensors/fan_tach/Fan1_0_RPM'
'/xyz/openbmc_project/sensors/fan_tach/Fan1_1_RPM'
'/xyz/openbmc_project/sensors/fan_tach/Fan2_0_RPM'
'/xyz/openbmc_project/sensors/fan_tach/Fan2_1_RPM'
)
check_fail_flag=0
current_fan_state=()
while true; do
hwmon_path="$(mapper get-service "${fan_tach_path[0]}")"
for i in "${!fan_tach_path[@]}";
do
current_fan_state[i%2]=$(get_fan_state "$hwmon_path" "${fan_tach_path[$i]}")
#Compare state of dual rotors with CriticalAlarmLow to check if fan fail
if [ ${#current_fan_state[@]} -eq 2 ];then
if [ "${current_fan_state[0]}" == "true" ] && \
[ "${current_fan_state[1]}" == "true" ] ;then
if [ $check_fail_flag -eq 0 ];then
systemctl stop phosphor-pid-control
for j in "${!fan_tach_path[@]}";
do
#If fan fail is detect, set other fan rpm to pwm 255.
set_fan_value "$hwmon_path" "${fan_tach_path[$j]}"
check_fail_flag=1
done
fi
current_fan_state=()
break
fi
current_fan_state=()
fi
#fans are going to normal.
if [ "$i" -eq $((${#fan_tach_path[@]}-1)) ] && [ $check_fail_flag -eq 1 ]; then
check_fail_flag=0
systemctl restart phosphor-pid-control
fi
done
sleep 2
done
@@ -0,0 +1,12 @@
[Unit]
Description=Hotswap Controller Setting Changing
Before=xyz.openbmc_project.Hwmon@.service
[Service]
ExecStart=/usr/bin/gsj-hotswap-change-setting.sh
Restart=no
Type=oneshot
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,67 @@
#!/bin/bash
# Purpose:
# The purpose of the script is to change the CB/CL ratio setting of the hotswap controller from 1.9x to 3.9x
I2C_BUS=11
CHIP_ADDR=0x15
GPIO_ID=91 #Revision ID
GPIO_BasePath=/sys/class/gpio
function set_hotswap_reg()
{
#set reg "0xd9" bit 3 to 1
i2cset -f -y $I2C_BUS $CHIP_ADDR 0xd9 0x08
}
function get_hotswap_value()
{
#get the value of reg "0xd9", return value should be "0x08"
i2cget -f -y $I2C_BUS $CHIP_ADDR 0xd9
}
function export_gpio()
{
if [ -d "$GPIO_BasePath/gpio$GPIO_ID" ]; then
echo "gpio$GPIO_ID folder exist, skip export."
else
echo "Export gpio$GPIO_ID..."
echo $GPIO_ID > $GPIO_BasePath/export
fi
}
function get_gpio_value()
{
cat $GPIO_BasePath/gpio$GPIO_ID/value
}
function setting_hotswap()
{
echo "setting hotswap controller..."
set_hotswap_reg
for i in {0..3};
do
if [ "$i" == "3" ];then
echo "change hotswap controller setting failed after retry 3 times."
else
hotswap_value=$(get_hotswap_value)
echo "get hotswap controller return value : $hotswap_value"
if [ "$hotswap_value" == "0x08" ];then
echo "change hotswap controller setting success."
break;
else
echo "hotswap controller setting failed, retry $i times..."
fi
fi
done
}
export_gpio
gpio_value=$(get_gpio_value)
if [ "$gpio_value" == "1" ];then
echo "gpio$GPIO_ID value is: $gpio_value, setting hotswap."
setting_hotswap
else
echo "gpio$GPIO_ID value is: $gpio_value, no need to set hotswap."
fi
@@ -0,0 +1,26 @@
SUMMARY = "Hotswap Controller Setting Changing"
DESCRIPTION = "Hotswap Controller Setting Changing Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "bash"
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append = " file://gsj-hotswap-change-setting.sh \
file://gsj-hotswap-change-setting.service \
"
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/gsj-hotswap-change-setting.sh ${D}${bindir}/
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/gsj-hotswap-change-setting.service ${D}${systemd_unitdir}/system
}
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "gsj-hotswap-change-setting.service"
@@ -0,0 +1,30 @@
SUMMARY = "OpenBMC for GSJ system - Applications"
PR = "r1"
inherit packagegroup
PROVIDES = "${PACKAGES}"
PACKAGES = " \
${PN}-chassis \
${PN}-fans \
${PN}-flash \
"
PROVIDES += "virtual/obmc-chassis-mgmt"
PROVIDES += "virtual/obmc-fan-mgmt"
PROVIDES += "virtual/obmc-flash-mgmt"
RPROVIDES:${PN}-chassis += "virtual-obmc-chassis-mgmt"
RPROVIDES:${PN}-fans += "virtual-obmc-fan-mgmt"
RPROVIDES:${PN}-flash += "virtual-obmc-flash-mgmt"
SUMMARY:${PN}-chassis = "GSJ Chassis"
RDEPENDS:${PN}-chassis = ""
SUMMARY:${PN}-fans = "GSJ Fans"
RDEPENDS:${PN}-fans = ""
SUMMARY:${PN}-flash = "GSJ Flash"
RDEPENDS:${PN}-flash = " \
phosphor-ipmi-flash \
"
@@ -0,0 +1,46 @@
### NVME SSD Power Control Manager
#### Description
The package mantains for SSD power control and related noification handle Deamon
#### Design
The service power supply design follow PCI Express Card Electromechanical Specification Revision 3.0 in Section 2.2
nvme_gpio.service follow section 2.2.1 Initial power-Up to initinal and adjust related signal.
nvme_powermanager.service follow section 2.2.2 power management states monitor PRESENT signal and update related signal.
#### Process
* Plugging
1. U2_[SSD_index] PRSNT_N will be input low
2. Set PWR_U2_[SSD_index]_EN to high
3. Check PWRGD_U2_[SSD_index] is high
4-1. If PWRGD_U2_[SSD_index] is high (PWR Good)
- Wait 5ms
- Enable PCI Clock by SMBus 9FGL0851
- Wait 100ms
- Set RST_BMC_U2 to high
4-2. If PWRGD_U2_[SSD_index] is low (PWR Fail)
- Set RST_BMC_U2_[SSD_index]_R_N to low
- Wait 100ms
- Disable PCI Clock by SMBus
* Removing
1. U2_[SSD_index] PRSNT_N will be input high
2. Set RST_BMC_U2 to low
3. Wait 100ms
4. Disable PCI Clock by SMBus
5. Wait 5ms
6. PWR_U2_[SSD_index]_EN to low
#### Test
1. PRESENT detect SSD: The hardware design has been implemented.
2. Initial SSD slot Power output: nvme_gpio service has tested on Module. It could sucess initial gpios and set correct power output.
3. Detect PRESENT and change power setting: nvme_powermanager service has tested on Module. It could success detect SSD plugged or removal change power output.
4. Improve initial power-up sequence: For matched hardware default initial power-up setting, the nvme_gpio service only set unplugged slot related signal.
5. Improve service execute sequence: nvme_powermanager.service must wait for nvme_gpio.service ensure gpio export complete.
@@ -0,0 +1,59 @@
#!/bin/bash
# shellcheck source=meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh
source /usr/libexec/nvme_powerctrl_library.sh
function set_gpio() {
#$1 gpio pin
echo "$1" > /sys/class/gpio/export
}
echo "Read Clock Gen Value is: $CLOCK_GEN_VALUE"
## Initial U2_PRESENT_N
for i in "${!U2_PRESENT[@]}";
do
set_gpio "${U2_PRESENT[$i]}";
set_gpio_direction "${U2_PRESENT[$i]}" 'in';
echo "Read $i SSD present: $(read_gpio_input "${U2_PRESENT[$i]}")"
done
## Initial POWER_U2_EN
for i in "${!POWER_U2[@]}";
do
set_gpio "${POWER_U2[$i]}";
done
## Initial PWRGD_U2
for i in "${!PWRGD_U2[@]}";
do
set_gpio "${PWRGD_U2[$i]}";
set_gpio_direction "${PWRGD_U2[$i]}" 'in';
echo "Read $i SSD Power Good: $(read_gpio_input "${PWRGD_U2[$i]}")"
done
## Initial RST_BMC_U2
for i in "${!RST_BMC_U2[@]}";
do
set_gpio "${RST_BMC_U2[$i]}";
done
### Initial related Power by Present
for i in {0..7};
do
update_value=$(printf '%x\n' "$((0x01 << i))")
if [ "$(read_gpio_input "${U2_PRESENT[$i]}")" == $PLUGGED ];then
CLOCK_GEN_VALUE=$(printf '0x%x\n' \
"$((CLOCK_GEN_VALUE | 0x$update_value))")
else
set_gpio_direction "${RST_BMC_U2[$i]}" "low"
set_gpio_direction "${POWER_U2[$i]}" "low"
CLOCK_GEN_VALUE=$(printf '0x%x\n' \
"$((CLOCK_GEN_VALUE & ~0x$update_value))")
fi
done
i2cset -y $I2C_BUS $CHIP_ADDR 0 "$CLOCK_GEN_VALUE" s
echo "Read Clock Gen Value again is: $CLOCK_GEN_VALUE"
exit 0;
@@ -0,0 +1,12 @@
[Unit]
Description = configure GPIO for SSD Power Control
Before=nvme_powermanager.service
[Service]
Restart=no
RemainAfterExit=true
Type=oneshot
ExecStart=/usr/bin/init_once.sh
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,65 @@
#!/bin/bash
export U2_PRESENT=( 148 149 150 151 152 153 154 155 )
export POWER_U2=( 195 196 202 199 198 197 127 126 )
export PWRGD_U2=( 161 162 163 164 165 166 167 168 )
export RST_BMC_U2=( 72 73 74 75 76 77 78 79 )
export PLUGGED=0
export I2C_BUS=8
export CHIP_ADDR=0x68
export CLOCK_GEN_VALUE=
CLOCK_GEN_VALUE=$(i2cget -y $I2C_BUS $CHIP_ADDR 0 i 2|cut -f3 -d' ')
function set_gpio_direction()
{
#$1 gpio pin, $2 'in','high','low'
echo "$2" > "/sys/class/gpio/gpio$1/direction"
}
function read_gpio_input()
{
#$1 read input gpio pin
cat "/sys/class/gpio/gpio$1/value"
}
function enable_nvme_power()
{
set_gpio_direction "${POWER_U2[$1]}" "high"
sleep 0.04
check_powergood "$1"
}
function check_powergood()
{
if [ "$(read_gpio_input "${PWRGD_U2[$1]}")" == 1 ];then
sleep 0.005
update_clock_gen_chip_register "$1" 1
sleep 0.1
set_gpio_direction "${RST_BMC_U2[$1]}" "high"
else
disable_nvme_power "$1"
fi
}
function disable_nvme_power()
{
set_gpio_direction "${RST_BMC_U2[$1]}" "low"
sleep 0.1
update_clock_gen_chip_register "$1" 0
sleep 0.005
set_gpio_direction "${POWER_U2[$1]}" "low"
}
function update_clock_gen_chip_register(){
#$1 nvme slot number, $2 enable/disable
update_value=$(printf '%x\n' "$((0x01 <<$1))")
if [ "$2" -eq 1 ];then
CLOCK_GEN_VALUE=$(printf '0x%x\n' \
"$((CLOCK_GEN_VALUE | 0x$update_value))")
else
CLOCK_GEN_VALUE=$(printf '0x%x\n' \
"$((CLOCK_GEN_VALUE & ~0x$update_value))")
fi
i2cset -y $I2C_BUS $CHIP_ADDR 0 "$CLOCK_GEN_VALUE" s
}
@@ -0,0 +1,11 @@
[Unit]
Description=SSD NVME Power Manager
Requires=nvme_gpio.service
After=nvme_gpio.service
[Service]
ExecStart=/usr/bin/nvme_powermanager.sh
Restart=always
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,48 @@
#!/bin/bash
# shellcheck source=meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh
source /usr/libexec/nvme_powerctrl_library.sh
U2_PRESENT_STATUS=( 1 1 1 1 1 1 1 1 )
function recovery_power()
{
set_gpio_direction "${POWER_U2[$1]}" "low"
sleep 0.2
set_gpio_direction "${POWER_U2[$1]}" "high"
sleep 0.2
check_powergood "$1"
}
##Initial U2 present status
for i in {0..7};
do
U2_PRESENT_STATUS[i]=$(read_gpio_input "${U2_PRESENT[$i]}")
done
## Loop while
while :
do
for i in {0..7};
do
## 1 second scan all loop
sleep 0.125
read_present=$(read_gpio_input "${U2_PRESENT[$i]}")
if [ "$read_present" != "${U2_PRESENT_STATUS[$i]}" ];then
U2_PRESENT_STATUS[i]="$read_present"
if [ "$read_present" == $PLUGGED ];then
echo "NVME $i Enable Power"
enable_nvme_power "$i"
else
echo "NVME $i Disable Power"
disable_nvme_power "$i"
fi
else
if [ "${U2_PRESENT_STATUS[$i]}" == $PLUGGED ] &&
[ "$(read_gpio_input "${PWRGD_U2[$i]}")" == 0 ];then
echo "NVME $i Recovery Power"
recovery_power "$i"
fi
fi
done
done
@@ -0,0 +1,37 @@
SUMMARY = "Phosphor OpenBMC Quanta NVME Power Control Service"
DESCRIPTION = "Phosphor OpenBMC Quanta NVME Power Control Daemon."
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
FILESEXTRAPATHS:append := "${THISDIR}/files:"
inherit systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
RDEPENDS:${PN} += "iotools"
SRC_URI += "file://init_once.sh \
file://nvme_powermanager.sh \
file://nvme_powerctrl_library.sh \
file://nvme_gpio.service \
file://nvme_powermanager.service \
"
do_install () {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/init_once.sh ${D}${bindir}/
install -m 0755 ${WORKDIR}/nvme_powermanager.sh ${D}${bindir}/
install -d ${D}${libexecdir}
install -m 0755 ${WORKDIR}/nvme_powerctrl_library.sh ${D}${libexecdir}/
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/nvme_gpio.service ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/nvme_powermanager.service ${D}${systemd_unitdir}/system
}
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "nvme_gpio.service nvme_powermanager.service"
@@ -0,0 +1,7 @@
[Match]
Name=usb0
[Address]
Address=169.254.95.118/16
[Network]
LinkLocalAddressing=no
IPv6AcceptRA=no
@@ -0,0 +1,10 @@
[Unit]
Description=enable usb network
After=phosphor-ipmi-host.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c '/usr/sbin/usb_network.sh'
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,27 @@
#!/bin/bash
cd /sys/kernel/config/usb_gadget || exit
if [ ! -f "g1" ]; then
mkdir g1
cd g1 || exit
echo 0x1d6b > idVendor # Linux foundation
echo 0x0104 > idProduct # Multifunction composite gadget
mkdir -p strings/0x409
echo "Linux" > strings/0x409/manufacturer
echo "Ethernet/RNDIS gadget" > strings/0x409/product
mkdir -p configs/c.1
echo 100 > configs/c.1/MaxPower
mkdir -p configs/c.1/strings/0x409
echo "RNDIS" > configs/c.1/strings/0x409/configuration
mkdir -p functions/rndis.usb0
ln -s functions/rndis.usb0 configs/c.1
echo f0839000.udc > UDC
fi
exit 0
@@ -0,0 +1,29 @@
FILESEXTRAPATHS:append := "${THISDIR}/files:"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DEPENDS += "systemd"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
SRC_URI += "file://usb_network.sh \
file://usb_network.service \
file://00-bmc-usb0.network"
do_install() {
install -d ${D}/${sbindir}
install -m 0755 ${WORKDIR}/usb_network.sh ${D}/${sbindir}
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/usb_network.service ${D}${systemd_unitdir}/system
install -d ${D}${sysconfdir_native}/systemd/network/
install -m 0644 ${WORKDIR}/00-bmc-usb0.network ${D}${sysconfdir_native}/systemd/network
}
NATIVE_SYSTEMD_SUPPORT = "1"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "usb_network.service"
FILES:${PN} += "${sysconfdir_native}/systemd/network/00-bmc-usb0.network"
inherit allarch systemd