Support checking host status via GPIO pins
Currently, openBmc supports checking host status via ipmi and PLDM
method. However, not all of platforms support IPMI and PLDM. Some
platforms, like Ampere Mt.Jade checks input GPIO to detect Host
firmware boot status. This commit supports Dbus method to check host
status via GPIO pins, it checks the value of "host0-ready/-n" pin to
detect HOST is ready or not.
Tested:
1. Update GPIO pin to detect host0 ready to "host0-ready"
in the device tree.
2. Enable host-gpios option and add executable and service
files to openBmc software then flash to the board.
3. In the BMC console, check host-gpio-condition via command
"busctl tree xyz.openbmc_project.State.HostCondition.Gpio"
Result as below:
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/Gpios
`-/xyz/openbmc_project/Gpios/host0
4. Turn on/off the HOST0 then check the host status via
command
"busctl get-property \
xyz.openbmc_project.State.HostCondition.Gpio \
/xyz/openbmc_project/Gpios/host0 \
xyz.openbmc_project.Condition.HostFirmware \
CurrentFirmwareCondition"
Result as below:
"xyz.openbmc_project.Condition.HostFirmware.\
FirmwareCondition.<Running/Off>"
Signed-off-by: Thang Tran <thuutran@amperecomputing.com>
Change-Id: I20e38e76c5b70119f0c86e5b497d47453d7c5a6c
diff --git a/host_condition_gpio/host_condition_main.cpp b/host_condition_gpio/host_condition_main.cpp
new file mode 100644
index 0000000..6148450
--- /dev/null
+++ b/host_condition_gpio/host_condition_main.cpp
@@ -0,0 +1,45 @@
+#include "config.h"
+
+#include "host_condition.hpp"
+
+#include <boost/algorithm/string.hpp>
+#include <sdbusplus/bus.hpp>
+
+#include <cstdlib>
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+ std::string hostId;
+
+ if (argc == 2)
+ {
+ hostId = std::string(argv[1]);
+ }
+ else
+ {
+ return 0;
+ }
+
+ auto bus = sdbusplus::bus::new_default();
+ std::string objGroupName = HOST_GPIOS_OBJPATH;
+ std::string objPathInst = objGroupName + "/host" + hostId;
+ std::string busName = HOST_GPIOS_BUSNAME;
+
+ // Add sdbusplus ObjectManager
+ sdbusplus::server::manager::manager objManager(bus, objGroupName.c_str());
+
+ // For now, we only support checking Host0 status
+ auto host = std::make_unique<phosphor::condition::Host>(
+ bus, objPathInst.c_str(), hostId);
+
+ bus.request_name(busName.c_str());
+
+ while (true)
+ {
+ bus.process_discard();
+ bus.wait();
+ }
+
+ return 0;
+}