diff options
author | Todd Broch <tbroch@chromium.org> | 2014-08-28 14:51:05 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-02 23:34:47 +0000 |
commit | 6bc911d978cb96694cb3f00d11fbe1848e10ab27 (patch) | |
tree | 7a6a8d39467ca0d7cf591caabec8476ce349e72f | |
parent | 31a935f520210e71dc9bddc3ec06911a8af8140a (diff) | |
download | chrome-ec-6bc911d978cb96694cb3f00d11fbe1848e10ab27.tar.gz |
pd: Expand polarity logic to include Ra pull-down logic.
Original implemenation of polarity only addressed Rd. This CL hopes
to address the addition of the Ra pull-down for powered accessories.
Truth table based on type-C specfication document is included in
source as well.
BRANCH=none
BUG=chrome-os-partner:28585
TEST=manual,
Setup:
<insert hoho into samus type-C port>
# from PD MCU console
typec <port>
Result:
See appropriate polarity. For example,
typec 1
Port C1: CC1 445 mV CC2 115 mV (polarity:CC1)
Superspeed USB1
<flip type-C accessory (hoho)>
typec 1
Port C1: CC1 119 mV CC2 426 mV (polarity:CC2)
Superspeed USB1
Also see correct polarity when just Rd is present.
Change-Id: I09073d731e4a6050281add3673cb4ec24c053da9
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/215666
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 3ab4719bb5..7952f12589 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -124,6 +124,33 @@ static const uint8_t dec4b5b[] = { #define PD_HARD_RESET (PD_RST1 | (PD_RST1 << 5) |\ (PD_RST1 << 10) | (PD_RST2 << 15)) +/* Polarity is based 'DFP Perspective' (see table USB Type-C Cable and Connector + * Specification) + * + * CC1 CC2 STATE POSITION + * ---------------------------------------- + * open open NC N/A + * Rd open UFP attached 1 + * open Rd UFP attached 2 + * open Ra pwr cable no UFP 1 + * Ra open pwr cable no UFP 2 + * Rd Ra pwr cable & UFP 1 + * Ra Rd pwr cable & UFP 2 + * Rd Rd dbg accessory N/A + * Ra Ra audio accessory N/A + * + * Note, V(Rd) > V(Ra) + * TODO(crosbug.com/p/31197): Need to identify necessary polarity switching for + * debug dongle. + * + */ +#ifndef PD_SRC_RD_THRESHOLD +#define PD_SRC_RD_THRESHOLD 200 /* mV */ +#endif +#define CC_RA(cc) (cc < PD_SRC_RD_THRESHOLD) +#define CC_RD(cc) ((cc > PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC)) +#define GET_POLARITY(cc1, cc2) (CC_RD(cc2) || CC_RA(cc1)) + /* PD counter definitions */ #define PD_MESSAGE_ID_COUNT 7 #define PD_RETRY_COUNT 2 @@ -1195,7 +1222,8 @@ void pd_task(void) cc2_volt = pd_adc_read(port, 1); if ((cc1_volt < PD_SRC_VNC) || (cc2_volt < PD_SRC_VNC)) { - pd[port].polarity = !(cc1_volt < PD_SRC_VNC); + pd[port].polarity = + GET_POLARITY(cc1_volt, cc2_volt); pd_select_polarity(port, pd[port].polarity); /* Set to USB SS initially */ #ifdef CONFIG_USBC_SS_MUX |