Initial commit
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
SUMMARY = "Bletchley SLED Present Service"
|
||||
DESCRIPTION = "OpenBMC Quanta Detect Present Daemon."
|
||||
PR = "r1"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
DEPENDS += "systemd"
|
||||
RDEPENDS:${PN} += " bash phosphor-gpio-monitor-presence"
|
||||
|
||||
SRC_URI = " file://detect-sled-present \
|
||||
file://detect-sled-present@.service \
|
||||
file://bletchley-sled-insertion@.target \
|
||||
file://bletchley-sled-removal@.target \
|
||||
"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/detect-sled-present ${D}${bindir}/
|
||||
|
||||
install -d ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/detect-sled-present@.service ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/bletchley-sled-insertion@.target ${D}${systemd_system_unitdir}
|
||||
install -m 0644 ${WORKDIR}/bletchley-sled-removal@.target ${D}${systemd_system_unitdir}
|
||||
}
|
||||
|
||||
TGT = "${SYSTEMD_DEFAULT_TARGET}"
|
||||
|
||||
SLED_PRESENT_INSTFMT="../detect-sled-present@.service:${TGT}.wants/detect-sled-present@{0}.service"
|
||||
SYSTEMD_SERVICE:${PN} += "detect-sled-present@.service"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'SLED_PRESENT_INSTFMT', 'OBMC_HOST_INSTANCES')}"
|
||||
|
||||
SLED_INSERT_INSTFMT="../bletchley-sled-insertion@.target:${TGT}.wants/bletchley-sled-insertion@{0}.target"
|
||||
SYSTEMD_SERVICE:${PN} += "bletchley-sled-insertion@.target"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'SLED_INSERT_INSTFMT', 'OBMC_HOST_INSTANCES')}"
|
||||
|
||||
SLED_REMOVE_INSTFMT="bletchley-sled-removal@.target:bletchley-sled-removal@{0}.target"
|
||||
SYSTEMD_SERVICE:${PN} += "bletchley-sled-removal@.target"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'SLED_REMOVE_INSTFMT', 'OBMC_HOST_INSTANCES')}"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Bletchlet SLED%i insertion target
|
||||
|
||||
Requires=chassis-poweron@%i.service
|
||||
After=chassis-poweron@%i.service
|
||||
Requires=motor-init-calibration@%i.service
|
||||
After=motor-init-calibration@%i.service
|
||||
Conflicts=bletchley-sled-removed@%i.target
|
||||
|
||||
RefuseManualStop=yes
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Bletchlet SLED%i removal target
|
||||
|
||||
Conflicts=motor-init-calibration@%i.service
|
||||
Conflicts=chassis-poweron@%i.service
|
||||
Conflicts=bletchley-sled-insertion@%i.target
|
||||
|
||||
RefuseManualStop=yes
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
SLED_ID=$1
|
||||
SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
|
||||
PRESENT_OBJPATH="/xyz/openbmc_project/inventory/system/chassis/presence/presence_sled${SLED_ID}"
|
||||
DBUS_PROPERTY_INTF="org.freedesktop.DBus.Properties"
|
||||
|
||||
bind_i2c_driver()
|
||||
{
|
||||
I2C_BUS_ADDR=$1
|
||||
DRIVER_NAME=$2
|
||||
DRIVER_DIR="/sys/bus/i2c/drivers/${DRIVER_NAME}"
|
||||
if [ ! -e "${DRIVER_DIR}/${I2C_BUS_ADDR}" ]; then
|
||||
echo "${I2C_BUS_ADDR}" > "${DRIVER_DIR}"/bind
|
||||
fi
|
||||
}
|
||||
|
||||
unbind_i2c_driver()
|
||||
{
|
||||
I2C_BUS_ADDR=$1
|
||||
DRIVER_NAME=$2
|
||||
DRIVER_DIR="/sys/bus/i2c/drivers/${DRIVER_NAME}"
|
||||
if [ -e "${DRIVER_DIR}/${I2C_BUS_ADDR}" ]; then
|
||||
echo "${I2C_BUS_ADDR}" > "${DRIVER_DIR}"/unbind
|
||||
fi
|
||||
}
|
||||
|
||||
sled_insert_action()
|
||||
{
|
||||
SLED_ID=$1
|
||||
I2C_BUS_NUM=$((SLED_ID-1))
|
||||
|
||||
# 0022: fusb302
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0022" "typec_fusb302"
|
||||
|
||||
# 0045: ina230
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0045" "ina2xx"
|
||||
|
||||
# 0040: mp5023
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0040" "mp5023"
|
||||
|
||||
# 0041: pca9536
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0041" "pca953x"
|
||||
|
||||
# 0076: pca9539
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0076" "pca953x"
|
||||
|
||||
# 004f: tmp421
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-004f" "tmp421"
|
||||
|
||||
# 0067: pca9552
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0067" "leds-pca955x"
|
||||
|
||||
# 0054: 24c64
|
||||
bind_i2c_driver "${I2C_BUS_NUM}-0054" "at24"
|
||||
|
||||
# start bletchley-sled-insertion target
|
||||
/bin/systemctl start bletchley-sled-insertion@"${SLED_ID}".target
|
||||
}
|
||||
|
||||
sled_remove_action()
|
||||
{
|
||||
SLED_ID=$1
|
||||
I2C_BUS_NUM=$((SLED_ID-1))
|
||||
|
||||
# 0022: fusb302
|
||||
unbind_i2c_driver "${I2C_BUS_NUM}-0022" "typec_fusb302"
|
||||
|
||||
# # 0045: ina230
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0045" "ina2xx"
|
||||
|
||||
# # 0040: mp5023
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0040" "mp5023"
|
||||
|
||||
# # 0041: pca9536
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0041" "pca953x"
|
||||
|
||||
# # 0076: pca9539
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0076" "pca953x"
|
||||
|
||||
# # 004f: tmp421
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-004f" "tmp421"
|
||||
|
||||
# # 0067: pca9552
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0067" "leds-pca955x"
|
||||
|
||||
# # 0054: 24c64
|
||||
# unbind_i2c_driver "${I2C_BUS_NUM}-0054" "at24"
|
||||
|
||||
# start bletchley-sled-removal target
|
||||
/bin/systemctl start bletchley-sled-removal@"${SLED_ID}".target
|
||||
}
|
||||
|
||||
|
||||
dbus-monitor --system "type=signal,interface=${DBUS_PROPERTY_INTF},sender=${SERVICE_NAME},path=${PRESENT_OBJPATH}" |
|
||||
while read -r line; do
|
||||
case "$line" in
|
||||
*"boolean false"*)
|
||||
echo "SLED${SLED_ID} Removal"
|
||||
sled_remove_action "$SLED_ID"
|
||||
;;
|
||||
*"boolean true"*)
|
||||
echo "SLED${SLED_ID} Insertion"
|
||||
sled_insert_action "$SLED_ID"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=SLED%i Present Manager
|
||||
After=phosphor-gpio-presence@presence-sled%i.service
|
||||
Wants=phosphor-gpio-presence@presence-sled%i.service
|
||||
After=mapper-wait@-xyz-openbmc_project-inventory-system-chassis-presence-presence_sled%i.service
|
||||
Wants=mapper-wait@-xyz-openbmc_project-inventory-system-chassis-presence-presence_sled%i.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/detect-sled-present %i
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user