summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-04-01 10:05:57 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-07 22:25:25 +0000
commit17487510e3e2f91f44692e7d30db8c7d8fcde2bd (patch)
treecaa942810c3558d127123d50a7f2fd9bbf469417 /util
parent6d80aeed939a35859c87517236e88c847604499d (diff)
downloadchrome-ec-17487510e3e2f91f44692e7d30db8c7d8fcde2bd.tar.gz
ec: Add Inventory command
Add command that list supported features by the firmware. Also let the firmware indicates if more features are expected in the RW version. This will help the cros_ec framework load the right driver(s) for exposing information via sysfs. BUG=chromium:428364 BRANCH=none TEST=Test on samus on both ec and pd: localhost ~ # ectool inventory EC supported features: 1 : Flash support 2 : Direct Fan power management support 3 : Keyboard backlight support 4 : Lightbar support 6 : Motion Sensors support 7 : Keyboard support 9 : BIOS Port 80h access support 10 : Thermal management support 11 : Switch backlight on/off support 12 : Switch wifi on/off support 13 : Host event support 14 : GPIO support 15 : I2C master support 16 : Charger support 17 : Simple Battery support 18 : Smart Battery support 21 : Control downstream MCU support localhost ~ # ectool --name cros_pd inventory EC supported features: 1 : Flash support 14 : GPIO support 15 : I2C master support 22 : USB Cros Power Delievery support Change-Id: Ib6eaac91fda86835e754c5316ecf81fbc27786e5 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/263463 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Sameer Nanda <snanda@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index c809464d92..9470600029 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -127,6 +127,8 @@ const char help_str[] =
" Perform I2C transfer on EC's I2C bus\n"
" infopddev <port>\n"
" Get info about USB type-C accessory attached to port\n"
+ " inventory\n"
+ " Return the list of supported features\n"
" keyscan <beat_us> <filename>\n"
" Test low-level key scanning\n"
" led <name> <query | auto | off | <color> | <color>=<value>...>\n"
@@ -392,6 +394,58 @@ int cmd_s5(int argc, char *argv[])
return rv < 0;
}
+static const char * const ec_feature_names[] = {
+ [EC_FEATURE_LIMITED] = "Limited image, load RW for more",
+ [EC_FEATURE_FLASH] = "Flash",
+ [EC_FEATURE_PWM_FAN] = "Direct Fan power management",
+ [EC_FEATURE_PWM_KEYB] = "Keyboard backlight",
+ [EC_FEATURE_LIGHTBAR] = "Lightbar",
+ [EC_FEATURE_LED] = "LED",
+ [EC_FEATURE_MOTION_SENSE] = "Motion Sensors",
+ [EC_FEATURE_KEYB] = "Keyboard",
+ [EC_FEATURE_PSTORE] = "Host Permanent Storage",
+ [EC_FEATURE_PORT80] = "BIOS Port 80h access",
+ [EC_FEATURE_THERMAL] = "Thermal management",
+ [EC_FEATURE_BKLIGHT_SWITCH] = "Switch backlight on/off",
+ [EC_FEATURE_WIFI_SWITCH] = "Switch wifi on/off",
+ [EC_FEATURE_HOST_EVENTS] = "Host event",
+ [EC_FEATURE_GPIO] = "GPIO",
+ [EC_FEATURE_I2C] = "I2C master",
+ [EC_FEATURE_CHARGER] = "Charger",
+ [EC_FEATURE_BATTERY] = "Simple Battery",
+ [EC_FEATURE_SMART_BATTERY] = "Smart Battery",
+ [EC_FEATURE_HANG_DETECT] = "Host hang detection",
+ [EC_FEATURE_PMU] = "Power Management",
+ [EC_FEATURE_SUB_MCU] = "Control downstream MCU",
+ [EC_FEATURE_USB_PD] = "USB Cros Power Delievery",
+ [EC_FEATURE_USB_MUX] = "USB Multiplexer",
+};
+
+int cmd_inventory(int argc, char *argv[])
+{
+ struct ec_response_get_features r;
+ int rv, i, j, idx;
+
+ rv = ec_command(EC_CMD_GET_FEATURES, 0, NULL, 0, &r, sizeof(r));
+ if (rv < 0)
+ return rv;
+
+ printf("EC supported features:\n");
+ for (i = 0, idx = 0; i < 2; i++) {
+ for (j = 0; j < 32; j++, idx++) {
+ if (r.flags[i] & (1 << j)) {
+ if (idx >= ARRAY_SIZE(ec_feature_names) ||
+ strlen(ec_feature_names[idx]) == 0)
+ printf("%-4d: Unknown feature\n", idx);
+ else
+ printf("%-4d: %s support\n",
+ idx, ec_feature_names[idx]);
+ }
+ }
+ }
+ return 0;
+}
+
int cmd_cmdversions(int argc, char *argv[])
{
@@ -6155,6 +6209,7 @@ const struct command commands[] = {
{"i2cwrite", cmd_i2c_write},
{"i2cxfer", cmd_i2c_xfer},
{"infopddev", cmd_pd_device_info},
+ {"inventory", cmd_inventory},
{"led", cmd_led},
{"lightbar", cmd_lightbar},
{"keyconfig", cmd_keyconfig},