summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-10-09 13:42:42 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-21 00:26:39 +0000
commit49f4704e9a11d69e915bccb725ba509323925297 (patch)
tree32fc7394479f516904fe7ad81a6d5fea6133586e
parentf420b2073e02a2e745bb4c43f4144cf60045b7be (diff)
downloadchrome-ec-49f4704e9a11d69e915bccb725ba509323925297.tar.gz
TCPMv2: Report partner PD revisions in TYPEC_STATUS
Gather and report both SOP and SOP' revisions for port partners. BRANCH=None BUG=b:167700356 TEST=on waddledoo, confirmed SOP and SOP' revisions were reported correctly with: - active cable and non-PD partner - PD 3.0 dock and active cable - PD 2.0 dock and active cable - PD 3.0 and PD 2.0 partners with no e-mark cable Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6448e5b80212b171a44864f90ae5cdfecbcb7244 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473097 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--common/usbc/usb_pd_host.c9
-rw-r--r--include/ec_commands.h54
-rw-r--r--util/ectool.c10
3 files changed, 57 insertions, 16 deletions
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c
index 61c1c69966..bb5d003ebb 100644
--- a/common/usbc/usb_pd_host.c
+++ b/common/usbc/usb_pd_host.c
@@ -152,7 +152,14 @@ static enum ec_status hc_typec_status(struct host_cmd_handler_args *args)
r->events = pd_get_events(p->port);
- /* TODO(b/167700356): Add revisions and source cap PDOs */
+ r->sop_revision = r->sop_connected ?
+ PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, TCPC_TX_SOP)) : 0;
+ r->sop_prime_revision = pd_get_identity_discovery(p->port,
+ TCPC_TX_SOP_PRIME) == PD_DISC_COMPLETE ?
+ PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, TCPC_TX_SOP_PRIME))
+ : 0;
+
+ /* TODO(b/167700356): Add sink and source cap PDOs */
return EC_RES_SUCCESS;
}
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 3b95dcf28a..06b3ad0414 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -6472,31 +6472,55 @@ enum tcpc_cc_polarity {
#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)
#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)
+/*
+ * Encode and decode for BCD revision response
+ *
+ * Note: the major revision set is written assuming that the value given is the
+ * Specification Revision from the PD header, which currently only maps to PD
+ * 1.0-3.0 with the major revision being one greater than the binary value.
+ */
+#define PD_STATUS_REV_SET_MAJOR(r) ((r + 1) << 12)
+#define PD_STATUS_REV_GET_MAJOR(r) ((r >> 12) & 0xF)
+#define PD_STATUS_REV_GET_MINOR(r) ((r >> 8) & 0xF)
+
struct ec_params_typec_status {
uint8_t port;
} __ec_align1;
struct ec_response_typec_status {
- uint8_t pd_enabled; /* PD communication enabled - bool */
- uint8_t dev_connected; /* Device connected - bool */
- uint8_t sop_connected; /* Device is SOP PD capable - bool */
- uint8_t reserved1; /* Reserved for future use */
+ uint8_t pd_enabled; /* PD communication enabled - bool */
+ uint8_t dev_connected; /* Device connected - bool */
+ uint8_t sop_connected; /* Device is SOP PD capable - bool */
+ uint8_t reserved1; /* Reserved for future use */
+
+ uint8_t power_role; /* enum pd_power_role */
+ uint8_t data_role; /* enum pd_data_role */
+ uint8_t vconn_role; /* enum pd_vconn_role */
+ uint8_t reserved2; /* Reserved for future use */
- uint8_t power_role; /* enum pd_power_role */
- uint8_t data_role; /* enum pd_data_role */
- uint8_t vconn_role; /* enum pd_vconn_role */
- uint8_t reserved2; /* Reserved for future use */
+ uint8_t polarity; /* enum tcpc_cc_polarity */
+ uint8_t cc_state; /* enum pd_cc_states */
+ uint8_t dp_pin; /* DP pin mode (MODE_DP_IN_[A-E]) */
+ uint8_t mux_state; /* USB_PD_MUX* - encoded mux state */
- uint8_t polarity; /* enum tcpc_cc_polarity */
- uint8_t cc_state; /* enum pd_cc_states */
- uint8_t dp_pin; /* DP pin mode (MODE_DP_IN_[A-E]) */
- uint8_t mux_state; /* USB_PD_MUX* - encoded USB mux state */
+ char tc_state[32]; /* TC state name */
- char tc_state[32]; /* TC state name */
+ uint32_t events; /* PD_STATUS_EVENT bitmask */
- uint32_t events; /* PD_STATUS_EVENT bitmask */
+ /*
+ * BCD PD revisions for partners
+ *
+ * The format has the PD major reversion in the upper nibble, and PD
+ * minor version in the next nibble. Following two nibbles are
+ * currently 0.
+ * ex. PD 3.2 would map to 0x3200
+ *
+ * PD major/minor will be 0 if no PD device is connected.
+ */
+ uint16_t sop_revision;
+ uint16_t sop_prime_revision;
- /* TODO(b/167700356): Add revisions and source cap PDOs */
+ /* TODO(b/167700356): Add sink and source cap PDOs */
} __ec_align1;
/*****************************************************************************/
diff --git a/util/ectool.c b/util/ectool.c
index 09c27db530..bb4ea2cef5 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -9692,6 +9692,16 @@ int cmd_typec_status(int argc, char *argv[])
printf("Port events: 0x%08x\n", r->events);
+ if (r->sop_revision)
+ printf("SOP PD Rev: %d.%d\n",
+ PD_STATUS_REV_GET_MAJOR(r->sop_revision),
+ PD_STATUS_REV_GET_MINOR(r->sop_revision));
+
+ if (r->sop_prime_revision)
+ printf("SOP' PD Rev: %d.%d\n",
+ PD_STATUS_REV_GET_MAJOR(r->sop_prime_revision),
+ PD_STATUS_REV_GET_MINOR(r->sop_prime_revision));
+
return 0;
}