summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-10-27 13:45:06 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-28 01:46:32 +0000
commitbf88b804ee831791378588e42c08a7c01f83ee40 (patch)
treea2d7d756d9b8fae91cf345bdce6dca3148ff86e9
parent2eb6cba5bd049bc74f84691dda7abcec650a9d10 (diff)
downloadchrome-ec-bf88b804ee831791378588e42c08a7c01f83ee40.tar.gz
usb_pd_protocol: Don't prematurely set PD charge supplier limit
Wait until we have a confirmed PD charger before setting the PD charge limit to non-zero. BUG=None TEST=Manual on samus_pd. Insert type C non-PD charger, verify that current limit is correctly set to to 3000 mA. BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ib4ec663d926e6ed955427e4a77123caac0e20252 Reviewed-on: https://chromium-review.googlesource.com/225691 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--common/usb_pd_protocol.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index aac2945a30..24cdf8e264 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1193,12 +1193,10 @@ void pd_ping_enable(int port, int enable)
}
#ifdef CONFIG_CHARGE_MANAGER
-/*
- * Initialize type C and PD current limits based upon cc_voltage. The PD
- * current limit may be revised upward (or downward to zero) depending on
- * PD negotiation.
+/**
+ * Returns type C current limit (mA) based upon cc_voltage (mV).
*/
-void pd_init_current_limits(int port, int cc_voltage)
+static inline int get_typec_current_limit(int cc_voltage)
{
int charge;
@@ -1211,18 +1209,8 @@ void pd_init_current_limits(int port, int cc_voltage)
charge = 500;
else
charge = 0;
- typec_set_input_current_limit(port, charge, TYPE_C_VOLTAGE);
- /*
- * Set the initial PD current limit based upon cc_voltage. If a PD
- * charger is attached, this will get changed upward later once
- * negotiation is complete.
- */
- if (cc_voltage > PD_SNK_VA)
- charge = PD_MIN_MA;
- else
- charge = 0;
- pd_set_input_current_limit(port, charge, PD_MIN_MV);
+ return charge;
}
#endif /* CONFIG_CHARGE_MANAGER */
@@ -1464,11 +1452,13 @@ void pd_task(void)
pd[port].msg_id = 0;
#ifdef CONFIG_CHARGE_MANAGER
initialized[port] = 1;
- pd_init_current_limits(port,
- pd[port].
- polarity ?
- cc2_volt :
- cc1_volt);
+ typec_set_input_current_limit(
+ port,
+ get_typec_current_limit(pd[port].
+ polarity ?
+ cc2_volt :
+ cc1_volt),
+ TYPE_C_VOLTAGE);
#endif
set_state(port, PD_STATE_SNK_DISCOVERY);
timeout = 10*MSEC;
@@ -1483,7 +1473,8 @@ void pd_task(void)
*/
if (!initialized[port]) {
initialized[port] = 1;
- pd_init_current_limits(port, 0);
+ typec_set_input_current_limit(port, 0, 0);
+ pd_set_input_current_limit(port, 0, 0);
}
#endif
/*
@@ -1519,6 +1510,7 @@ void pd_task(void)
break;
case PD_STATE_SNK_REQUESTED:
/* Ensure the power supply actually becomes ready */
+ pd_set_input_current_limit(port, PD_MIN_MA, PD_MIN_MV);
set_state(port, PD_STATE_SNK_TRANSITION);
hard_reset_count = 0;
timeout = 10 * MSEC;