diff options
author | Wai-Hong Tam <waihong@google.com> | 2019-10-30 11:34:19 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-02 04:26:39 +0000 |
commit | 3c1eff2e293adeca40c0c919e63db4c62b89de41 (patch) | |
tree | e0d509c80610365972c61874e1c5a8fb46dc96d6 /common | |
parent | 7d4547799ca33dbc8806f2d7db99ca58d26173c6 (diff) | |
download | chrome-ec-3c1eff2e293adeca40c0c919e63db4c62b89de41.tar.gz |
servo_v4: The polarity is based on the flags in SRC DTS mode
When the port in SRC DTS mode, it should not perform the polarity
detection. The polarity is predetermined, as a board-specific
setting. In the servo case, the polarity is based on the flags.
This CL changes the protocol layer to check the port in SRC DTS mode
and call the board-specific function board_get_src_dts_polarity()
for the polarity.
BRANCH=servo
BUG=b:140876537
TEST=Configed servo as srcdts and unflipped direction:
> cc srcdts cc2
Verified the power negotiation good and detected the correct polarity:
> pd 1 state
Port C1 CC2, Ena - Role: SRC-UFP State: SRC_READY, Flags: 0x415e
Without this patch, it detected the wrong polarity and the power
negotiation failed:
> pd 1 state
Port C1 CC1, Ena - Role: SRC-DFP State: SRC_DISCOVERY, Flags: 0x10608
Change-Id: I32c5dfffeaeb20a21db1417f3a1c98566b7f5e38
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1891255
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Sean Abraham <seanabraham@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 5d5df2d4e5..71a3f5385b 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2697,6 +2697,16 @@ void pd_ping_enable(int port, int enable) pd[port].flags &= ~PD_FLAGS_PING_ENABLED; } +__overridable uint8_t board_get_src_dts_polarity(int port) +{ + /* + * If the port in SRC DTS, the polarity is determined by the board, + * i.e. what Rp impedance the CC lines are pulled. If this function + * is not overridden, assume CC1 is primary. + */ + return 0; +} + #if defined(CONFIG_CHARGE_MANAGER) /** @@ -3143,6 +3153,10 @@ void pd_task(void *u) if (pd[port].power_role == PD_ROLE_SINK) { pd[port].polarity = get_snk_polarity(cc1, cc2); + } else if (cc_is_snk_dbg_acc(cc1, cc2)) { + pd[port].polarity = + board_get_src_dts_polarity( + port); } else { pd[port].polarity = (cc1 != TYPEC_CC_VOLT_RD); @@ -3386,7 +3400,14 @@ void pd_task(void *u) /* Inform PPC that a sink is connected. */ ppc_sink_is_connected(port, 1); #endif /* CONFIG_USBC_PPC */ - pd[port].polarity = (cc1 != TYPEC_CC_VOLT_RD); + if (new_cc_state == PD_CC_UFP_DEBUG_ACC) { + pd[port].polarity = + board_get_src_dts_polarity( + port); + } else { + pd[port].polarity = + (cc1 != TYPEC_CC_VOLT_RD); + } set_polarity(port, pd[port].polarity); /* initial data role for source is DFP */ |