diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-07-10 07:31:20 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-29 02:20:15 +0000 |
commit | d7cc6d59113deca4f11c021d63a4beeb293dbddb (patch) | |
tree | 3177b1cae7b0fe17a07905530fc906077e4545bb /common/power_button.c | |
parent | 63429076b3473ab261316a1136c02ab376256c20 (diff) | |
download | chrome-ec-d7cc6d59113deca4f11c021d63a4beeb293dbddb.tar.gz |
power_button: allow to modify the active level
On most platforms, the power button is active low,
but the power button on Ryu is active high.
Add CONFIG_POWER_BUTTON_ACTIVE_STATE to override the default active
state.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=on Ryu, use the servo pwr_button to start and stop the AP.
Change-Id: I11c6bb3c700bccd3606ce1fa1a69905671792990
Reviewed-on: https://chromium-review.googlesource.com/207274
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'common/power_button.c')
-rw-r--r-- | common/power_button.c | 8 |
1 files changed, 7 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) |