From 394192d71258df12c86d100f58f1d5521d133e82 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Fri, 12 Dec 2014 12:27:16 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/235414 Reviewed-by: Shawn Nematbakhsh --- common/usb_pd_protocol.c | 20 +++++++++++--------- 1 file 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)) { -- cgit v1.2.1