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/button_handler.hpp b/inc/button_handler.hpp
index 5723cf7..819a433 100644
--- a/inc/button_handler.hpp
+++ b/inc/button_handler.hpp
@@ -83,6 +83,17 @@
void resetReleased(sdbusplus::message_t& msg);
/**
+ * @brief The handler for a OCP debug card host selector button press
+ *
+ * In multi host system increases host position by 1 up to max host
+ * position.
+ *
+ * @param[in] msg - sdbusplus message from signal
+ */
+
+ void debugHostSelectorReleased(sdbusplus::message::message& msg);
+
+ /**
* @brief Checks if system is powered on
*
* @return true if powered on, false else
@@ -105,7 +116,14 @@
*/
size_t getHostSelectorValue();
+ /**
+ * @brief increases the host selector position property
+ * by 1 upto max host selector position
+ *
+ * @return void
+ */
+ void increaseHostSelectorPosition();
/**
* @brief checks if the system has multi host
* based on the host selector property availability
@@ -146,6 +164,11 @@
* @brief Matches on the reset button released signal
*/
std::unique_ptr<sdbusplus::bus::match_t> resetButtonReleased;
+
+ /**
+ * @brief Matches on the ocp debug host selector button released signal
+ */
+ std::unique_ptr<sdbusplus::bus::match_t> debugHSButtonReleased;
};
} // namespace button
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;
+ }
+};
diff --git a/inc/gpio.hpp b/inc/gpio.hpp
index 6f0a67b..6a63056 100644
--- a/inc/gpio.hpp
+++ b/inc/gpio.hpp
@@ -21,6 +21,12 @@
#include <string>
#include <vector>
+enum class GpioState
+{
+ low,
+ high
+};
+
// this struct has the gpio config for single gpio
struct gpioInfo
{
diff --git a/inc/hostSelector_switch.hpp b/inc/hostSelector_switch.hpp
index dc98739..8030564 100644
--- a/inc/hostSelector_switch.hpp
+++ b/inc/hostSelector_switch.hpp
@@ -20,12 +20,6 @@
static constexpr auto INVALID_INDEX = std::numeric_limits<size_t>::max();
-enum class GpioState
-{
- low,
- high
-};
-
class HostSelector final :
public sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::