diff options
author | Namyoon Woo <namyoon@chromium.org> | 2019-01-04 18:04:49 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-09 11:55:37 -0800 |
commit | bad4ea14581f20bb298a597bee9549619ff4d096 (patch) | |
tree | 98ee6b30b176f0176c4791fd2a25f2ccee623ad5 | |
parent | c78bd78daca4d6a3f5befbfe9475eaf306e5238e (diff) | |
download | chrome-ec-bad4ea14581f20bb298a597bee9549619ff4d096.tar.gz |
cr50: Deferred RDD check in deasserting EC_RST_L.
RDD connection can be detected after the debug cables comparator
values are stable, which takes RDD_MAX_WAIT_TIME_COUNTER.
This CL changes to check RDD connection in a deferred way only when
it is a power-on reset and the power button is held.
This CL increases Flash memory usage by 40 bytes.
BRANCH=cr50
BUG=b:37351386
TEST=manually on bob, coral and scarlet.
1. (EC) cutoff
2. unplug all cables.
3. hold the power button.
4. plug USB-C cable of Servo V4 (or SuzyQ cable) in.
5. check EC console. Should be off.
To verify, run the cr50 console command, 'ecrst' and check
if 'EC_RST_L' is asserted.
6. release the power button. EC should run.
Change-Id: I4c7b0653bf49fbe57c8ad8395c72e006fa3a0ff0
Signed-off-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1398921
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r-- | chip/g/rbox.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/chip/g/rbox.c b/chip/g/rbox.c index 00fac521b6..005ed547c1 100644 --- a/chip/g/rbox.c +++ b/chip/g/rbox.c @@ -32,18 +32,42 @@ int rbox_powerbtn_is_pressed(void) return !GREAD_FIELD(RBOX, CHECK_OUTPUT, PWRB_OUT); } +/* + * This is 4X as RDD_MAX_WAIT_TIME_COUNTER default value, which should be + * long enough for rdd_is_detected() to represent a stable RDD status + */ +#define RDD_WAIT_TIME (40 * MSEC) + +/* + * Delay EC_RST_L release if RDD cable is connected, or release EC_RST_L + * otherwise. + */ +static void rbox_check_rdd(void) +{ +#ifdef CR50_DEV + print_rdd_state(); +#endif + if (rbox_powerbtn_is_pressed() && rdd_is_detected()) { + power_button_release_enable_interrupt(1); + return; + } + + deassert_ec_rst(); +} +DECLARE_DEFERRED(rbox_check_rdd); + static void rbox_release_ec_reset(void) { /* Unfreeze the PINMUX */ GREG32(PINMUX, HOLD) = 0; /* - * After a POR, if it finds RDD cable plugged and Power button pressed, - * then it delays releasing EC-reset until power button gets released. + * After a POR, if the power button is held, then delay releasing + * EC_RST_L. */ if ((system_get_reset_flags() & RESET_FLAG_POWER_ON) && - rdd_is_detected() && rbox_powerbtn_is_pressed()) { - power_button_release_enable_interrupt(1); + rbox_powerbtn_is_pressed()) { + hook_call_deferred(&rbox_check_rdd_data, RDD_WAIT_TIME); return; } |