Add OCP debug card host selector button interface
A new button interface class definition is added for handling OCP
debug card host selector button events.
In case of the button release event, The host selector property is
increased up to the max host position.
Design : https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/45544
Signed-off-by: Naveen Moses <naveen.mosess@hcl.com>
Change-Id: Iec8fabb00d1daa10f587981a9c77df8a62e3c373
diff --git a/inc/debugHostSelector_button.hpp b/inc/debugHostSelector_button.hpp
new file mode 100644
index 0000000..bdd9dfa
--- /dev/null
+++ b/inc/debugHostSelector_button.hpp
@@ -0,0 +1,57 @@
+
+#pragma once
+#include "config.h"
+
+#include "button_factory.hpp"
+#include "button_interface.hpp"
+#include "common.hpp"
+#include "gpio.hpp"
+#include "xyz/openbmc_project/Chassis/Buttons/Button/server.hpp"
+#include "xyz/openbmc_project/Chassis/Common/error.hpp"
+
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/lg2.hpp>
+
+static constexpr std::string_view DEBUG_SELECTOR_BUTTON =
+ "DEBUG_SELECTOR_BUTTON";
+
+class DebugHostSelector final :
+ public sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>,
+ public ButtonIface
+
+{
+ public:
+ DebugHostSelector(sdbusplus::bus::bus& bus, const char* path,
+ EventPtr& event, buttonConfig& buttonCfg) :
+ sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>(
+ bus, path, action::defer_emit),
+ ButtonIface(bus, event, buttonCfg)
+ {
+ init();
+ emit_object_added();
+ }
+
+ ~DebugHostSelector()
+ {
+ deInit();
+ }
+
+ void simPress() override;
+ void simRelease() override;
+ void simLongPress() override;
+ void handleEvent(sd_event_source* es, int fd, uint32_t revents) override;
+
+ static constexpr std::string_view getFormFactorName()
+ {
+ return DEBUG_SELECTOR_BUTTON;
+ }
+
+ static const char* getDbusObjectPath()
+ {
+ return DBG_HS_DBUS_OBJECT_NAME;
+ }
+};