mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
pd: fix possible redundant requests (again)
Another fix for redundant requests. This time there can be redundant requests if the maximum allowed voltage changes, but we still fall into the samus PDO index and therefore are asking for the same voltage. This fixes by checking the voltage value we actually request vs. the max value we can request. BUG=none BRANCH=samus TEST=samus to samus was causing redundant requests and now it's not. Change-Id: Ie49add1a42b86de97cee87f9d4637dd0578e2ce3 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239950 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
This commit is contained in:
@@ -117,24 +117,16 @@ int pd_build_request(int cnt, uint32_t *src_caps, uint32_t *rdo,
|
||||
|
||||
pd_extract_pdo_power(src_caps[pdo_index], ma, mv);
|
||||
uw = *ma * *mv;
|
||||
/* Mismatch bit set if less power offered than the operating power */
|
||||
if (uw < (1000 * PD_OPERATING_POWER_MW))
|
||||
flags |= RDO_CAP_MISMATCH;
|
||||
|
||||
if ((src_caps[pdo_index] & PDO_TYPE_MASK) == PDO_TYPE_BATTERY) {
|
||||
int mw = uw / 1000;
|
||||
*rdo = RDO_BATT(pdo_index + 1, mw, mw, flags);
|
||||
CPRINTF("Request [%d] %dmV %dmW",
|
||||
pdo_index, *mv, mw);
|
||||
} else {
|
||||
*rdo = RDO_FIXED(pdo_index + 1, *ma, *ma, flags);
|
||||
CPRINTF("Request [%d] %dmV %dmA",
|
||||
pdo_index, *mv, *ma);
|
||||
}
|
||||
/* Mismatch bit set if less power offered than the operating power */
|
||||
if (flags & RDO_CAP_MISMATCH)
|
||||
CPRINTF(" Mismatch");
|
||||
CPRINTF("\n");
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -890,7 +890,6 @@ static void pd_store_src_cap(int port, int cnt, uint32_t *src_caps)
|
||||
static void pd_send_request_msg(int port, int always_send_request)
|
||||
{
|
||||
uint32_t rdo, curr_limit, supply_voltage;
|
||||
int request_mv;
|
||||
int res;
|
||||
|
||||
#ifdef CONFIG_CHARGE_MANAGER
|
||||
@@ -903,12 +902,6 @@ static void pd_send_request_msg(int port, int always_send_request)
|
||||
|
||||
/* Build and send request RDO */
|
||||
/* If this port is not actively charging, select vSafe5V */
|
||||
request_mv = charging ? pd_get_max_voltage() : PD_MIN_MV;
|
||||
|
||||
/* Don't re-request the same voltage */
|
||||
if (!always_send_request && pd[port].prev_request_mv == request_mv)
|
||||
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);
|
||||
@@ -920,9 +913,19 @@ static void pd_send_request_msg(int port, int always_send_request)
|
||||
*/
|
||||
return;
|
||||
|
||||
/* Don't re-request the same voltage */
|
||||
if (!always_send_request && pd[port].prev_request_mv == supply_voltage)
|
||||
return;
|
||||
|
||||
CPRINTF("Request [%d] %dmV %dmA", RDO_POS(rdo),
|
||||
supply_voltage, curr_limit);
|
||||
if (rdo & RDO_CAP_MISMATCH)
|
||||
CPRINTF(" Mismatch");
|
||||
CPRINTF("\n");
|
||||
|
||||
pd[port].curr_limit = curr_limit;
|
||||
pd[port].supply_voltage = supply_voltage;
|
||||
pd[port].prev_request_mv = request_mv;
|
||||
pd[port].prev_request_mv = supply_voltage;
|
||||
res = send_request(port, rdo);
|
||||
if (res >= 0)
|
||||
set_state(port, PD_STATE_SNK_REQUESTED);
|
||||
|
||||
@@ -76,6 +76,7 @@ enum pd_errors {
|
||||
|
||||
/* RDO : Request Data Object */
|
||||
#define RDO_OBJ_POS(n) (((n) & 0x7) << 28)
|
||||
#define RDO_POS(rdo) (((rdo) >> 28) & 0x7)
|
||||
#define RDO_GIVE_BACK (1 << 27)
|
||||
#define RDO_CAP_MISMATCH (1 << 26)
|
||||
#define RDO_COMM_CAP (1 << 25)
|
||||
|
||||
Reference in New Issue
Block a user