From 1291eb4b1dafead1d6910ea0032ebbb3f31a612d Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Wed, 12 Nov 2014 20:53:51 -0800 Subject: [PATCH] plankton: reset USB hub on cable plug If USB hub is connected to the type-C port, we need to reset the hub whenever a cable plugs in. Otherwise, USB3.0 may fail to enumerate. BRANCH=None BUG=None TEST=Plug/unplug cable and measure hub reset signal. Change-Id: I60f67c83653d532971ee156914fe6ae0ecdb8d3a Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/229490 Reviewed-by: Pin-chih Lin Reviewed-by: Alec Berg --- board/plankton/board.c | 15 +++++++++++++++ board/plankton/board.h | 3 +++ board/plankton/usb_pd_policy.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/board/plankton/board.c b/board/plankton/board.c index ddabdc9297..de836dfc0d 100644 --- a/board/plankton/board.c +++ b/board/plankton/board.c @@ -225,6 +225,21 @@ static int board_usb_hub_reset(void) return pca9534_set_level(I2C_PORT_MASTER, 0x40, 7, 1); } +void board_maybe_reset_usb_hub(void) +{ + int ret; + int level; + + ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 6, PCA9534_INPUT); + if (ret) + return; + ret = pca9534_get_level(I2C_PORT_MASTER, 0x40, 6, &level); + if (ret) + return; + if (level == 1) + board_usb_hub_reset(); +} + static int cmd_usb_hub_reset(int argc, char *argv[]) { return board_usb_hub_reset(); diff --git a/board/plankton/board.h b/board/plankton/board.h index 46495178e0..50abc6faab 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -64,6 +64,9 @@ enum board_src_cap { /* Set USB PD source capability */ void board_set_source_cap(enum board_src_cap cap); +/* Reset USB hub if USB hub is switched to type-C port */ +void board_maybe_reset_usb_hub(void); + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index d5274ba0b5..b2fb708888 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -167,6 +167,10 @@ void pd_power_supply_reset(int port) int pd_board_checks(void) { + static int was_connected = -1; + if (was_connected != 1 && pd_is_connected(0)) + board_maybe_reset_usb_hub(); + was_connected = pd_is_connected(0); return EC_SUCCESS; }