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 | |
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')
-rw-r--r-- | board/plankton/board.c | 6 | ||||
-rw-r--r-- | board/plankton/board.h | 9 | ||||
-rw-r--r-- | board/plankton/usb_pd_policy.c | 22 |
3 files changed, 33 insertions, 4 deletions
diff --git a/board/plankton/board.c b/board/plankton/board.c index 79ea23147c..e6649bc57d 100644 --- a/board/plankton/board.c +++ b/board/plankton/board.c @@ -37,8 +37,12 @@ enum usbc_action { static void set_usbc_action(enum usbc_action act) { switch (act) { - case USBC_ACT_5V_TO_DUT: /* TODO: Force 5V */ + case USBC_ACT_5V_TO_DUT: + board_set_source_cap(SRC_CAP_5V); + pd_set_dual_role(PD_DRP_FORCE_SOURCE); + break; case USBC_ACT_12V_TO_DUT: + board_set_source_cap(SRC_CAP_12V); pd_set_dual_role(PD_DRP_FORCE_SOURCE); break; case USBC_ACT_DEVICE: diff --git a/board/plankton/board.h b/board/plankton/board.h index 3011038440..045fa8b6c8 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -20,6 +20,7 @@ #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP +#define CONFIG_USB_PD_DYNAMIC_SRC_CAP #define CONFIG_ADC #define CONFIG_HW_CRC #define CONFIG_I2C @@ -51,6 +52,14 @@ enum adc_channel { ADC_CH_COUNT }; +enum board_src_cap { + SRC_CAP_5V = 0, + SRC_CAP_12V, +}; + +/* Set USB PD source capability */ +void board_set_source_cap(enum board_src_cap cap); + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ 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 ... */ |