x86-power-control: add passthrough option
Add a power and reset button passthrough option
for emulating button behavior by directly controlling
the control output pin.
Change-Id: I50df3e604401b4afd43fa89a0709466bbf01638b
Signed-off-by: Renze Nicolai <renze@rnplus.nl>
diff --git a/src/power_control.cpp b/src/power_control.cpp
index b020309..0fd422d 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -2067,6 +2067,16 @@
lg2::info("power button press masked");
}
}
+#if USE_BUTTON_PASSTHROUGH
+ gpiod::line gpioLine;
+ bool outputState =
+ asserted ? powerOutConfig.polarity : (!powerOutConfig.polarity);
+ if (!setGPIOOutput(powerOutConfig.lineName, outputState, gpioLine))
+ {
+ lg2::error("{GPIO_NAME} power button passthrough failed", "GPIO_NAME",
+ powerOutConfig.lineName);
+ }
+#endif
}
static void resetButtonHandler(bool state)
@@ -2086,6 +2096,16 @@
lg2::info("reset button press masked");
}
}
+#if USE_BUTTON_PASSTHROUGH
+ gpiod::line gpioLine;
+ bool outputState =
+ asserted ? resetOutConfig.polarity : (!resetOutConfig.polarity);
+ if (!setGPIOOutput(resetOutConfig.lineName, outputState, gpioLine))
+ {
+ lg2::error("{GPIO_NAME} reset button passthrough failed", "GPIO_NAME",
+ resetOutConfig.lineName);
+ }
+#endif
}
#ifdef CHASSIS_SYSTEM_RESET