summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNehemiah Dureus <ndureus@google.com>2021-10-27 16:04:02 +0000
committerCommit Bot <commit-bot@chromium.org>2021-10-29 18:49:32 +0000
commitdc9db9545c29b267f76ca8b3c0518e1458cbab30 (patch)
treede959589f8e06cb42969b0984751b45534227e96
parentd3d7afedfa17c503b0ccea9512d76a98517a7f88 (diff)
downloadchrome-ec-dc9db9545c29b267f76ca8b3c0518e1458cbab30.tar.gz
common: Make EC power delivery cmd more verbose
Added more detailed output for `pd <port> srccaps` for debugging convenience. For boards that have large enough memory, the output of srccaps will be formatted showing pdo flags, pdo type, etc.: Src 0: (Fixed) 5000mV/3000mA DRP UP USB DRD Src 1: (Aug3.0) 5000mV-2000mV/3000mA DRP UP USB DRD ... For boards that don't have enough memory to support this, defining CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE will default to displaying the old way of printing out srccaps, shown below: 0: 5000mV/3000mA 1: 5000mV-2000mV/3000mA ... BRANCH=None BUG=b:194402616 TEST=On Delbin, connected with ServoV4, execute `pd <port> srccaps`, Built all boards (make -j buildall) Signed-off-by: Nehemiah Dureus <ndureus@google.com> Cq-Depend: chromium:3248341, chromium:3248342, chromium:3248343, chromium:3248344, chromium:3252409, chromium:3252413 Change-Id: I146f619c5baaf28b56a603c3b0a96fc9efbfb26a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3248345 Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r--common/usb_common.c51
-rw-r--r--docs/reducing_ec_image_size.md1
-rw-r--r--include/config.h1
3 files changed, 53 insertions, 0 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index 786bd118cf..6c51da3358 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -994,6 +994,7 @@ void pd_srccaps_dump(int port)
for (i = 0; i < pd_get_src_cap_cnt(port); ++i) {
uint32_t max_ma, max_mv, min_mv;
+#ifdef CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE
pd_extract_pdo_power(srccaps[i], &max_ma, &max_mv, &min_mv);
if ((srccaps[i] & PDO_TYPE_MASK) == PDO_TYPE_AUGMENTED) {
@@ -1003,6 +1004,56 @@ void pd_srccaps_dump(int port)
} else {
ccprintf("%d: %dmV/%dmA\n", i, max_mv, max_ma);
}
+#else
+ const uint32_t pdo = srccaps[i];
+ const uint32_t pdo_mask = pdo & PDO_TYPE_MASK;
+ const char *pdo_type;
+ bool range_flag = true;
+
+ pd_extract_pdo_power(pdo, &max_ma, &max_mv, &min_mv);
+
+ switch (pdo_mask) {
+ case PDO_TYPE_FIXED:
+ pdo_type = "Fixed";
+ range_flag = false;
+ break;
+ case PDO_TYPE_BATTERY:
+ pdo_type = "Battery";
+ break;
+ case PDO_TYPE_VARIABLE:
+ pdo_type = "Variable";
+ break;
+ case PDO_TYPE_AUGMENTED:
+ pdo_type = "Augmnt";
+ if (!IS_ENABLED(CONFIG_USB_PD_REV30)) {
+ pdo_type = "Aug3.0";
+ range_flag = false;
+ }
+ break;
+ default:
+ pdo_type = "?";
+ break;
+ }
+
+ ccprintf("Src %d: (%s) %dmV", i, pdo_type, max_mv);
+ if (range_flag)
+ ccprintf("-%dmV", min_mv);
+ ccprintf("/%dm%c", max_ma,
+ pdo_mask == PDO_TYPE_BATTERY ? 'W' : 'A');
+
+ if (pdo & PDO_FIXED_DUAL_ROLE)
+ ccprintf(" DRP");
+ if (pdo & PDO_FIXED_UNCONSTRAINED)
+ ccprintf(" UP");
+ if (pdo & PDO_FIXED_COMM_CAP)
+ ccprintf(" USB");
+ if (pdo & PDO_FIXED_DATA_SWAP)
+ ccprintf(" DRD");
+ /* Note from ectool.c: FRS bits are reserved in PD 2.0 spec */
+ if (pdo & PDO_FIXED_FRS_CURR_MASK)
+ ccprintf(" FRS");
+ ccprintf("\n");
+#endif
}
}
diff --git a/docs/reducing_ec_image_size.md b/docs/reducing_ec_image_size.md
index a165f165ff..dd7d9bbcab 100644
--- a/docs/reducing_ec_image_size.md
+++ b/docs/reducing_ec_image_size.md
@@ -233,6 +233,7 @@ prj.conf file to disable the console command.
| x | CONFIG_CMD_PD | `pd` | Used by FAFT PD |
| | CONFIG_CMD_PD_DEV_DUMP_INFO | | Not a console command |
| | CONFIG_CMD_PD_FLASH | `pd flash` | Not supported by TCPMv2 |
+| | CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE | `pd <port> srccaps` | Defining this reduces the verbosity of this command, saving bytes |
| | CONFIG_CMD_PECI | `peci` | firmware_ECThermal uses `ectool tempsinfo` |
| | CONFIG_CMD_PLL | `pll` | only used by lm4 chip |
| | CONFIG_CMD_POWERINDEBUG | `powerindebug` | |
diff --git a/include/config.h b/include/config.h
index 9fd746071c..ce5fa5c25e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1405,6 +1405,7 @@
#undef CONFIG_CMD_BATT_MFG_ACCESS
#undef CONFIG_CMD_BUTTON
#define CONFIG_CMD_CBI
+#undef CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE
/*
* HAS_TASK_CHIPSET implies the GSC presence.