Support host selector using cpld definitions
Description:
- Support host selector using cpld definitions
Design:
- Because the current structure only supports config defined by GPIO
(Yosemite V2), but there are also have the system (Yosemite V3.5)
gets the host-selector's selection from CPLD.
- So this commit is to extend the current configuration to use CPLD
definitions. Also, support adding event io from the register file
which was exported from the CLD driver.
- For example with config json below:
{
"cpld_definitions": [
{
"name": "HOST_SELECTOR",
"i2c_address": 15,
"i2c_bus": 12,
"register_name": "uart-selection-debug-card",
"max_position": 4
}
]
}
Dependency:
- CLD driver is required (link: https://lore.kernel.org/lkml/20230117094425.19004-1-Delphine_CC_Chiu@Wiwynn.com/)
Test Case:
- When ocp debug card uart button is pressed the position property on
dbus is correct.
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
Change-Id: I6746afa6d905bd3c681e2921c643b3cd4cb9944c
diff --git a/inc/button_factory.hpp b/inc/button_factory.hpp
index faf948d..29fb990 100644
--- a/inc/button_factory.hpp
+++ b/inc/button_factory.hpp
@@ -1,14 +1,14 @@
#pragma once
+#include "button_config.hpp"
#include "button_interface.hpp"
-#include "gpio.hpp"
#include <phosphor-logging/elog-errors.hpp>
#include <unordered_map>
using buttonIfCreatorMethod = std::function<std::unique_ptr<ButtonIface>(
- sdbusplus::bus_t& bus, EventPtr& event, buttonConfig& buttonCfg)>;
+ sdbusplus::bus_t& bus, EventPtr& event, ButtonConfig& buttonCfg)>;
/**
* @brief This is abstract factory for the creating phosphor buttons objects
@@ -37,7 +37,7 @@
{
buttonIfaceRegistry[std::string(T::getFormFactorName())] =
[](sdbusplus::bus_t& bus, EventPtr& event,
- buttonConfig& buttonCfg) {
+ ButtonConfig& buttonCfg) {
return std::make_unique<T>(bus, T::getDbusObjectPath(), event,
buttonCfg);
};
@@ -49,7 +49,7 @@
std::unique_ptr<ButtonIface> createInstance(const std::string& name,
sdbusplus::bus_t& bus,
EventPtr& event,
- buttonConfig& buttonCfg)
+ ButtonConfig& buttonCfg)
{
// find matching name in the registry and call factory method.
auto objectIter = buttonIfaceRegistry.find(name);