summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-05-04 15:57:42 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-05 16:54:35 +0000
commit4293de83e09a0a9ee24e422e09f7012c7a6a751e (patch)
tree333a8f395215c453a0720d58181c1dd02db0fbf8
parent418ce5f80a26a0da4af396b802b1a2a5ce5b4291 (diff)
downloadchrome-ec-stabilize-7039.B.tar.gz
pd: fix PDO selection for low voltage boardsstabilize-7039.B
When the policy of the board is to select lowest voltage providing enough power, the current algorithm ignores the fact that the board input current limit might be lower than the charger maximum current for a particular voltage level leading to the possibility of selected a voltage with a lower available power. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=set a Ryu board with the following configuration : PD_PREFER_LOW_VOLTAGE PD_MAX_POWER_MW 24000 PD_MAX_CURRENT_MA 1000 PD_MAX_VOLTAGE_MV 20000 connect it a Zinger (offering 3A @ 20V, 3A @ 12V and 3A @ 5V), see it selecting 20V rather 12V before the patch. Change-Id: I8c0589bb5e5705c4d8a6035120d1cdfaacaa14df Reviewed-on: https://chromium-review.googlesource.com/269262 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_policy.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 96cf970a30..21d4f1b0e1 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -72,6 +72,7 @@ static int pd_find_pdo_index(int cnt, uint32_t *src_caps, int max_mv)
uw = 250000 * (src_caps[i] & 0x3FF);
} else {
ma = (src_caps[i] & 0x3FF) * 10;
+ ma = MIN(ma, PD_MAX_CURRENT_MA);
uw = ma * mv;
}
#ifdef PD_PREFER_LOW_VOLTAGE