diff options
author | Diana Z <dzigterman@chromium.org> | 2022-07-27 14:52:14 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-03 17:32:25 +0000 |
commit | 6e157ac150249f8962abdeac957c9ca71dc9445d (patch) | |
tree | 0ad54248c7e9aae8fe70874d85bcff6d2ce5f0f0 | |
parent | 0b5019e0c65fe0f66ea77ec37531b83705cb58ec (diff) | |
download | chrome-ec-6e157ac150249f8962abdeac957c9ca71dc9445d.tar.gz |
Zephyr test: Store last 5V fixed source cap for reference
The 5V fixed source cap may have a number of testable fields we'd be
interested in, such as the power offered or static capabilities
advertised. Store it for the tests to reference, and allow them to
clear it when desired.
BRANCH=None
BUG=b:237256250
TEST=zmake testall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Ic396be8ca30ba5f1a86c1da1fe60a7a4c66dbea1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3789837
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | zephyr/emul/tcpc/emul_tcpci_partner_snk.c | 11 | ||||
-rw-r--r-- | zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c index 6ac498151d..650759c416 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c @@ -262,6 +262,12 @@ tcpci_snk_emul_handle_source_cap(struct tcpci_snk_emul_data *data, snk_pdos = tcpci_snk_emul_num_of_pdos(data); src_pdos = (msg->cnt - TCPCI_MSG_HEADER_LEN) / TCPCI_MSG_DO_LEN; + /* + * Store the 5V fixed PDO for future reference (required to be index 0 + * by spec) + */ + data->last_5v_source_cap = tcpci_snk_emul_get_pdo_from_cap(msg, 0); + /* Find if any source PDO satisfy any sink PDO */ for (int pdo_num = 0; pdo_num < src_pdos; pdo_num++) { pdo = tcpci_snk_emul_get_pdo_from_cap(msg, pdo_num); @@ -348,6 +354,11 @@ void tcpci_snk_emul_clear_alert_received(struct tcpci_snk_emul_data *data) data->alert_received = false; } +void tcpci_snk_emul_clear_last_5v_cap(struct tcpci_snk_emul_data *data) +{ + data->last_5v_source_cap = 0; +} + /** * @brief Handle SOP messages as TCPCI sink device. It handles source cap, * get sink cap and ping messages. Accept, Reject and PS_RDY are handled diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h index 3956637300..5d2084858b 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h @@ -41,6 +41,8 @@ struct tcpci_snk_emul_data { bool ping_received; /** PD_DATA_ALERT message received */ bool alert_received; + /** Last received 5V fixed source cap */ + uint32_t last_5v_source_cap; }; /** @@ -73,6 +75,13 @@ void tcpci_snk_emul_clear_ping_received(struct tcpci_snk_emul_data *sink_data); void tcpci_snk_emul_clear_alert_received(struct tcpci_snk_emul_data *sink_data); /** + * @brief Clear the last received 5V fixed source cap. + * + * @param sink_data + */ +void tcpci_snk_emul_clear_last_5v_cap(struct tcpci_snk_emul_data *sink_data); + +/** * @} */ |