diff options
author | Caveh Jalali <caveh@chromium.org> | 2022-03-03 19:03:10 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-11 00:27:37 +0000 |
commit | ade000f151b2b262e57b887703c1e466236c4075 (patch) | |
tree | 929f6d6ee8db4e0ac3f2c8c27f12135878363ca1 /common/usb_pd_dual_role.c | |
parent | e8d90613cadd6e3c51ef77cee463b7acbaceb905 (diff) | |
download | chrome-ec-ade000f151b2b262e57b887703c1e466236c4075.tar.gz |
usbpd: Advertise USB COMM_CAP in RDO
This sets the USB Communication Capable bit in packets we generate based
on our ability to do USB data instead of discovered partner
capabilities.
BRANCH=none
BUG=b:213021159
TEST=buildall passes
Change-Id: Ib1704c5142835039b031399652f8a71e4753e825
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3503145
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usb_pd_dual_role.c')
-rw-r--r-- | common/usb_pd_dual_role.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/common/usb_pd_dual_role.c b/common/usb_pd_dual_role.c index 52042c5439..a748f8377b 100644 --- a/common/usb_pd_dual_role.c +++ b/common/usb_pd_dual_role.c @@ -39,6 +39,28 @@ unsigned int pd_get_max_voltage(void) return max_request_mv; } +/** + * Return true if port is capable of communication over USB data lines. + * + * @param port USB-C port number + */ +static bool pd_get_usb_comm_capable(int port) +{ + uint32_t fixed_pdo; + + /* the fixed PDO is always the first entry */ + if (pd_get_power_role(port) == PD_ROLE_SINK) { + fixed_pdo = pd_snk_pdo[0]; + } else { + const uint32_t *pdo; + + pd_get_source_pdo(&pdo, port); + fixed_pdo = pdo[0]; + } + + return !!(fixed_pdo & PDO_FIXED_COMM_CAP); +} + /* * Zinger implements a board specific usb policy that does not define * PD_MAX_VOLTAGE_MV and PD_OPERATING_POWER_MW. And in turn, does not @@ -334,12 +356,12 @@ void pd_build_request(int32_t vpd_vdo, uint32_t *rdo, uint32_t *ma, * 6.4.2.4 USB Communications Capable * 6.4.2.5 No USB Suspend * - * If the port partner is capable of USB communication set the - * USB Communications Capable flag. + * If the port is capable of USB communication, set the USB + * Communications Capable flag. * If the port partner is sink device do not suspend USB as the * power can be used for charging. */ - if (pd_get_partner_usb_comm_capable(port)) { + if (pd_get_usb_comm_capable(port)) { *rdo |= RDO_COMM_CAP; if (pd_get_power_role(port) == PD_ROLE_SINK) *rdo |= RDO_NO_SUSPEND; |