diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-05-04 10:44:52 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-05 03:36:24 +0000 |
commit | 828086e961c0107bbdd65fa1086c082e95c912fc (patch) | |
tree | 63dd7a3750d5f1bc13ad0f0787d5822dd422d253 /board/samus_pd | |
parent | 1abcdf9145eaa4508546190f76577289dcd04803 (diff) | |
download | chrome-ec-828086e961c0107bbdd65fa1086c082e95c912fc.tar.gz |
pd: add explicit setting of D+/D- switch when setting type-C muxes
Add explicit setting of USB D+/D- switch when setting the type-C
muxes. This fixes a bug in which we would open D+/D- switch when
entering DP mode and lose USB2.0 connection.
BUG=chrome-os-partner:39766
BRANCH=samus
TEST=add printf to board_set_usb_switches() on samus and make sure
we don't open the D+/D- switch when entering DP mode.
Change-Id: I2b5bb2185298794ddb4cc457f3695ce6adabd9f8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/268993
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/samus_pd')
-rw-r--r-- | board/samus_pd/board.c | 11 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_config.h | 2 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 4 |
3 files changed, 10 insertions, 7 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index 13ccc90d37..165c8ebe4f 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -553,6 +553,9 @@ BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == PD_PORT_COUNT); static void board_set_usb_switches(int port, int open) { + /* If switch is not changing, then return */ + if (open == usb_switch_state[port]) + return; mutex_lock(&usb_switch_lock[port]); usb_switch_state[port] = open; @@ -560,7 +563,8 @@ static void board_set_usb_switches(int port, int open) mutex_unlock(&usb_switch_lock[port]); } -void board_set_usb_mux(int port, enum typec_mux mux, int polarity) +void board_set_usb_mux(int port, enum typec_mux mux, + enum usb_switch usb, int polarity) { const struct usb_port_mux *usb_mux = usb_muxes + port; @@ -572,9 +576,8 @@ void board_set_usb_mux(int port, enum typec_mux mux, int polarity) gpio_set_level(usb_mux->ss1_dp_mode, 1); gpio_set_level(usb_mux->ss2_dp_mode, 1); - if ((mux == TYPEC_MUX_NONE) || (mux == TYPEC_MUX_USB)) - /* Set D+/D- switch to appropriate level */ - board_set_usb_switches(port, mux == TYPEC_MUX_NONE); + /* Set D+/D- switch to appropriate level */ + board_set_usb_switches(port, usb); if (mux == TYPEC_MUX_NONE) /* everything is already disabled, we can return */ diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h index a7df33e499..b655c8e914 100644 --- a/board/samus_pd/usb_pd_config.h +++ b/board/samus_pd/usb_pd_config.h @@ -247,7 +247,7 @@ static inline void pd_config_init(int port, uint8_t power_role) pd_tx_init(); /* Reset mux ... for NONE polarity doesn't matter */ - board_set_usb_mux(port, TYPEC_MUX_NONE, 0); + board_set_usb_mux(port, TYPEC_MUX_NONE, USB_SWITCH_DISCONNECT, 0); if (port == 0) { gpio_set_level(GPIO_USB_C0_CC1_VCONN1_EN_L, 1); diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 431c281b1e..05df870be9 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -264,7 +264,7 @@ static uint32_t dp_status[PD_PORT_COUNT]; static void svdm_safe_dp_mode(int port) { /* make DP interface safe until configure */ - board_set_usb_mux(port, TYPEC_MUX_NONE, pd_get_polarity(port)); + board_set_usb_mux(port, TYPEC_MUX_NONE, USB_SWITCH_CONNECT, 0); dp_flags[port] = 0; dp_status[port] = 0; } @@ -306,7 +306,7 @@ static int svdm_dp_config(int port, uint32_t *payload) return 0; board_set_usb_mux(port, mf_pref ? TYPEC_MUX_DOCK : TYPEC_MUX_DP, - pd_get_polarity(port)); + USB_SWITCH_CONNECT, pd_get_polarity(port)); payload[0] = VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); |