diff options
author | Diana Z <dzigterman@chromium.org> | 2020-10-14 13:59:06 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-21 00:26:39 +0000 |
commit | d7c1691c7592c8374ee0bb695f6d1e61d49d310f (patch) | |
tree | ab2e79a829580243ed0bc4c6ea8a481455af71a0 /util | |
parent | 49f4704e9a11d69e915bccb725ba509323925297 (diff) | |
download | chrome-ec-d7c1691c7592c8374ee0bb695f6d1e61d49d310f.tar.gz |
TCPMv2: Report source capabilities in TYPEC_STATUS
Report the source capabilities for a port to the TYPEC_STATUS host
command, and add decoding for the interesting fields here to ectool.
BRANCH=None
BUG=b:167700356
TEST=on waddledoo, confirm source capability decoding from ectool
matches that from TotalPhase for servo_v4 and a charger
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Ib79c36c613c47fc60cfd8736202216ee40fbb42f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473098
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/util/ectool.c b/util/ectool.c index bb4ea2cef5..7d573b44d5 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -9582,13 +9582,50 @@ int cmd_typec_discovery(int argc, char *argv[]) return 0; } +/* Print shared fields of sink and source cap PDOs */ +static inline void print_pdo_fixed(uint32_t pdo) +{ + printf(" Fixed: %dmV %dmA %s%s%s%s", + PDO_FIXED_VOLTAGE(pdo), + PDO_FIXED_CURRENT(pdo), + pdo & PDO_FIXED_DUAL_ROLE ? "DRP " : "", + pdo & PDO_FIXED_UNCONSTRAINED ? "UP " : "", + pdo & PDO_FIXED_COMM_CAP ? "USB " : "", + pdo & PDO_FIXED_DATA_SWAP ? "DRD" : ""); +} + +static inline void print_pdo_battery(uint32_t pdo) +{ + printf(" Battery: max %dmV min %dmV max %dmW\n", + PDO_BATT_MAX_VOLTAGE(pdo), + PDO_BATT_MIN_VOLTAGE(pdo), + PDO_BATT_MAX_POWER(pdo)); + +} + +static inline void print_pdo_variable(uint32_t pdo) +{ + printf(" Variable: max %dmV min %dmV max %dmA\n", + PDO_VAR_MAX_VOLTAGE(pdo), + PDO_VAR_MIN_VOLTAGE(pdo), + PDO_VAR_MAX_CURRENT(pdo)); +} + +static inline void print_pdo_augmented(uint32_t pdo) +{ + printf(" Augmented: max %dmV min %dmV max %dmA\n", + PDO_AUG_MAX_VOLTAGE(pdo), + PDO_AUG_MIN_VOLTAGE(pdo), + PDO_AUG_MAX_CURRENT(pdo)); +} + int cmd_typec_status(int argc, char *argv[]) { struct ec_params_typec_status p; struct ec_response_typec_status *r = (struct ec_response_typec_status *)ec_inbuf; char *endptr; - int rv; + int rv, i; char *desc; if (argc != 2) { @@ -9702,6 +9739,25 @@ int cmd_typec_status(int argc, char *argv[]) PD_STATUS_REV_GET_MAJOR(r->sop_prime_revision), PD_STATUS_REV_GET_MINOR(r->sop_prime_revision)); + for (i = 0; i < r->source_cap_count; i++) { + uint32_t pdo = r->source_cap_pdos[i]; + int pdo_type = pdo & PDO_TYPE_MASK; + + if (i == 0) + printf("Source Capabilities:\n"); + + if (pdo_type == PDO_TYPE_FIXED) { + print_pdo_fixed(pdo); + printf("\n"); + } 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; } |