Files
OpenCellular/include/physical_presence.h
Randall Spangler a6060f53ee cr50: Add physical presence state machine
This will be used as part of case closed debugging configuration.
Currently, this only adds the state machine, and a test command which
is available when CR50_DEV=1.  It also adds a new sleep mask flag for
physical presence detect, instead of oveloading FORCE_NO_DSLEEP.

The physical presence state machine supports both short (tap 5 times
in 15 seconds) and long (short, followed by 4 more taps 1-5 minutes
apart) sequences.  It will call a callback function at the end of the
sequence, so that multiple things can each request physical presence
in turn.  This will be used by ccdopen / ccdunlock / testlab commands
for CCD V1.

Eventually, CCD config will replace the unlock sequence handling in
wp.c.  But for now, we don't touch that.

See go/cr50-ccd-wp for more information.

BUG=b:62537474
BRANCH=none
TEST=manual
	Short sequence:
		pp short
		pp
		pp
		pp # See "Physical presence good"
	Timeout
		pp short
		pp # 15 sec later, get timeout error
	Long sequence:
		pp long
		pp
		pp
		pp
		(wait 2 sec)
		pp
		(wait 2 sec)
		pp # See "PP good"
	Long sequence, presses too fast:
		pp long
		pp
		pp
		pp
		pp # See "PP L too soon"
		(wait 2 sec)
		pp
		(wait 2 sec)
		pp # See "Physical presence good"
	Abort:
		pp short
		pp abort # See "Physical presence aborted"

Change-Id: I09da81ad11d328e7d7740c3fe838a5f67d7b8708
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/568796
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-07-19 14:41:21 -07:00

65 lines
1.9 KiB
C

/* Copyright 2017 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.
*
* Physical presence detection
*/
#ifndef __CROS_EC_PHYSICAL_PRESENCE_H
#define __CROS_EC_PHYSICAL_PRESENCE_H
/**
* Start physical presence detect.
*
* If the physical presence sequence is successful, callback() will be called
* from the hook task context as a deferred function.
*
* On failure or abort, callback() will not be called.
*
* @param is_long Use long (!=0) or short (0) sequence)
* @param callback Function to call when successful
* @return EC_SUCCESS, EC_BUSY if detect already in progress, or other
* non-zero error code if error.
*/
int physical_detect_start(int is_long, void (*callback)(void));
/**
* Check if a physical detect attempt is in progress
*
* @return non-zero if in progress
*/
int physical_detect_busy(void);
/**
* Abort a currently-running physical presence detect.
*
* Note there is a race condition between stopping detect and a running
* detect finishing and calling its callback. The intent of this function
* is not to prevent that, but instead to avoid an aborted physical detect
* tying up the button for long periods when we no longer care.
*/
void physical_detect_abort(void);
/**
* Handle a physical detect button press.
*
* This may be called from interrupt level.
*
* Returns EC_SUCCESS if the press was consumed, or EC_ERROR_NOT_HANDLED if
* physical detect was idle (so the press is for someone else).
*/
int physical_detect_press(void);
/**
* Start/stop capturing the button for physical presence.
*
* When enabled, a debounced button press+release should call
* physical_detect_press().
*
* This should be implemented by the board.
*
* @param enable Enable (!=0) or disable (==0) capturing button.
*/
void board_physical_presence_enable(int enable);
#endif /* __CROS_EC_PHYSICAL_PRESENCE_H */