diff options
author | Vic Yang <victoryang@chromium.org> | 2014-09-02 13:06:04 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-03 04:47:38 +0000 |
commit | 386ada84e9464b0c3ec76cf64129e40a2f0c9131 (patch) | |
tree | 4f09cfdf1cf5bff40a31226ebd2ea82829f5c17d | |
parent | 6bc911d978cb96694cb3f00d11fbe1848e10ab27 (diff) | |
download | chrome-ec-386ada84e9464b0c3ec76cf64129e40a2f0c9131.tar.gz |
pd: Initialize dual role state based on chipset state
When we do sysjump, the chipset might be in any of S0/S3/S5 states, and
thus we cannot just initialize the dual role state to its default state.
Instead, let's look at the chipset state and set the appropriate dual
role state.
BUG=chrome-os-partner:31724
TEST=On Ryu, do a sysjump and check dual role state.
BRANCH=factory-ryu-6212.B
Change-Id: I67abcc7fb1357d11498973a831ab8b32dad670ce
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/215866
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 7952f12589..c2735863f1 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -5,6 +5,7 @@ #include "adc.h" #include "board.h" +#include "chipset.h" #include "common.h" #include "console.h" #include "crc.h" @@ -1499,6 +1500,19 @@ static void dual_role_force_sink(void) CPRINTS("chipset -> S5, force dual-role port to sink"); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, dual_role_force_sink, HOOK_PRIO_DEFAULT); + +#ifdef HAS_TASK_CHIPSET +static void dual_role_init(void) +{ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + dual_role_force_sink(); + else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) + dual_role_off(); + else /* CHIPSET_STATE_ON */ + dual_role_on(); +} +DECLARE_HOOK(HOOK_INIT, dual_role_init, HOOK_PRIO_DEFAULT); +#endif /* HAS_TASK_CHIPSET */ #endif /* CONFIG_USB_PD_DUAL_ROLE */ #ifdef CONFIG_COMMON_RUNTIME |