From fe0a3b99ff8303113c52e4573361325b44574b5c Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 25 Aug 2017 12:39:16 -0700 Subject: cr50: Split servo state machine into its own file This is the last state machine which used common/device_state.c. But servo is more complex than that, because it needs to differentiate state-isn't-known (debouncing) from state-isn't-knowable (Cr50 driving EC TX), so it's cleaner to split it out the way we did AP and EC state machines in previous CLs. BUG=b:35587387 BRANCH=cr50 TEST=manual with CR50_DEV=1 build // Test detect at boot, even with CCD connected Pull CCD_MODE_L low Pull DETECT_SERVO high Pull DETECT_EC high reboot -> 'Servo connect' // CCD is not driving EC UART TX ccd -> EC on, Servo connected, CCD enabled, EC UART RX // When servo disconnects CCD can drive EC TX Pull DETECT_SERVO low --> 'Servo disconnect' ccd -> EC on, Servo undetectable, CCD enabled, EC UART RX+TX // Can't detect servo reconnecting if we're driving EC TX Pull DETECT_SERVO high --> (no change) ccd -> EC on, Servo undetectable, CCD enabled, EC UART RX+TX // When we stop driving EC TX, can redetect servo Pull EC_DETECT low --> See 'EC off', 'Servo connected' ccd -> EC off, Servo connected, CCD enabled, EC UART disabled // Test debouncing at boot Pull DETECT_EC high Pull DETECT_SERVO low Pull CCD_MODE_L high reboot Within 1 sec, pull DETECT_SERVO high --> 'Servo connected' // Test debouncing after boot Pull DETECT_SERVO low then high < 1 sec --> (no message) Change-Id: I964bd36c35f52c8ef7b3ea3793b6e0764e93587c Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/636047 Reviewed-by: Mary Ruthven --- board/cr50/rdd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'board/cr50/rdd.c') diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c index 03b1785d90..db38fbcd52 100644 --- a/board/cr50/rdd.c +++ b/board/cr50/rdd.c @@ -5,7 +5,6 @@ #include "case_closed_debug.h" #include "console.h" -#include "device_state.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" @@ -51,11 +50,6 @@ static void uart_select_tx(int uart, int signal) } } -int servo_is_connected(void) -{ - return device_get_state(DEVICE_SERVO) == DEVICE_STATE_ON; -} - void uartn_tx_connect(int uart) { /* @@ -188,6 +182,7 @@ static int command_ccd(int argc, char **argv) print_ap_state(); print_ec_state(); print_rdd_state(); + print_servo_state(); ccprintf("CCD: %s\n", rdd_is_connected() ? "enabled" : "disabled"); ccprintf("AP UART: %s\n", -- cgit v1.2.1