diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2014-12-11 08:38:37 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-11 23:40:05 +0000 |
commit | 73949da5d907689d8e3b04f09fe8d200d3b223cd (patch) | |
tree | 39fa1616a530472c0c77ba4e0a2d84a266ce5743 | |
parent | 34fe8658abe4e6b63b3d1b5e727ba8c792110431 (diff) | |
download | chrome-ec-73949da5d907689d8e3b04f09fe8d200d3b223cd.tar.gz |
pd: Remove needless re-requests of same charge mode
If a PD charger is attached and immediately becomes our charge port, we
will request PD_REQUEST_MAX twice. Remove this needless re-request by
storing the previous request, and only re-requesting from
PD_STATE_SNK_READY if the request has changed.
BUG=chrome-os-partner:34168
TEST=Manual on Samus. Plug Zinger as lone charger, verify that 20V @ 3A
is requested only once. Plug second Zinger in second port, verify that
5V @ 3A is correctly requested.
BRANCH=samus.
Change-Id: Ife6fa9788e97a045edbca5d83933af57cd0ea91d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/234701
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index e522d4bac4..ee7b1585ac 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -252,6 +252,8 @@ static struct pd_protocol { uint32_t supply_voltage; /* Signal charging update that affects the port */ int new_power_request; + /* Store previously requested power type */ + enum pd_request_type previous_pd_request; #endif /* PD state for Vendor Defined Messages */ @@ -771,9 +773,10 @@ static void pd_store_src_cap(int port, int cnt, uint32_t *src_caps) pd_src_caps[port][i] = *src_caps++; } -static void pd_send_request_msg(int port) +static void pd_send_request_msg(int port, int always_send_request) { uint32_t rdo, curr_limit, supply_voltage; + enum pd_request_type request; int res; #ifdef CONFIG_CHARGE_MANAGER @@ -786,9 +789,14 @@ static void pd_send_request_msg(int port) /* Build and send request RDO */ /* If this port is not actively charging, select vSafe5V */ + request = charging ? PD_REQUEST_MAX : PD_REQUEST_VSAFE5V; + + /* Don't re-request the same state */ + if (!always_send_request && pd[port].previous_pd_request == request) + return; + res = pd_build_request(pd_src_cap_cnt[port], pd_src_caps[port], - &rdo, &curr_limit, &supply_voltage, - charging ? PD_REQUEST_MAX : PD_REQUEST_VSAFE5V); + &rdo, &curr_limit, &supply_voltage, request); if (res != EC_SUCCESS) /* @@ -799,6 +807,7 @@ static void pd_send_request_msg(int port) pd[port].curr_limit = curr_limit; pd[port].supply_voltage = supply_voltage; + pd[port].previous_pd_request = request; res = send_request(port, rdo); if (res >= 0) set_state(port, PD_STATE_SNK_REQUESTED); @@ -844,7 +853,7 @@ static void handle_data_request(int port, uint16_t head, pd_process_source_cap(port, pd_src_cap_cnt[port], pd_src_caps[port]); - pd_send_request_msg(port); + pd_send_request_msg(port, 1); } break; #endif /* CONFIG_USB_PD_DUAL_ROLE */ @@ -2026,7 +2035,7 @@ void pd_task(void) /* Check for new power to request */ if (pd[port].new_power_request) { - pd_send_request_msg(port); + pd_send_request_msg(port, 0); break; } |