summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
{
}