diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-11-06 08:28:25 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-11 11:00:54 -0800 |
commit | 8501badde7178f6197f534093ff7aae33af2ca71 (patch) | |
tree | c8242b2102f377ea59bd0ef4306f18867fb34c00 | |
parent | c391492dcaadb327c86592e46c89ffdf33d0965d (diff) | |
download | chrome-ec-8501badde7178f6197f534093ff7aae33af2ca71.tar.gz |
pd: set dedicated charger after boot with legacy charger
Fix bug with the new VBUS_NEVER_LOW flag in which if a BC1.2 charger
is attached on boot, we will not set the charger as a dedicated
charger and therefore not charge from it, until the charger is
disconnected and reconnected. This happens because in SNK_DISCOVERY
we will send soft reset first, and then when the charger doesn't
respond, we send hard reset. But, registering the charger as a
dedicated charger previously only happened when we send hard reset
directly after SNK_DISCOVERY state.
BUG=none
BRANCH=none
TEST=tested on glados. sysjump with bc1.2 charger plugged in and make
sure we charge from it.
Change-Id: Ida89304092a2186bcb2aa885917d706231490288
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311364
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index fc063d24b9..1ecefeb4da 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -912,6 +912,11 @@ static void handle_ctrl_request(int port, uint16_t head, break; case PD_CTRL_ACCEPT: if (pd[port].task_state == PD_STATE_SOFT_RESET) { + /* + * For the case that we sent soft reset in SNK_DISCOVERY + * on startup due to VBUS never low, clear the flag. + */ + pd[port].flags &= ~PD_FLAGS_VBUS_NEVER_LOW; execute_soft_reset(port); } else if (pd[port].task_state == PD_STATE_DR_SWAP) { /* switch data role */ @@ -2128,14 +2133,11 @@ void pd_task(void) * first, in case we were already in a stable * contract before this boot. */ - if (pd[port].flags & PD_FLAGS_VBUS_NEVER_LOW) { - pd[port].flags &= - ~PD_FLAGS_VBUS_NEVER_LOW; + if (pd[port].flags & PD_FLAGS_VBUS_NEVER_LOW) set_state_timeout(port, get_time().val + PD_T_SINK_WAIT_CAP, PD_STATE_SOFT_RESET); - } /* * If we haven't passed hard reset counter, * start SinkWaitCapTimer, otherwise start @@ -2432,7 +2434,10 @@ void pd_task(void) if (pd[port].last_state != pd[port].task_state) hard_reset_sent = 0; #ifdef CONFIG_CHARGE_MANAGER - if (pd[port].last_state == PD_STATE_SNK_DISCOVERY) { + if (pd[port].last_state == PD_STATE_SNK_DISCOVERY || + (pd[port].last_state == PD_STATE_SOFT_RESET && + (pd[port].flags & PD_FLAGS_VBUS_NEVER_LOW))) { + pd[port].flags &= ~PD_FLAGS_VBUS_NEVER_LOW; /* * If discovery timed out, assume that we * have a dedicated charger attached. This |