summaryrefslogtreecommitdiff
path: root/board/plankton
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2015-02-27 14:11:09 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-02 10:06:24 +0000
commit4e5c20fb07aeefdd3705bfb69d7ed40838e744ab (patch)
tree6b09b49836e020826e6ff1113b79cc222739b86f /board/plankton
parent179fcb3f1d0916f3cacea64c1d78b9644d6fa6ef (diff)
downloadchrome-ec-4e5c20fb07aeefdd3705bfb69d7ed40838e744ab.tar.gz
plankton: always run as UFP when in USB hub mode
When Plankton is in USB hub mode, running as DFP doesn't make sense. In this case, ask for a data swap. BRANCH=None BUG=chrome-os-partner:37079 TEST=With Ryu, check Plankton is always UFP no matter it's sink or source. Change-Id: I7752b8c1255234a5ea726138708fe52c5fcd47b2 Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/254713 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'board/plankton')
-rw-r--r--board/plankton/board.c25
-rw-r--r--board/plankton/board.h7
-rw-r--r--board/plankton/usb_pd_policy.c3
3 files changed, 25 insertions, 10 deletions
diff --git a/board/plankton/board.c b/board/plankton/board.c
index b081a0f479..b6c9c666ca 100644
--- a/board/plankton/board.c
+++ b/board/plankton/board.c
@@ -217,6 +217,20 @@ DECLARE_CONSOLE_COMMAND(usbc_action, cmd_usbc_action,
"Set Plankton type-C port state",
NULL);
+int board_in_hub_mode(void)
+{
+ int ret;
+ int level;
+
+ ret = pca9534_config_pin(I2C_PORT_MASTER, 0x40, 6, PCA9534_INPUT);
+ if (ret)
+ return -1;
+ ret = pca9534_get_level(I2C_PORT_MASTER, 0x40, 6, &level);
+ if (ret)
+ return -1;
+ return level;
+}
+
static int board_usb_hub_reset(void)
{
int ret;
@@ -233,16 +247,7 @@ static int board_usb_hub_reset(void)
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)
+ if (board_in_hub_mode() == 1)
board_usb_hub_reset();
}
diff --git a/board/plankton/board.h b/board/plankton/board.h
index a2accc8058..efb1bc7868 100644
--- a/board/plankton/board.h
+++ b/board/plankton/board.h
@@ -79,6 +79,13 @@ void board_update_fake_adc_value(int host_mode);
/* Set pull-up/pull-down on CC lines */
void board_pd_set_host_mode(int enable);
+/*
+ * Whether the board is in USB hub mode or not
+ *
+ * @return 1 when in hub mode, 0 when not, and -1 on error.
+ */
+int board_in_hub_mode(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */
diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c
index 628e244500..f007cd4b91 100644
--- a/board/plankton/usb_pd_policy.c
+++ b/board/plankton/usb_pd_policy.c
@@ -149,6 +149,9 @@ void pd_check_pr_role(int port, int pr_role, int partner_pr_swap)
void pd_check_dr_role(int port, int dr_role, int partner_dr_swap)
{
+ /* If Plankton is in USB hub mode, always act as UFP */
+ if (board_in_hub_mode() && dr_role == PD_ROLE_DFP && partner_dr_swap)
+ pd_request_data_swap(port);
}
int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload)