summaryrefslogtreecommitdiff
path: root/board/dingdong
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/dingdong
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/dingdong')
-rw-r--r--board/dingdong/usb_pd_policy.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c
index 807d18c1c0..1cd9a7a5f0 100644
--- a/board/dingdong/usb_pd_policy.c
+++ b/board/dingdong/usb_pd_policy.c
@@ -25,6 +25,11 @@
const uint32_t pd_src_pdo[] = {};
const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
+/* Define typical operating power and max power */
+#define OPERATING_POWER_MW 1000
+#define MAX_POWER_MW 1500
+#define MAX_CURRENT_MA 300
+
/* Fake PDOs : we just want our pre-defined voltages */
const uint32_t pd_snk_pdo[] = {
PDO_FIXED(5000, 500, 0),
@@ -43,6 +48,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)
@@ -58,11 +65,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;
}