diff options
author | Vic Yang <victoryang@chromium.org> | 2014-07-22 20:26:20 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-29 00:01:52 +0000 |
commit | e852161dc423c4a4063e3ae360d31e5126e3a53e (patch) | |
tree | 2be949bc45ab13f0b001abcebd1ad6f38a164af9 /board/plankton/usb_pd_policy.c | |
parent | 3a033a2bbf0ba6a28c4c7b56ea02b5f3b624e3f4 (diff) | |
download | chrome-ec-e852161dc423c4a4063e3ae360d31e5126e3a53e.tar.gz |
plankton: Support 5V only mode
When Plankton is in 5V only mode, we should only advertise 5V
capability.
BUG=None
TEST=Connect to Samus. Check the PDO received on Samus.
BRANCH=None
Change-Id: Ia2b65c1b202aba291a008511801ede4d5c93aac5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209481
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board/plankton/usb_pd_policy.c')
-rw-r--r-- | board/plankton/usb_pd_policy.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index 3cda22108c..5f238a7f99 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -20,12 +20,17 @@ /* Acceptable margin between requested VBUS and measured value */ #define MARGIN_MV 400 /* mV */ -/* we are not acting as a source */ +/* Source PDOs */ const uint32_t pd_src_pdo[] = { PDO_FIXED(5000, 500, PDO_FIXED_EXTERNAL), PDO_FIXED(12000, 3000, PDO_FIXED_EXTERNAL), }; -const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); +static const int pd_src_pdo_cnts[2] = { + [SRC_CAP_5V] = 1, + [SRC_CAP_12V] = 2, +}; + +static int pd_src_pdo_idx; /* Fake PDOs : we just want our pre-defined voltages */ const uint32_t pd_snk_pdo[] = { @@ -38,6 +43,17 @@ const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); /* Desired voltage requested as a sink (in millivolts) */ static unsigned select_mv = 5000; +void board_set_source_cap(enum board_src_cap cap) +{ + pd_src_pdo_idx = cap; +} + +int pd_get_source_pdo(const uint32_t **src_pdo) +{ + *src_pdo = pd_src_pdo; + return pd_src_pdo_cnts[pd_src_pdo_idx]; +} + int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo) { int i; @@ -79,7 +95,7 @@ int pd_request_voltage(uint32_t rdo) uint32_t pdo; uint32_t pdo_ma; - if (!idx || idx > pd_src_pdo_cnt) + if (!idx || idx > pd_src_pdo_cnts[pd_src_pdo_idx]) return EC_ERROR_INVAL; /* Invalid index */ /* check current ... */ |