diff options
author | Patryk Duda <pdk@semihalf.com> | 2020-09-07 11:29:04 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-11 17:38:25 +0000 |
commit | 91953e21a8899a3f736f8c4dc2d31880d19193e9 (patch) | |
tree | fe2509f0438d135d00f02e432044c8343258d3c7 /board/eve/board.c | |
parent | d0ad43dbe419ec86b4c9429f071911205e994826 (diff) | |
download | chrome-ec-91953e21a8899a3f736f8c4dc2d31880d19193e9.tar.gz |
eve: Set dual role state on AC change in suspend
Eve doesn't provide VBUS in suspend when charger is disconnected.
When charger is connected - VBUS is provided. Therefore we need to
update dual role state on every AC change in suspend state.
This commit also provides implementation of pd_get_drp_state_in_suspend()
which is suitable for eve (return PD_DRP_FORCE_SINK when charger
is not connected).
BUG=b:162254118
BRANCH=none
TEST=Flash on eve. Connect charger.
Connect some device which acts as sink (eg. USB-C hub).
Make sure that eve is providing power to USB-C hub (port in
Attached.SRC state). Issue 'powerd_dbus_suspend' from developer
console. Port should be still in Attached.SRC state.
Disconnect charger, port should exit from Attached.SRC state.
DRP state should be set to force sink.
Flash on eve. Connect some device which acts as
sink (eg. USB-C hub). Make sure that eve is providing power
to USB-C hub (port in Attached.SRC state). Issue
'powerd_dbus_suspend' from developer console. Port should exit
from Attached.SRC state. DRP state should be set to force sink.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I690552d4330c4599ac997b7d64c314b2cae323db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395559
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/eve/board.c')
-rw-r--r-- | board/eve/board.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/board/eve/board.c b/board/eve/board.c index 4665698375..095b19ef3a 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -514,12 +514,36 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +__override enum pd_dual_role_states pd_get_drp_state_in_suspend(void) +{ + /* + * If board is not connected to charger it will disable VBUS + * on all ports that acts as source when going to suspend. + * Change DRP state to force sink, to inform TCPM about that. + */ + if (!extpower_is_present()) + return PD_DRP_FORCE_SINK; + + return PD_DRP_TOGGLE_OFF; +} + /** * Buffer the AC present GPIO to the PCH. + * Set appropriate DRP state when chipset in suspend */ static void board_extpower(void) { + enum pd_dual_role_states drp_state; + int port; + gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); + + if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_SUSPEND)) { + drp_state = pd_get_drp_state_in_suspend(); + for (port = 0; port < board_get_usb_pd_port_count(); port++) + if (pd_get_dual_role(port) != drp_state) + pd_set_dual_role(port, drp_state); + } } DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT); |