Files
OpenCellular/include/power_button.h
Alexandru M Stan 6136b1fb09 Power Button: Wait for power button to be stable when waiting for release
The debounce timer might be too slow to actually update the state of
debounced_power_pressed by the time we do power_button_is_pressed in the S3->S5
state transition. Solution is to move the power_button_wait_for_release function
here and make sure there are no deferreds active.

BUG=chrome-os-partner:35948
TEST=During dev mode screen, press power button, note the device stays off
TEST=Print debounced_power_pressed in power_button_is_pressed(void), note it's
not 0 when power button is actually pressed
BRANCH=veyron

Change-Id: I8258e9e5524bd65d6ea9c77ea5649304d2195bf0
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/244590
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-10 23:07:14 +00:00

53 lines
1.3 KiB
C

/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Power button API for Chrome EC */
#ifndef __CROS_EC_POWER_BUTTON_H
#define __CROS_EC_POWER_BUTTON_H
#include "common.h"
/**
* Return non-zero if power button is pressed.
*
* Uses the debounced button state, not the raw signal from the GPIO.
*/
int power_button_is_pressed(void);
/**
* Wait for the power button to be released
*
* @param timeout_us Timeout in microseconds, or -1 to wait forever
* @return EC_SUCCESS if ok, or
* EC_ERROR_TIMEOUT if power button failed to release
*/
int power_button_wait_for_release(unsigned int timeout_us);
/**
* Return non-zero if power button signal asserted at hardware input.
*
*/
int power_button_signal_asserted(void);
/**
* Interrupt handler for power button.
*
* @param signal Signal which triggered the interrupt.
*/
void power_button_interrupt(enum gpio_signal signal);
/**
* For x86 systems, force-deassert the power button signal to the PCH.
*/
void power_button_pch_release(void);
/**
* For x86 systems, force a pulse of the power button signal to the PCH.
*/
void power_button_pch_pulse(void);
#endif /* __CROS_EC_POWER_BUTTON_H */