summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-12-17 10:04:09 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-24 01:10:59 +0000
commitc9cc5600573a6a28bd0a66d43916e969bd403bbd (patch)
tree3c3aceedd8bcfdb32e718d919f045586646b38cd
parent1edf350debe3c19215d8afb7d168d26950fe9cdb (diff)
downloadchrome-ec-c9cc5600573a6a28bd0a66d43916e969bd403bbd.tar.gz
TCPMv2: Update current limits in appropriate task
Since setting the current limit on a port often involves communicating with a port's PPC or charger, run this from the appropriate port task rather than allowing another port to run it. This interface can also be used later to increase or decrease the source Rp for non-PD partners. BRANCH=None BUG=b:168862110,b:141690755 TEST=on drawcia, plug in two hubs requiring 3.0 A and confirm that the first receives 3.0 A, and on its unplug the second is offered 3.0 A Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie8423f612d199f4389955e00a82e9ca588f2d836 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597430 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--common/usbc/usb_pd_dpm.c4
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index 9748742b75..d607485ae4 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -400,12 +400,8 @@ static void balance_source_ports(void)
if (count_port_bits(max_current_claimed) <
CONFIG_USB_PD_3A_PORTS) {
max_current_claimed |= BIT(new_max_port);
- typec_set_source_current_limit(new_max_port,
- TYPEC_RP_3A0);
typec_select_src_current_limit_rp(new_max_port,
TYPEC_RP_3A0);
- pd_update_contract(new_max_port);
-
} else {
/* TODO(b/141690755): Check lower priority claims */
goto unlock;
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 9460814b31..655d291dbb 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -114,6 +114,8 @@ void print_flag(int set_or_clear, int flag);
#define TC_FLAGS_CHECK_CONNECTION BIT(16)
/* Flag to note pd_set_suspend SUSPEND state */
#define TC_FLAGS_SUSPEND BIT(17)
+/* Flag to indicate the port current limit has changed */
+#define TC_FLAGS_UPDATE_CURRENT BIT(18)
/*
* Clear all flags except TC_FLAGS_LPM_ENGAGED and TC_FLAGS_SUSPEND.
@@ -297,6 +299,7 @@ static struct bit_name flag_bit_names[] = {
{ TC_FLAGS_DISC_IDENT_IN_PROGRESS, "DISC_IDENT_IN_PROGRESS" },
{ TC_FLAGS_CHECK_CONNECTION, "CHECK_CONNECTION" },
{ TC_FLAGS_SUSPEND, "SUSPEND" },
+ { TC_FLAGS_UPDATE_CURRENT, "UPDATE_CURRENT" },
};
static struct bit_name event_bit_names[] = {
@@ -1182,6 +1185,8 @@ static void typec_select_pull(int port, enum tcpc_cc_pull pull)
void typec_select_src_current_limit_rp(int port, enum tcpc_rp_value rp)
{
tc[port].select_current_limit_rp = rp;
+ if (IS_ATTACHED_SRC(port))
+ TC_SET_FLAG(port, TC_FLAGS_UPDATE_CURRENT);
}
void typec_select_src_collision_rp(int port, enum tcpc_rp_value rp)
{
@@ -2976,6 +2981,14 @@ static void tc_attached_src_run(const int port)
}
}
#endif
+
+ if (TC_CHK_FLAG(port, TC_FLAGS_UPDATE_CURRENT)) {
+ /* TODO(b/141690755): Also set new CC if needed for non-PD */
+ TC_CLR_FLAG(port, TC_FLAGS_UPDATE_CURRENT);
+ typec_set_source_current_limit(port,
+ tc[port].select_current_limit_rp);
+ pd_update_contract(port);
+ }
}
static void tc_attached_src_exit(const int port)