nvmes: add Availability interface
Add Availability interface.
When PwrGoodPin is low, Set Available property to false to indicate
this sensor is currently unavilable due to power loss.
Tested on Bletchley:
- PwrGoodPin is low
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
- PwrGoodPin is high
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 33 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
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I0b621ae619dde85607c635912c7230bbe9de22ac
diff --git a/nvme_manager.cpp b/nvme_manager.cpp
index cdb76b1..51b0f7d 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -617,6 +617,7 @@
: IS_PRESENT;
auto pwrGoodPinValStr =
(config.pwrGoodPin) ? getGPIOValueOfNvme(devPwrGoodPath) : POWERGD;
+ const bool isPwrGood = (pwrGoodPinValStr == POWERGD);
if (presentPinValStr != IS_PRESENT)
{
@@ -636,7 +637,7 @@
continue;
}
- if (pwrGoodPinValStr != POWERGD)
+ if (!isPwrGood)
{
// IFDET should be used to provide the final say
// in SSD's presence - IFDET showing SSD is present
@@ -672,6 +673,7 @@
// (To make thermal loop know that the sensor reading
// is invalid).
readNvmeData(config);
+ nvmes.find(config.index)->second->setSensorAvailability(isPwrGood);
}
}
} // namespace nvme