Add warm-reboot option support for reset button
Pressing reset button currently issues a reboot transion. However, some
platforms might expect to have force warm reboot instead. This commit
adds new reset-button-do-warm-reboot option to configure the expected
action for reset button on those platforms.
Tested:
- By default, on release of reset button, the Host is powered cycle.
- Enable reset-button-do-warm-reboot meson option. On release of reset
button, the Host is reset while Host power does not change.
Change-Id: I5d5f754f8b848fa0faef97354ef0dab7c47645f4
Signed-off-by: HuyLe <hule@amperecomputing.com>
diff --git a/README.md b/README.md
index 2b5b863..826492c 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,11 @@
### Reset Button
-When released, reboots the host.
+When released:
+
+- If 'reset-button-do-warm-reboot' meson option is set to enabled, does warm
+ reboot the host.
+- Otherwise, reboots the host (default behavior)
### ID Button
diff --git a/meson.build b/meson.build
index 2d1d1b8..3652ced 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,7 @@
conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled())
+conf_data.set('ENABLE_RESET_BUTTON_DO_WARM_REBOOT', get_option('reset-button-do-warm-reboot').enabled())
configure_file(output: 'config.h',
configuration: conf_data
diff --git a/meson_options.txt b/meson_options.txt
index 8fa5e59..c41ed4b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -26,3 +26,10 @@
value: 'default',
description : 'Used to select a custom power button behavior profile.'
)
+
+option(
+ 'reset-button-do-warm-reboot',
+ type : 'feature',
+ value : 'disabled',
+ description : 'Enable warm reboot on the reset button'
+)
diff --git a/src/button_handler.cpp b/src/button_handler.cpp
index 801cc9e..36ed096 100755
--- a/src/button_handler.cpp
+++ b/src/button_handler.cpp
@@ -284,7 +284,11 @@
}
lg2::info("Handling reset button press");
+#ifdef ENABLE_RESET_BUTTON_DO_WARM_REBOOT
+ transition = Host::Transition::ForceWarmReboot;
+#else
transition = Host::Transition::Reboot;
+#endif
break;
}
default: