pd: Honor both max power and current for all power source

Currently, we only use PD_MAX_POWER_MW for battery power source and
PD_MAX_CURRENT_MA for other sources. This change makes it so that both
limits are honored no matter what the power source is.

BRANCH=Ryu
BUG=None
TEST=Set current limit to 1A on Ryu and charge from Zinger. Make sure
only 1A is pulled.

Change-Id: If9b2451f1351c6548b831d36c8162b2f86f42492
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242629
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
Vic Yang
2015-01-22 14:01:13 -08:00
committed by ChromeOS Commit Bot
parent 48eed0bebc
commit cf77f90f2c

View File

@@ -96,10 +96,10 @@ static void pd_extract_pdo_power(uint32_t pdo, uint32_t *ma, uint32_t *mv)
max_ma = 1000 * MIN(1000 * uw, PD_MAX_POWER_MW) / *mv;
} else {
max_ma = 10 * (pdo & 0x3FF);
max_ma = MIN(max_ma, PD_MAX_CURRENT_MA);
max_ma = MIN(max_ma, PD_MAX_POWER_MW * 1000 / *mv);
}
*ma = max_ma;
*ma = MIN(max_ma, PD_MAX_CURRENT_MA);
}
int pd_build_request(int cnt, uint32_t *src_caps, uint32_t *rdo,