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>
This commit is contained in:
Vincent Palatin
2014-07-10 07:31:20 -07:00
committed by chrome-internal-fetch
parent 63429076b3
commit d7cc6d5911
2 changed files with 10 additions and 1 deletions

View File

@@ -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)

View File

@@ -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