summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Chao <scott_chao@wistron.corp-partner.google.com>2022-04-19 12:52:29 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-05 16:11:36 +0000
commitd767b1e4ac93b8e84110df19edc79a44bb789f76 (patch)
tree89cf75a6eb84512e41afd0e567e8e7177836a7a9
parent2a39f3df356956b88d1a67eced2d545a54b57062 (diff)
downloadchrome-ec-d767b1e4ac93b8e84110df19edc79a44bb789f76.tar.gz
common/usbc: add new DPM for sink capability and request mismatch
In TBT EV - Host Source Power Provisioning test item. The port partner will return sink capability that it can support 3A, but it will request 1.5A at the end. In this case, EC will provide 3A for it and provide 1.5A for the second port partner. This case will cause test failed due to EC only provide 1.5A for both port. BUG=b:229683022 BRANCH=none TEST=make -j BOARD=primus TEST=make buildall TEST=verified by GRL Change-Id: Icc4904ec1267b7a34e64c01b626f607999072410 Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3592313 Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/mock/usb_pd_dpm_mock.c4
-rw-r--r--common/usbc/usb_pd_dpm.c26
-rw-r--r--common/usbc/usb_pe_drp_sm.c1
-rw-r--r--include/usb_pd_dpm.h8
-rw-r--r--test/fake_usbc.c4
5 files changed, 43 insertions, 0 deletions
diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c
index 47b1290785..005e0090a6 100644
--- a/common/mock/usb_pd_dpm_mock.c
+++ b/common/mock/usb_pd_dpm_mock.c
@@ -61,6 +61,10 @@ void dpm_add_non_pd_sink(int port)
{
}
+void dpm_evaluate_request_rdo(int port, uint32_t rdo)
+{
+}
+
void dpm_remove_sink(int port)
{
}
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index 53c7127080..6d95f41ada 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -720,6 +720,32 @@ void dpm_add_non_pd_sink(int port)
balance_source_ports();
}
+void dpm_evaluate_request_rdo(int port, uint32_t rdo)
+{
+ int idx;
+ int op_ma;
+
+ if (CONFIG_USB_PD_3A_PORTS == 0)
+ return;
+
+ idx = RDO_POS(rdo);
+ /* Check for invalid index */
+ if (!idx)
+ return;
+
+ op_ma = (rdo >> 10) & 0x3FF;
+ if ((BIT(port) && sink_max_pdo_requested) && (op_ma <= 150)) {
+ /*
+ * sink_max_pdo_requested will be set when we get 5V/3A sink
+ * capability from port partner. If port partner only request
+ * 5V/1.5A, we need to provide 5V/1.5A.
+ */
+ atomic_clear_bits(&sink_max_pdo_requested, BIT(port));
+
+ balance_source_ports();
+ }
+}
+
void dpm_remove_sink(int port)
{
if (CONFIG_USB_PD_3A_PORTS == 0)
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 352e2b4fe3..8625359712 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -2495,6 +2495,7 @@ static void pe_src_negotiate_capability_entry(int port)
* Evaluate the Request from the Attached Sink
*/
+ dpm_evaluate_request_rdo(port, payload);
/*
* Transition to the PE_SRC_Capability_Response state when:
* 1) The Request cannot be met.
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h
index 663c711daa..391e7ed246 100644
--- a/include/usb_pd_dpm.h
+++ b/include/usb_pd_dpm.h
@@ -91,6 +91,14 @@ void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo);
void dpm_add_non_pd_sink(int port);
/*
+ * Evaluates the request from port partner
+ *
+ * @param port USB-C port number
+ * @param rdo Request from port partner
+ */
+void dpm_evaluate_request_rdo(int port, uint32_t rdo);
+
+/*
* Remove this port as a sink, and reallocate maximum current as needed.
*
* @param port USB-C port number
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index 6e61a1ca81..2cabb2dee0 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -300,6 +300,10 @@ void dpm_add_non_pd_sink(int port)
{
}
+void dpm_evaluate_request_rdo(int port, uint32_t rdo)
+{
+}
+
void dpm_remove_sink(int port)
{
}