From 75e8dae37c698b00591c358025223d03a82d2a22 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Mon, 28 Sep 2015 18:58:08 -0700 Subject: pd: Always update charge manager on PD_CTRL_PS_RDY When a PD charger is found, we typically update charge manager voltage / current limits to what we want to request, set a 500mA ceiling, and then wait for negoiation to complete. If it completes as expected, we simply remove the 500mA ceiling. When we're already negotiated with a port and we receive a new power request, we may switch to a different voltage / current limit. If we do so, charge manager won't get updated with the existing design because we don't get new source cap information. Therefore, update charge manager whenever we receive PD_CTRL_PS_RDY as a sink. Typically, the update will have no effect because we'll be writing identical values. In the new power request case though it will serve to inform charge manager of the new mode. BUG=chrome-os-partner:45932 TEST=Manual on ryu. Insert zinger, run `pd 0 dev 5` followed by `bq` to verify 3A limit is set as expected. BRANCH=ryu Signed-off-by: Shawn Nematbakhsh Change-Id: I8cc3ac0a3eb603cdeb45ea437906303abcaedac0 Reviewed-on: https://chromium-review.googlesource.com/302844 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Alec Berg --- common/usb_pd_protocol.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 23aae650c0..28389b274f 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -904,14 +904,13 @@ static void handle_ctrl_request(int port, uint16_t head, /* Do nothing, assume this is a redundant PD_RDY */ } else if (pd[port].power_role == PD_ROLE_SINK) { set_state(port, PD_STATE_SNK_READY); + pd_set_input_current_limit(port, pd[port].curr_limit, + pd[port].supply_voltage); #ifdef CONFIG_CHARGE_MANAGER /* Set ceiling based on what's negotiated */ charge_manager_set_ceil(port, CEIL_REQUESTOR_PD, pd[port].curr_limit); -#else - pd_set_input_current_limit(port, pd[port].curr_limit, - pd[port].supply_voltage); #endif } break; -- cgit v1.2.1