summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-04-28 18:12:47 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-30 09:42:52 +0000
commitbc72ea3e17007577cfdb87d068bbc1883a591ad2 (patch)
tree466308630c4b83b46d1c11e34d25efd5b5dc2a32 /common
parent439bfbddedde616c3417163a6c018a606281c17d (diff)
downloadchrome-ec-bc72ea3e17007577cfdb87d068bbc1883a591ad2.tar.gz
pd: handle plug polarity
Use the plug polarity detected by the ADCs to do the PD communication on the right CCx line. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28339 TEST=make buildall on Firefly, plug Zinger connector in both direction and see it can control it either way. on Fruitpie, use CC1 or CC2 and see it can communicate on both. Change-Id: I81cb00f164cb8194fba73b383014e81c37d975e2 Reviewed-on: https://chromium-review.googlesource.com/197520 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_protocol.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index b5c64d83f8..23cb178bff 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -273,8 +273,8 @@ static void send_hard_reset(void *ctxt)
/* Ensure that we have a final edge */
off = pd_write_last_edge(ctxt, off);
/* Transmit the packet */
- pd_start_tx(ctxt, off);
- pd_tx_done();
+ pd_start_tx(ctxt, pd_polarity, off);
+ pd_tx_done(pd_polarity);
}
static int send_validate_message(void *ctxt, uint16_t header, uint8_t cnt,
@@ -290,8 +290,8 @@ static int send_validate_message(void *ctxt, uint16_t header, uint8_t cnt,
/* write the encoded packet in the transmission buffer */
bit_len = prepare_message(ctxt, header, cnt, data);
/* Transmit the packet */
- pd_start_tx(ctxt, bit_len);
- pd_tx_done();
+ pd_start_tx(ctxt, pd_polarity, bit_len);
+ pd_tx_done(pd_polarity);
/* starting waiting for GoodCrc */
pd_rx_start();
/* read the incoming packet if any */
@@ -336,8 +336,8 @@ static void send_goodcrc(void *ctxt, int id)
uint16_t header = PD_HEADER(PD_CTRL_GOOD_CRC, pd_role, id, 0);
int bit_len = prepare_message(ctxt, header, 0, NULL);
- pd_start_tx(ctxt, bit_len);
- pd_tx_done();
+ pd_start_tx(ctxt, pd_polarity, bit_len);
+ pd_tx_done(pd_polarity);
}
static int send_source_cap(void *ctxt)
@@ -654,6 +654,7 @@ void pd_task(void)
if ((cc1_volt < PD_SRC_VNC) ||
(cc2_volt < PD_SRC_VNC)) {
pd_polarity = !(cc1_volt < PD_SRC_VNC);
+ pd_select_polarity(pd_polarity);
pd_task_state = PD_STATE_SRC_DISCOVERY;
}
timeout = 10000;
@@ -707,6 +708,7 @@ void pd_task(void)
if ((cc1_volt > PD_SNK_VA) ||
(cc2_volt > PD_SNK_VA)) {
pd_polarity = !(cc1_volt > PD_SNK_VA);
+ pd_select_polarity(pd_polarity);
pd_task_state = PD_STATE_SNK_DISCOVERY;
}
timeout = 10000;