diff options
author | Denis Brockus <dbrockus@google.com> | 2020-10-21 14:47:46 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-22 06:43:08 +0000 |
commit | 3c75f4bd8c44b4ccf2971e18c5d8f1a5d596dffa (patch) | |
tree | 32c140a7f2587bb7c8ee0ec64e5769c4508ed2b9 | |
parent | 4fd0b5f12d0e4ab39c06b92f35ea5ddb194c1c8a (diff) | |
download | chrome-ec-3c75f4bd8c44b4ccf2971e18c5d8f1a5d596dffa.tar.gz |
TCPMv2: Create charge allow_list and add devices
The charge allow_list is for partner devices that
do not advertise Unconstrained Power in their
SRC_Caps but we should still charge from them
if they are the SRC.
The allow_list should be constrained to partners
that perform dual role and do not present
Unconstrained Power in their SRC_Caps. It is
preferred for the partner to send this
correctly but for products that are already out
in the wild, it may be a really bad user
experience for this to fail.
BUG=b:170644500,b:170848849,b:170970249
BRANCH=zork
TEST=connect E24d monitor and verify it charges DUT
Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: Ib4f2c62af3bb2c1ed066ea4353ec26cd536a4c26
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2490729
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
-rw-r--r-- | common/usb_pd_dual_role.c | 39 | ||||
-rw-r--r-- | include/usb_pd.h | 6 |
2 files changed, 39 insertions, 6 deletions
diff --git a/common/usb_pd_dual_role.c b/common/usb_pd_dual_role.c index 5fc19f91fe..fbcf5e23f1 100644 --- a/common/usb_pd_dual_role.c +++ b/common/usb_pd_dual_role.c @@ -19,6 +19,28 @@ */ static unsigned int max_request_mv = PD_MAX_VOLTAGE_MV; +/* + * Partner allow_list pair data to override ability for us to sink from them + * even if they do not present Unconstrained Power in their SRC_Caps. The + * partner pairs in this list should be able to perform as a dual role partner + * and should not present Unconstrained Power. It is best for the partner to + * fix the device so it is not required to be in this list but some devices + * are already out in the wild and will require this for the user's sake. + */ +struct allow_list_pair { + uint16_t vid; + uint16_t pid; +}; + +static struct allow_list_pair allow_list[] = { + {USB_VID_APPLE, USB_PID1_APPLE}, + {USB_VID_APPLE, USB_PID2_APPLE}, + {USB_VID_HP, USB_PID1_HP}, + {USB_VID_HP, USB_PID2_HP}, + {USB_VID_HP, USB_PID3_HP}, +}; +static int allow_list_count = ARRAY_SIZE(allow_list); + STATIC_IF_NOT(CONFIG_USB_PD_PREFER_MV) struct pd_pref_config_t __maybe_unused pd_pref_config; @@ -335,14 +357,19 @@ void pd_process_source_cap(int port, int cnt, uint32_t *src_caps) int pd_charge_from_device(uint16_t vid, uint16_t pid) { - /* TODO: rewrite into table if we get more of these */ + int i; + /* - * Allow the Apple charge-through accessory since it doesn't set - * unconstrained bit, but we still need to charge from it when - * we are a sink. + * Allow list check for partners that do not set unconstrained bit + * but we still need to charge from it when we are a sink. */ - return (vid == USB_VID_APPLE && - (pid == USB_PID1_APPLE || pid == USB_PID2_APPLE)); + for (i = 0; i < allow_list_count; ++i) { + if (vid == allow_list[i].vid && + pid == allow_list[i].pid) + return 1; + } + ccprints("Allow_List pair not found: vid=0x%X pid=0x%X", vid, pid); + return 0; } bool pd_is_battery_capable(void) diff --git a/include/usb_pd.h b/include/usb_pd.h index 06a04b2103..df5f785135 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -775,6 +775,12 @@ struct pd_cable { #define USB_VID_APPLE 0x05ac #define USB_PID1_APPLE 0x1012 #define USB_PID2_APPLE 0x1013 + +#define USB_VID_HP 0x03F0 +#define USB_PID1_HP 0x0467 /* E24d monitor */ +#define USB_PID2_HP 0x096B /* USB-C/A Univ Dock G2 */ +#define USB_PID3_HP 0x036B /* USB-C Dock G5 */ + #define USB_VID_INTEL 0x8087 /* Timeout for message receive in microseconds */ |