usb_pd_dual_role: Respect max voltage limit when processing capabilities

To process source capabilities received from charger we just find the
most appropriate PDO and inform charge manager about our choice
(pd_process_source_cap() function). This function doesn't respect any
voltage limits, so even when such a limit exists charge manager will be
informed about higher voltage. Of course PD stack will request correct
voltage from charger and charge manager will be notified about that
fact, but providing wrong information about voltage can cause
unnecessary new power requests.

This issue was found during debugging EC hibernate issue on casta.

BUG=b:161775827
BRANCH=none
TEST=Flash EC ToT on casta. Set voltage limit to 5V. Observe if
     charge manager reports voltage changes from 5V to 15V (in my case)
     when received capabilities from ServoV4.
     NOTE: ServoV4 will send capabilities to DUT as a result of voltage
     transition (requested by ServoV4).

Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I5fe30f7a1b86fb1d934a29429147d9d7c9a84337
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2592496
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
Patryk Duda 2020-12-15 16:55:55 +01:00 committed by Commit Bot
parent 5316af00b3
commit 0bfbb5c932
1 changed files with 1 additions and 1 deletions

View File

@ -350,7 +350,7 @@ void pd_process_source_cap(int port, int cnt, uint32_t *src_caps)
/* Get max power info that we could request */
pd_find_pdo_index(pd_get_src_cap_cnt(port),
pd_get_src_caps(port),
PD_MAX_VOLTAGE_MV, &pdo);
pd_get_max_voltage(), &pdo);
pd_extract_pdo_power(pdo, &ma, &mv);
/* Set max. limit, but apply 500mA ceiling */