summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2020-12-15 18:07:42 +0100
committerCommit Bot <commit-bot@chromium.org>2021-01-22 09:44:54 +0000
commit6f8c85f7572d02c000cf3bfcc7a767689c275ccf (patch)
tree604cc060bbb791ac6f637120cc0b585d3861ff2e
parent0fcc700324d8f8517e752e88b05fda49b0689c2c (diff)
downloadchrome-ec-6f8c85f7572d02c000cf3bfcc7a767689c275ccf.tar.gz
charge_manager: Notify PD when new power is different than requested
On TCPMv2 stack voltage is limited by setting target voltage and sending DPM_REQUEST_NEW_POWER_LEVEL to Policy Engine. This causes state transition from PE_SNK_Ready to PE_SNK_Select_Capability and finally to PE_SNK_Transition_Sink. When leaving PE_SNK_Transition_Sink charge manager is notified about currently requested voltage. Charge manager detects voltage change and sends new power level request to PD stack which will trigger process of selecting capability once again. Actually we already requested appropriate voltage and current from charger so there is no need to trigger process of selecting capability. Above situation was fixed by checking if new voltage and current for updated port is different than last voltage and current requested by PD stack. BUG=b:161775827 BRANCH=none TEST=Flash EC ToT on casta. Set 5V limit. Observe if there is only one transition to PE_SNK_Select_Capability before receiving 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: Ic2ce76a8efaa1321a70a4dab2628855634430160 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2592498 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/charge_manager.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index e5256b4b26..a6307fe318 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -872,8 +872,29 @@ static void charge_manager_refresh(void)
#endif
/* New power requests must be set only after updating the globals. */
- if (is_pd_port(updated_new_port))
- pd_set_new_power_request(updated_new_port);
+ if (is_pd_port(updated_new_port)) {
+ /* Check if we can get requested voltage/current */
+ if ((IS_ENABLED(CONFIG_USB_PD_TCPMV1) &&
+ IS_ENABLED(CONFIG_USB_PD_DUAL_ROLE)) ||
+ (IS_ENABLED(CONFIG_USB_PD_TCPMV2) &&
+ IS_ENABLED(CONFIG_USB_PE_SM))) {
+ /*
+ * Check if new voltage/current is different
+ * than requested. If yes, send new power request
+ */
+ if (pd_get_requested_voltage(updated_new_port) !=
+ charge_voltage ||
+ pd_get_requested_current(updated_new_port) !=
+ charge_current_uncapped)
+ pd_set_new_power_request(updated_new_port);
+ } else {
+ /*
+ * Functions for getting requested voltage/current
+ * are not available. Send new power request.
+ */
+ pd_set_new_power_request(updated_new_port);
+ }
+ }
if (is_pd_port(updated_old_port))
pd_set_new_power_request(updated_old_port);