diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2020-01-30 15:08:26 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-04 04:07:51 +0000 |
commit | 1c5d43dd90a55dc3e5a61447aaa8e0441b13b236 (patch) | |
tree | 2422948d19d949585f12cfc44167b752edc7f1af /common/usb_pd_alt_mode_dfp.c | |
parent | a14f04dd9525b4e59c549bc6cdc193da45423b0c (diff) | |
download | chrome-ec-1c5d43dd90a55dc3e5a61447aaa8e0441b13b236.tar.gz |
TCPMv1/v2: Move dfp_consume_identity() to common file
BUG=b:148528713
BRANCH=none
TEST=make buildall -j
Change-Id: I5b0bbd553cbe4fc76478b1c89b0f3f391f074a27
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032158
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_alt_mode_dfp.c')
-rw-r--r-- | common/usb_pd_alt_mode_dfp.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index a5371f8c78..a8551ccc2e 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -233,3 +233,32 @@ void dfp_consume_attention(int port, uint32_t *payload) if (modep->fx->attention) modep->fx->attention(port, payload); } + +void dfp_consume_identity(int port, int cnt, uint32_t *payload) +{ + int ptype = PD_IDH_PTYPE(payload[VDO_I(IDH)]); + struct pd_policy *pe = pd_get_am_policy(port); + size_t identity_size = MIN(sizeof(pe->identity), + (cnt - 1) * sizeof(uint32_t)); + pd_dfp_pe_init(port); + memcpy(pe->identity, payload + 1, identity_size); + + switch (ptype) { + case IDH_PTYPE_AMA: + /* Leave vbus ON if the following macro is false */ + if (IS_ENABLED(CONFIG_USB_PD_DUAL_ROLE) && + IS_ENABLED(CONFIG_USBC_VCONN_SWAP)) { + /* Adapter is requesting vconn, try to supply it */ + if (PD_VDO_AMA_VCONN_REQ(payload[VDO_I(AMA)])) + pd_try_vconn_src(port); + + /* Only disable vbus if vconn was requested */ + if (PD_VDO_AMA_VCONN_REQ(payload[VDO_I(AMA)]) && + !PD_VDO_AMA_VBUS_REQ(payload[VDO_I(AMA)])) + pd_power_supply_reset(port); + } + break; + default: + break; + } +} |