summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-10-14 14:44:46 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-21 00:26:43 +0000
commit3cac50952113db8ec86a187c61a02132e423ee52 (patch)
tree527d302ae38f929531901a4fad14f7f65eda04f8
parentd7c1691c7592c8374ee0bb695f6d1e61d49d310f (diff)
downloadchrome-ec-3cac50952113db8ec86a187c61a02132e423ee52.tar.gz
TCPMv2: Add fields for sink capabilities to TYPEC_STATUS
Round out the final fields of the new TYPEC_STATUS v0 command return with sink capabilities fields. Note that they are not yet being populated, but are being added now to avoid unnecessary return versioning in the coming months when the command is being used. BRANCH=None BUG=b:167700356 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I38a6e96a9ec4974e11b85839abcd4deafcf96b6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473099 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/usb_pd_host.c3
-rw-r--r--include/ec_commands.h7
-rw-r--r--util/ectool.c32
3 files changed, 35 insertions, 7 deletions
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c
index c009c16568..61dfa8bf49 100644
--- a/common/usbc/usb_pd_host.c
+++ b/common/usbc/usb_pd_host.c
@@ -163,7 +163,8 @@ static enum ec_status hc_typec_status(struct host_cmd_handler_args *args)
memcpy(r->source_cap_pdos, pd_get_src_caps(p->port),
r->source_cap_count * sizeof(uint32_t));
- /* TODO(b/167700356): Add sink cap PDOs */
+ /* TODO(b/160009733): Populate sink cap PDOs */
+ r->sink_cap_count = 0;
return EC_RES_SUCCESS;
}
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 1ec0e63dee..651c6dd740 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -6396,9 +6396,6 @@ struct ec_params_typec_control {
* EC_CMD_USB_PD_CONTROL command.
*
* This also combines in the EC_CMD_USB_PD_MUX_INFO flags.
- *
- * Version 0 of command is under development
- * TODO(b/167700356): Remove this statement when version 0 is finalized
*/
#define EC_CMD_TYPEC_STATUS 0x0133
@@ -6573,7 +6570,7 @@ struct ec_response_typec_status {
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 sink_cap_count; /* Number of Sink Cap PDOs */
uint8_t polarity; /* enum tcpc_cc_polarity */
uint8_t cc_state; /* enum pd_cc_states */
@@ -6599,7 +6596,7 @@ struct ec_response_typec_status {
uint32_t source_cap_pdos[7]; /* Max 7 PDOs can be present */
- /* TODO(b/167700356): Add sink cap PDOs */
+ uint32_t sink_cap_pdos[7]; /* Max 7 PDOs can be present */
} __ec_align1;
/*****************************************************************************/
diff --git a/util/ectool.c b/util/ectool.c
index 7d573b44d5..ebc201e3f1 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -9600,7 +9600,6 @@ static inline void print_pdo_battery(uint32_t pdo)
PDO_BATT_MAX_VOLTAGE(pdo),
PDO_BATT_MIN_VOLTAGE(pdo),
PDO_BATT_MAX_POWER(pdo));
-
}
static inline void print_pdo_variable(uint32_t pdo)
@@ -9740,6 +9739,11 @@ int cmd_typec_status(int argc, char *argv[])
PD_STATUS_REV_GET_MINOR(r->sop_prime_revision));
for (i = 0; i < r->source_cap_count; i++) {
+ /*
+ * Bits 31:30 always indicate the type of PDO
+ *
+ * Table 6-7 PD Rev 3.0 Ver 2.0
+ */
uint32_t pdo = r->source_cap_pdos[i];
int pdo_type = pdo & PDO_TYPE_MASK;
@@ -9758,6 +9762,32 @@ int cmd_typec_status(int argc, char *argv[])
}
}
+ for (i = 0; i < r->sink_cap_count; i++) {
+ /*
+ * Bits 31:30 always indicate the type of PDO
+ *
+ * Table 6-7 PD Rev 3.0 Ver 2.0
+ */
+ uint32_t pdo = r->sink_cap_pdos[i];
+ int pdo_type = pdo & PDO_TYPE_MASK;
+
+ if (i == 0)
+ printf("Sink Capabilities:\n");
+
+ if (pdo_type == PDO_TYPE_FIXED) {
+ print_pdo_fixed(pdo);
+ /* Note: FRS bits are reserved in PD 2.0 spec */
+ printf("%s\n", pdo & PDO_FIXED_FRS_CURR_MASK ?
+ "FRS" : "");
+ } else if (pdo_type == PDO_TYPE_BATTERY) {
+ print_pdo_battery(pdo);
+ } else if (pdo_type == PDO_TYPE_VARIABLE) {
+ print_pdo_variable(pdo);
+ } else {
+ print_pdo_augmented(pdo);
+ }
+ }
+
return 0;
}