diff options
author | Potin Lai <potin.lai@quantatw.com> | 2023-02-08 08:25:38 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-03-10 19:04:15 +0300 |
commit | eb37b942ab298654e23ae65d53f93f14c7f8b5b6 (patch) | |
tree | 5dd4786905d513fc4816a84bd6b2aec0edf19658 /meta-facebook/meta-bletchley/recipes-phosphor | |
parent | 161a8ff9ac5726763fa7a794c4ed361a5245b060 (diff) | |
download | openbmc-eb37b942ab298654e23ae65d53f93f14c7f8b5b6.tar.xz |
meta-bletchley: phosphor-nvme: add nvme config script
In Bletchley, we use PCIE_PWR_EN pin as NVME power good pin from each
interposer board. Because PCIE_PWR_EN is form the I/O expander, it
won't have fixed GPIO pin number.
Add script to generate a nvme_config.json with correct GPIO pin number
before nvme management service start.
Tested:
- nvme_config.json generated
```
root@bletchley:~# cat /etc/nvme/nvme_config.json
{
"config": [
{
"NVMeDriveIndex": 1,
"NVMeDriveBusID": 0,
"NVMeDrivePwrGoodPin": 779
},
{
"NVMeDriveIndex": 2,
"NVMeDriveBusID": 1,
"NVMeDrivePwrGoodPin": 759
},
{
"NVMeDriveIndex": 3,
"NVMeDriveBusID": 2,
"NVMeDrivePwrGoodPin": 739
},
{
"NVMeDriveIndex": 4,
"NVMeDriveBusID": 3,
"NVMeDrivePwrGoodPin": 719
},
{
"NVMeDriveIndex": 5,
"NVMeDriveBusID": 4,
"NVMeDrivePwrGoodPin": 699
},
{
"NVMeDriveIndex": 6,
"NVMeDriveBusID": 5,
"NVMeDrivePwrGoodPin": 679
}
],
"threshold": [
{
"criticalHigh": 68,
"criticalLow": 0,
"warningHigh": 67,
"warningLow": 1,
"maxValue": 127,
"minValue": -127
}
]
}
```
- nvme sensor available (host on)
```
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
< /xyz/openbmc_project/sensors/temperature/nvme6 \
< xyz.openbmc_project.Sensor.Value
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
xyz.openbmc_project.Sensor.Value interface - - -
.MaxValue property d 127 emits-change writable
.MinValue property d -127 emits-change writable
.Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change writable
.Value property d 36 emits-change writable
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.State.Decorator.Availability
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b true emits-change writable
```
- nvme sensor not available (host off)
```
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.Sensor.Value
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.MaxValue property d 127 emits-change writable
.MinValue property d -127 emits-change writable
.Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change writable
.Value property d -127 emits-change writable
root@bletchley:~# busctl introspect xyz.openbmc_project.nvme.manager \
> /xyz/openbmc_project/sensors/temperature/nvme6 \
> xyz.openbmc_project.State.Decorator.Availability
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b false emits-change writable
```
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I2cda2e5e252fdfdd66ba6f9e0ea006c425cbf43b
Diffstat (limited to 'meta-facebook/meta-bletchley/recipes-phosphor')
3 files changed, 93 insertions, 0 deletions
diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite new file mode 100644 index 0000000000..d30ed89d18 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite @@ -0,0 +1,72 @@ +#!/bin/bash + +TARGET_FILE_NAME="/etc/nvme/nvme_config.json" + +export_gpio() { + if [ ! -d "/sys/class/gpio/gpio$1" ]; then + echo "$1" >/sys/class/gpio/export + fi +} + +for i in {0..5} +do + SLED_NVME_PCIE_EN[$i]=0 + for file in /sys/bus/i2c/drivers/pca953x/"$i"-0041/gpio/gpiochip*/base + do + if [ -f "$file" ]; then + GPIOCHIP_BASE="$(cat /sys/bus/i2c/drivers/pca953x/"$i"-0041/gpio/gpiochip*/base)" + SLED_NVME_PCIE_EN[$i]=$((GPIOCHIP_BASE+3)) + export_gpio ${SLED_NVME_PCIE_EN[$i]} + break + fi + done +done + +cat > $TARGET_FILE_NAME << EOF1 +{ + "maxSmbusErrorRetry": 3, + "config": [ + { + "NVMeDriveIndex": 1, + "NVMeDriveBusID": 0, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[0]} + }, + { + "NVMeDriveIndex": 2, + "NVMeDriveBusID": 1, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[1]} + }, + { + "NVMeDriveIndex": 3, + "NVMeDriveBusID": 2, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[2]} + }, + { + "NVMeDriveIndex": 4, + "NVMeDriveBusID": 3, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[3]} + }, + { + "NVMeDriveIndex": 5, + "NVMeDriveBusID": 4, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[4]} + }, + { + "NVMeDriveIndex": 6, + "NVMeDriveBusID": 5, + "NVMeDrivePwrGoodPin": ${SLED_NVME_PCIE_EN[5]} + } + ], + "threshold": [ + { + "criticalHigh": 68, + "criticalLow": 0, + "warningHigh": 67, + "warningLow": 1, + "maxValue": 127, + "minValue": -127 + } + ] +} + +EOF1 diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite.conf b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite.conf new file mode 100644 index 0000000000..3e156e5c3f --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme-json-rewrite.conf @@ -0,0 +1,2 @@ +[Service] +ExecStartPre=/usr/libexec/phosphor-nvme/nvme-json-rewrite diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend new file mode 100644 index 0000000000..d495c8d831 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend @@ -0,0 +1,19 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +inherit obmc-phosphor-systemd + +SRC_URI:append:bletchley = " \ + file://nvme-json-rewrite \ + file://nvme-json-rewrite.conf \ +" + +RDEPENDS:${PN}:bletchley += "bash" + +do_install:append:bletchley() { + install -d ${D}${libexecdir}/${PN}/ + install -m 0755 ${WORKDIR}/nvme-json-rewrite ${D}${libexecdir}/${PN}/ +} + +SYSTEMD_OVERRIDE:${PN}:append:bletchley = " \ + nvme-json-rewrite.conf:xyz.openbmc_project.nvme.manager.service.d/nvme-json-rewrite.conf \ +" |