diff options
author | Mary Ruthven <mruthven@google.com> | 2018-05-03 14:34:48 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-07 20:45:51 -0700 |
commit | c24d480d90699bf6aaf534d66dc48513d867bdd0 (patch) | |
tree | 8cae26b83302a0261c9e4fc244761f51fa4e7f3e | |
parent | abbde30dd527568d04f6baf2557e668bb0597f35 (diff) | |
download | chrome-ec-c24d480d90699bf6aaf534d66dc48513d867bdd0.tar.gz |
cr50: disable s3_terms during init
When cr50 resumes from deep sleep term_enabled is reset to 0, but not
all of the s3 termination settings are reset. Some of them are, because
some of the gpios are defined in gpio.inc and cr50 will handle setting
those up during init, but others like the sps pulldowns aren't. At this
point, the term_enabled setting does not actually match the state of
enabled terminations.
After deep sleep reset if the AP is on, ccd update state will try to
disable the s3 terminations, but term_enabled is 0, so s3_term thinks
they're already disabled and wont do anything even though some of the
terminations are actually enabled.
This change initializes all of the s3_term stuff to disable during hook
init. This way things are reset so they won't interfere with sps_init.
This will also make sure to align the system state with term_enabled,
before the ccd hook starts getting called. It is safer to start with
disabling the terminations, because it wont interfere with tpm
communication if the AP is on. If the AP is off, ccd_update_state will
re-enable the terminations around a second after init.
BUG=b:62200096,b:79214702
BRANCH=cr50
TEST=firwmare_Cr50DeepSleepStress.reboot on bob
Change-Id: I9a90c7f7703b1406b4c494db448a8ac84d040d1c
Signed-off-by: Mary Ruthven <mruthven@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1043152
Commit-Ready: Mary Ruthven <mruthven@chromium.org>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | board/cr50/s3_term.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/board/cr50/s3_term.c b/board/cr50/s3_term.c index bb486d207e..53fc8b3e98 100644 --- a/board/cr50/s3_term.c +++ b/board/cr50/s3_term.c @@ -4,6 +4,7 @@ */ #include "console.h" +#include "hooks.h" #include "registers.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) @@ -12,7 +13,7 @@ #define AP_TX_TERM (1 << 0) #define SPS_TERM (1 << 1) -int term_enabled; +static uint8_t term_enabled; static void update_term_state(int term, int enable) { @@ -65,9 +66,10 @@ static void sps_term_enable(int term_enable) update_term_state(SPS_TERM, term_enable); } -void board_s3_term(int term_enable) +static void s3_term(int term_enable) { - if (!board_needs_s3_term() || (!term_enable == !term_enabled)) + /* If the board doesn't use s3_term, return before doing anything */ + if (!board_needs_s3_term()) return; CPRINTS("%sable S3 signal terminations", term_enable ? "En" : "Dis"); @@ -77,9 +79,31 @@ void board_s3_term(int term_enable) sps_term_enable(term_enable); } +/* + * Disable all terminations after cr50 reset. CCD state will re-enable them if + * needed. We just want to make sure any terminations enabled from the previous + * boot don't interfere with any other peripheral initialization. The pins + * s3_term controls may not be covered by the standard gpio init, so they won't + * be reset unless s3_term resets them during init. + */ +static void s3_term_init(void) +{ + s3_term(0); +} +DECLARE_HOOK(HOOK_INIT, s3_term_init, HOOK_PRIO_FIRST); + +void board_s3_term(int term_enable) +{ + /* Only update the terminations if something has changed */ + if (!term_enable == !term_enabled) + return; + s3_term(term_enable); +} + static int command_s3term(int argc, char **argv) { - ccprintf("Terminations:%s%s\n", + ccprintf("Terminations:%s%s%s\n", + term_enabled ? "" : "None", term_enabled & AP_TX_TERM ? " AP" : "", term_enabled & SPS_TERM ? " SPS" : ""); return EC_SUCCESS; |