summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-gsj
diff options
context:
space:
mode:
authorSpencerKu <Spencer.Ku@quantatw.com>2020-03-24 11:18:14 +0300
committerAndrew Geissler <geissonator@yahoo.com>2020-03-26 17:52:05 +0300
commit67f272f241a92ecbf5f85c38bfa165960ecdef93 (patch)
treed2a08aa72fa7558a83257315606ea2ad44f21dd8 /meta-quanta/meta-gsj
parent9df0b985d1d7214335c3365e759803bcdb167d24 (diff)
downloadopenbmc-67f272f241a92ecbf5f85c38bfa165960ecdef93.tar.xz
meta-quanta: gsj: Add service for setting hotswap controller
(1)Add a service for setting the value to hotswap controller, and checking the return value is right. (From meta-quanta rev: 83d0a87b74ac974112873690739727167137793d) Signed-off-by: SpencerKu <Spencer.Ku@quantatw.com> Change-Id: I51c5512562429351c007fd4ae9225b8d7097435f Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-quanta/meta-gsj')
-rw-r--r--meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.service13
-rw-r--r--meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh67
-rw-r--r--meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/gsj-hotswap-change-setting.bb26
-rw-r--r--meta-quanta/meta-gsj/recipes-phosphor/images/obmc-phosphor-image.bbappend1
4 files changed, 107 insertions, 0 deletions
diff --git a/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.service b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.service
new file mode 100644
index 000000000..ccf4ee1b0
--- /dev/null
+++ b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.service
@@ -0,0 +1,13 @@
+[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
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target \ No newline at end of file
diff --git a/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh
new file mode 100644
index 000000000..bed745dda
--- /dev/null
+++ b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/files/gsj-hotswap-change-setting.sh
@@ -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"
+ echo "$(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()
+{
+ echo "$(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 \ No newline at end of file
diff --git a/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/gsj-hotswap-change-setting.bb b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/gsj-hotswap-change-setting.bb
new file mode 100644
index 000000000..f9d9a9e47
--- /dev/null
+++ b/meta-quanta/meta-gsj/recipes-gsj/gsj-hotswap-change-setting/gsj-hotswap-change-setting.bb
@@ -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"
diff --git a/meta-quanta/meta-gsj/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-quanta/meta-gsj/recipes-phosphor/images/obmc-phosphor-image.bbappend
index 9950401c6..f1679cfe1 100644
--- a/meta-quanta/meta-gsj/recipes-phosphor/images/obmc-phosphor-image.bbappend
+++ b/meta-quanta/meta-gsj/recipes-phosphor/images/obmc-phosphor-image.bbappend
@@ -2,3 +2,4 @@ OBMC_IMAGE_EXTRA_INSTALL_append_gsj = " phosphor-ipmi-flash"
OBMC_IMAGE_EXTRA_INSTALL_append_gsj = " phosphor-pid-control"
OBMC_IMAGE_EXTRA_INSTALL_append_gsj = " detect-fan-fail"
OBMC_IMAGE_EXTRA_INSTALL_append_gsj = " google-ipmi-sys"
+OBMC_IMAGE_EXTRA_INSTALL_append_gsj = " gsj-hotswap-change-setting" \ No newline at end of file