diff options
-rw-r--r-- | common/power_button.c | 8 | ||||
-rw-r--r-- | include/config.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/common/power_button.c b/common/power_button.c index a87fadc2ff..7d7e90b86d 100644 --- a/common/power_button.c +++ b/common/power_button.c @@ -20,6 +20,11 @@ #define CPUTS(outstr) cputs(CC_SWITCH, outstr) #define CPRINTS(format, args...) cprints(CC_SWITCH, format, ## args) +/* By default the power button is active low */ +#ifndef CONFIG_POWER_BUTTON_ACTIVE_STATE +#define CONFIG_POWER_BUTTON_ACTIVE_STATE 0 +#endif + #define PWRBTN_DEBOUNCE_US (30 * MSEC) /* Debounce time for power button */ static int debounced_power_pressed; /* Debounced power button state */ @@ -45,7 +50,8 @@ static int raw_power_button_pressed(void) return 0; #endif - return gpio_get_level(GPIO_POWER_BUTTON_L) ? 0 : 1; + return !!(gpio_get_level(GPIO_POWER_BUTTON_L) + == CONFIG_POWER_BUTTON_ACTIVE_STATE); } int power_button_is_pressed(void) diff --git a/include/config.h b/include/config.h index f82547da21..0b5132e8ab 100644 --- a/include/config.h +++ b/include/config.h @@ -715,6 +715,9 @@ /* Compile common code to support power button debouncing */ #undef CONFIG_POWER_BUTTON +/* Force the active state of the power button : 0(default if unset) or 1 */ +#undef CONFIG_POWER_BUTTON_ACTIVE_STATE + /* Allow the power button to send events while the lid is closed */ #undef CONFIG_POWER_BUTTON_IGNORE_LID |