summaryrefslogtreecommitdiff
path: root/board/plankton
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-11-04 13:00:22 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-10 20:43:00 +0000
commit8a9d0cae28c77be4ce1013802ea6f8713b3e5033 (patch)
tree5798d5bd56dda7b6a263910536b216fe955f766b /board/plankton
parente35494e4acaaf0d33d237fbfcedfc9ecbb87fd13 (diff)
downloadchrome-ec-8a9d0cae28c77be4ce1013802ea6f8713b3e5033.tar.gz
pd: for request message, add operational and max current
For request message, add the operational and max current for each board. If the requested power is less than the operational power required, then set mismatch bit. BUG=none BRANCH=samus TEST=make buildall. load onto samus, plug in zinger and see that request 20V, operational current 3000mA and max current of 3000mA. Change-Id: I4df45d88b7e060f66ff5b806f6fe30803f1afcf7 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227393 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/plankton')
-rw-r--r--board/plankton/usb_pd_policy.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c
index 1fb945ad7b..25e9099ac0 100644
--- a/board/plankton/usb_pd_policy.c
+++ b/board/plankton/usb_pd_policy.c
@@ -21,6 +21,11 @@
/* Acceptable margin between requested VBUS and measured value */
#define MARGIN_MV 400 /* mV */
+/* Define typical operating power and max power */
+#define OPERATING_POWER_MW 5000
+#define MAX_POWER_MW 60000
+#define MAX_CURRENT_MA 3000
+
/* Source PDOs */
const uint32_t pd_src_pdo[] = {
PDO_FIXED(5000, 3000, PDO_FIXED_EXTERNAL|PDO_FIXED_DUAL_ROLE),
@@ -63,6 +68,8 @@ int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo,
int i;
int ma;
int set_mv = select_mv;
+ int max;
+ uint32_t flags;
/* Default to 5V */
if (set_mv <= 0)
@@ -78,11 +85,19 @@ int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo,
if (i < 0)
return -EC_ERROR_UNKNOWN;
- /* request all the power ... */
+ /* build rdo for desired power */
ma = 10 * (src_caps[i] & 0x3FF);
- *rdo = RDO_FIXED(i + 1, ma, ma, 0);
- CPRINTF("Request [%d] %dV %dmA\n", i, set_mv/1000, ma);
- *curr_limit = ma;
+ max = MIN(ma, MAX_CURRENT_MA);
+ flags = (max * set_mv) < (1000 * OPERATING_POWER_MW) ?
+ RDO_CAP_MISMATCH : 0;
+ *rdo = RDO_FIXED(i + 1, max, max, 0);
+ CPRINTF("Request [%d] %dV %dmA", i, set_mv/1000, max);
+ /* Mismatch bit set if less power offered than the operating power */
+ if (flags & RDO_CAP_MISMATCH)
+ CPRINTF(" Mismatch");
+ CPRINTF("\n");
+
+ *curr_limit = max;
*supply_voltage = set_mv;
return EC_SUCCESS;
}