summaryrefslogtreecommitdiff
path: root/common/usb_pd_tcpc.c
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2017-03-08 18:56:32 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-03-26 02:15:54 -0700
commit850e9e4ac0f84217b7fbc182b23821047e203307 (patch)
treea4834dedbba38f33b7f1038148d590a782b5d942 /common/usb_pd_tcpc.c
parent577fb7faa0fd8479921dfdf344a4d8bd44022e82 (diff)
downloadchrome-ec-850e9e4ac0f84217b7fbc182b23821047e203307.tar.gz
servo_v4: pd: Updated CC_NC and CC_RA macros
Previous boards that implemented tcpc layer on chip didn't support variable Rp values. However, servo_v4 can present any of the 3 possible Rp values and therefore the voltage thresholds that are used to determine a no-connect or Ra attach status need a way to be set based on the Rp value that's current attached to a given CC line. - Added port and cc line selection to both the CC_NC and CC_RA macros and now check if they are already defined before being defined in usb_pd_tcpc.c. - Defined each of these macros in board.h to use a function that's able to select the threshold based on the current Rp configuration. BUG=b:35586526 BRANCH=servo TEST=Tested with servo_v4 against Electro and verified that it connects when a charger is and is not connected to CHG port which exercises the differnt Rp combinations that servo_v4 presents. Change-Id: I1a31e430c0f290486f0fa8a50bdafdddf20d23ca Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/451962 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/usb_pd_tcpc.c')
-rw-r--r--common/usb_pd_tcpc.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c
index 491b471e22..0c620f7207 100644
--- a/common/usb_pd_tcpc.c
+++ b/common/usb_pd_tcpc.c
@@ -158,9 +158,13 @@ static const uint8_t dec4b5b[] = {
#define PD_SRC_VNC PD_SRC_DEF_VNC_MV
#endif
-#define CC_RA(cc) (cc < PD_SRC_RD_THRESHOLD)
+#ifndef CC_RA
+#define CC_RA(port, cc, sel) (cc < PD_SRC_RD_THRESHOLD)
+#endif
#define CC_RD(cc) ((cc >= PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC))
-#define CC_NC(cc) (cc >= PD_SRC_VNC)
+#ifndef CC_NC
+#define CC_NC(port, cc, sel) (cc >= PD_SRC_VNC)
+#endif
/*
* Polarity based on 'UFP Perspective'.
@@ -715,13 +719,13 @@ static void handle_request(int port, uint16_t head)
}
/* Convert CC voltage to CC status */
-static int cc_voltage_to_status(int port, int cc_volt)
+static int cc_voltage_to_status(int port, int cc_volt, int cc_sel)
{
/* If we have a pull-up, then we are source, check for Rd. */
if (pd[port].cc_pull == TYPEC_CC_RP) {
- if (CC_NC(cc_volt))
+ if (CC_NC(port, cc_volt, cc_sel))
return TYPEC_CC_VOLT_OPEN;
- else if (CC_RA(cc_volt))
+ else if (CC_RA(port, cc_volt, cc_sel))
return TYPEC_CC_VOLT_RA;
else
return TYPEC_CC_VOLT_RD;
@@ -824,7 +828,7 @@ int tcpc_run(int port, int evt)
cc = pd_adc_read(port, i);
/* convert voltage to status, and check status change */
- cc = cc_voltage_to_status(port, cc);
+ cc = cc_voltage_to_status(port, cc, i);
if (pd[port].cc_status[i] != cc) {
pd[port].cc_status[i] = cc;
alert(port, TCPC_REG_ALERT_CC_STATUS);
@@ -1109,7 +1113,8 @@ void tcpc_init(int port)
/* make initial readings of CC voltages */
for (i = 0; i < 2; i++) {
pd[port].cc_status[i] = cc_voltage_to_status(port,
- pd_adc_read(port, i));
+ pd_adc_read(port, i),
+ i);
}
#ifdef CONFIG_USB_PD_TCPC_TRACK_VBUS