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/meson.build b/meson.build
index 6117245..80eeed6 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,9 @@
if get_option('ignore-soft-resets-during-post').allowed()
cpp_args += '-DIGNORE_SOFT_RESETS_DURING_POST'
endif
+if get_option('button-passthrough').allowed()
+ cpp_args += '-DUSE_BUTTON_PASSTHROUGH'
+endif
deps = [
dependency('libgpiodcxx', default_options: ['bindings=cxx']),
diff --git a/meson.options b/meson.options
index c32fd30..07adb15 100644
--- a/meson.options
+++ b/meson.options
@@ -6,3 +6,5 @@
description: 'Use hardware Reset Reason to control Power Restore. Note: this only works with Intel-BMC')
option('ignore-soft-resets-during-post', type: 'feature', value : 'disabled',
description: 'Ignore soft resets from host during POST')
+option('button-passthrough', type: 'feature', value : 'disabled',
+ description: 'Directly couple through power and reset buttons')
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