summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-12-12 12:27:16 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-13 02:52:56 +0000
commit394192d71258df12c86d100f58f1d5521d133e82 (patch)
tree34992cffb8ea2e32a4f6ccf714798997a03bbd8b
parent33142ba9ac61833ad10ffe5b7b6a2ca0e7be9912 (diff)
downloadchrome-ec-394192d71258df12c86d100f58f1d5521d133e82.tar.gz
pd: fix bug constantly sending HC's with non-PD aware charger
Fix bug where if we have a non-PD aware charger, we constantly send host events to notify EC of an input current limit change. This was unintentionally broken when adding code to constantly monitor the CC line pull-up strength and adjust the current limit accordingly. BUG=none BRANCH=samus TEST=plug in a non-PD aware charger and make sure it sets the correct input current limit and that it is not constantly sending host events that the limit has changed. Change-Id: I7d835769ebc768043a9a46f50721987dce0384f5 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235414 Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
-rw-r--r--common/usb_pd_protocol.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index ee7b1585ac..b9722e3cfe 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1971,20 +1971,22 @@ void pd_task(void)
get_time().val +
PD_T_SINK_WAIT_CAP,
PD_STATE_HARD_RESET_SEND);
+#ifdef CONFIG_CHARGE_MANAGER
+ /*
+ * If we didn't come from disconnected, must
+ * have come from some path that did not set
+ * typec current limit. So, set to 0 so that
+ * we guarantee this is revised below.
+ */
+ if (pd[port].last_state !=
+ PD_STATE_SNK_DISCONNECTED)
+ typec_curr = 0;
+#endif
}
#ifdef CONFIG_CHARGE_MANAGER
timeout = PD_T_SINK_ADJ - PD_T_DEBOUNCE;
- /*
- * If we didn't come from disconnected, must have
- * come from some path that did not set typec
- * current limit. So, set to 0 so that we guarantee
- * this is revised below.
- */
- if (pd[port].last_state != PD_STATE_SNK_DISCONNECTED)
- typec_curr = 0;
-
/* Check if CC pull-up has changed */
cc1_volt = pd_adc_read(port, pd[port].polarity);
if (typec_curr != get_typec_current_limit(cc1_volt)) {