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>
This commit is contained in:
Alec Berg
2015-11-06 08:28:25 -08:00
committed by chrome-bot
parent c391492dca
commit 8501badde7

View File

@@ -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