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/hostSelector_switch.hpp b/inc/hostSelector_switch.hpp
index 8030564..806da06 100644
--- a/inc/hostSelector_switch.hpp
+++ b/inc/hostSelector_switch.hpp
@@ -28,7 +28,7 @@
{
public:
HostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
- buttonConfig& buttonCfg) :
+ ButtonConfig& buttonCfg) :
sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Chassis::
Buttons::server::HostSelector>(
bus, path, action::defer_emit),
@@ -36,11 +36,14 @@
{
init();
// read and store the host selector position Map
- hsPosMap = buttonCfg.extraJsonInfo.at("host_selector_map")
- .get<std::map<std::string, int>>();
- maxPosition(buttonCfg.extraJsonInfo["max_position"], true);
- gpioLineCount = buttonCfg.gpios.size();
+ if (buttonCfg.type == ConfigType::gpio)
+ {
+ hsPosMap = buttonCfg.extraJsonInfo.at("host_selector_map")
+ .get<std::map<std::string, int>>();
+ gpioLineCount = buttonCfg.gpios.size();
+ }
setInitialHostSelectorValue();
+ maxPosition(buttonCfg.extraJsonInfo["max_position"], true);
emit_object_added();
}
@@ -63,6 +66,7 @@
size_t getGpioIndex(int fd);
void setInitialHostSelectorValue(void);
void setHostSelectorValue(int fd, GpioState state);
+ char getValueFromFd(int fd);
protected:
size_t hostSelectorPosition = 0;