From bf368218e517c47bc5dfe92566431182e55c68b7 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Mon, 22 Sep 2014 19:36:58 +0800 Subject: plankton: Do not send soft reset unless already sourcing power When 5v/12v/20v buttons are pressed, plankton first switchs to source role, set the requested source cap, and then perform a soft reset. However, if plankton was sink and just switched to source, the port partner might not have switched to sink and this leaves the CC line in a state where communication is not possible. The subsequent soft reset then fails. If we are not already sourcing power, we actually don't need a soft reset after changing source cap. BUG=chrome-os-partner:32163 TEST=Switch from sink to source. Doesn't see "soft reset" in console. TEST=Switch from 5V to 12V. See "soft reset". BRANCH=None Change-Id: Ia4b834c2e7dc1324b9143c46a72938845499e2fb Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/219004 Reviewed-by: Alec Berg --- board/plankton/board.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/board/plankton/board.c b/board/plankton/board.c index b563fdaf74..fb3a2914dc 100644 --- a/board/plankton/board.c +++ b/board/plankton/board.c @@ -36,25 +36,31 @@ enum usbc_action { USBC_ACT_CABLE_FLIP, USBC_ACT_CABLE_POLARITY0, USBC_ACT_CABLE_POLARITY1, + + /* Number of USBC actions */ + USBC_ACT_COUNT +}; + +enum board_src_cap src_cap_mapping[USBC_ACT_COUNT] = +{ + [USBC_ACT_5V_TO_DUT] = SRC_CAP_5V, + [USBC_ACT_12V_TO_DUT] = SRC_CAP_12V, + [USBC_ACT_20V_TO_DUT] = SRC_CAP_20V, }; static void set_usbc_action(enum usbc_action act) { + int need_soft_reset; + switch (act) { case USBC_ACT_5V_TO_DUT: - board_set_source_cap(SRC_CAP_5V); - pd_set_dual_role(PD_DRP_FORCE_SOURCE); - pd_soft_reset(); - break; case USBC_ACT_12V_TO_DUT: - board_set_source_cap(SRC_CAP_12V); - pd_set_dual_role(PD_DRP_FORCE_SOURCE); - pd_soft_reset(); - break; case USBC_ACT_20V_TO_DUT: - board_set_source_cap(SRC_CAP_20V); + need_soft_reset = gpio_get_level(GPIO_VBUS_CHARGER_EN); + board_set_source_cap(src_cap_mapping[act]); pd_set_dual_role(PD_DRP_FORCE_SOURCE); - pd_soft_reset(); + if (need_soft_reset) + pd_soft_reset(); break; case USBC_ACT_DEVICE: pd_set_dual_role(PD_DRP_FORCE_SINK); -- cgit v1.2.1