summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Chiu <howard.chiu@quantatw.com>2021-12-09 08:27:04 +0300
committerPatrick Williams <patrick@stwcx.xyz>2021-12-22 19:16:58 +0300
commit0eb09a13b1e395c0ff09d794cc11bd1513a6b935 (patch)
treefcbdf1664f22fde8c1a669db51305c8e302279b4
parentda05a16b41d429bd7c1229b377b8bfa948d61281 (diff)
downloadopenbmc-0eb09a13b1e395c0ff09d794cc11bd1513a6b935.tar.xz
meta-bletchley: Add init service to setup system
To setup GPIOs and set fan speed to 70% Signed-off-by: Howard Chiu <howard.chiu@quantatw.com> Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I7a64e19b6e34bcab7013b382d19d7be6156bf87a
-rwxr-xr-xmeta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init82
-rw-r--r--meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service11
-rw-r--r--meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb25
-rw-r--r--meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend5
4 files changed, 122 insertions, 1 deletions
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init
new file mode 100755
index 000000000..90a3f72af
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init
@@ -0,0 +1,82 @@
+#!/bin/bash -e
+
+set_gpio()
+{
+ NET_NAME=$1
+ OUT_VAL=$2
+ mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME")
+ if [ "${#GPIO_INFO[@]}" -ne 2 ]; then
+ echo "set_gpio: can not find gpio, $NET_NAME"
+ return 1
+ fi
+
+ echo -n "set_gpio: set $NET_NAME = $OUT_VAL"
+ if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then
+ echo " failed"
+ return 1
+ fi
+
+ echo " success"
+ return 0
+}
+
+set_fan()
+{
+ FAN_ID=$1
+ FAN_DUTY=$2
+ SYSFA_PWM_PATH=""
+
+ for file in /sys/devices/platform/pwm-fan"$FAN_ID"/hwmon/hwmon*/pwm1
+ do
+ if [ -e "$file" ]; then
+ SYSFA_PWM_PATH="$file"
+ break
+ fi
+ done
+
+ if [ -z "$SYSFA_PWM_PATH" ]; then
+ echo "set_fan: pwm file not found, chekc fan id ($FAN_ID)"
+ return 1
+ fi
+
+ if [ "$FAN_DUTY" -lt 0 ] || [ "$FAN_DUTY" -gt 100 ]; then
+ echo "set_fan: incorrect fan duty, $FAN_DUTY"
+ return 1
+ fi
+
+ # convert duty (0-100) to pwm value (0-255)
+ PWM_VAL=$(printf "%.0f" $((FAN_DUTY*255/100)))
+
+ echo -n "set_fan: set fan$FAN_ID = $FAN_DUTY"
+ if ! echo "$PWM_VAL" > "$SYSFA_PWM_PATH"; then
+ echo " failed"
+ return 1
+ fi
+
+ echo " success"
+ return 0
+}
+
+# set initial value for GPIO output pins
+set_gpio SEL_SPI2_MUX 1
+set_gpio SPI2_MUX1 1
+set_gpio SPI2_MUX2 1
+set_gpio SPI2_MUX3 1
+set_gpio SWITCH_FRU_MUX 1
+set_gpio BAT_DETECT 1
+set_gpio BMC_BT_WP0 1
+set_gpio BMC_BT_WP1 1
+set_gpio USB2_SEL0_A 1
+set_gpio USB2_SEL1_A 1
+set_gpio USB2_SEL0_B 1
+set_gpio USB2_SEL1_B 1
+set_gpio RST_FRONT_IOEXP 1
+set_gpio BSM_FLASH_LATCH 1
+
+# set initial duty value for each fan
+set_fan 0 70
+set_fan 1 70
+set_fan 2 70
+set_fan 3 70
+
+exit 0;
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service
new file mode 100644
index 000000000..481225990
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Bletchley Early System Init
+Before=phosphor-pid-control.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/bletchley-early-sys-init
+SyslogIdentifier=Bletchley Early Init
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb
new file mode 100644
index 000000000..dcbf6e88a
--- /dev/null
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb
@@ -0,0 +1,25 @@
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit allarch systemd
+
+RDEPENDS:${PN} += "bash"
+RDEPENDS:${PN} += "libgpiod-tools"
+
+SRC_URI += " \
+ file://bletchley-early-sys-init \
+ file://bletchley-sys-init.service \
+ "
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN}:append = " \
+ bletchley-sys-init.service \
+ "
+
+do_install() {
+ install -d ${D}${libexecdir}
+ install -m 0755 ${WORKDIR}/bletchley-early-sys-init ${D}${libexecdir}
+
+ install -d ${D}${systemd_system_unitdir}
+ install -m 0644 ${WORKDIR}/bletchley-sys-init.service ${D}${systemd_system_unitdir}
+}
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend
index 11096e1c4..a13903c39 100644
--- a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend
+++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend
@@ -1 +1,4 @@
-OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-nvme"
+OBMC_IMAGE_EXTRA_INSTALL:append = " \
+ phosphor-nvme \
+ plat-svc \
+"