summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-02-16 12:43:22 -0800
committerVic Yang <victoryang@chromium.org>2012-02-16 12:45:51 -0800
commit6a60a7fbdc83e3b5b8e8534353d30fb0966a5303 (patch)
tree212d35fa19b4078f782d34510b445a6b85d5ff40 /util
parentb221c77b6293ad03e2610b940e2d39de6d40c4db (diff)
downloadchrome-ec-6a60a7fbdc83e3b5b8e8534353d30fb0966a5303.tar.gz
USB charging control LPC command.
Add a LPC command to control USB charging mode. Also add the command to ectool. BUG=chrome-os-partner:7476 TEST=Manually test on link proto-0. Change-Id: Ica87d0a690bc86e28844bd695f31641398b21939 Signed-off-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 49785ac1a1..127f357208 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -40,6 +40,8 @@ const char help_str[] =
" Prints current fan RPM\n"
" pwmsetfanrpm <targetrpm>\n"
" Set target fan RPM\n"
+ " usbchargemode <port> <mode>\n"
+ " Set USB charging mode\n"
"\n"
"Not working for you? Make sure LPC I/O is configured:\n"
" pci_write32 0 0x1f 0 0x88 0x00fc0801\n"
@@ -506,6 +508,39 @@ int cmd_pwm_set_fan_rpm(int argc, char *argv[])
return 0;
}
+int cmd_usb_charge_set_mode(int argc, char *argv[])
+{
+ struct lpc_params_usb_charge_set_mode p;
+ char *e;
+ int rv;
+
+ if (argc != 2) {
+ fprintf(stderr,
+ "Usage: usbchargemode <port_id> <mode_id>\n");
+ return -1;
+ }
+ p.usb_port_id = strtol(argv[0], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad port ID.\n");
+ return -1;
+ }
+ p.mode = strtol(argv[1], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad mode ID.\n");
+ return -1;
+ }
+
+ printf("Setting port %d to mode %d...\n", p.usb_port_id, p.mode);
+
+ rv = ec_command(EC_LPC_COMMAND_USB_CHARGE_SET_MODE,
+ &p, sizeof(p), NULL, 0);
+ if (rv)
+ return rv;
+
+ printf("USB charging mode set.\n");
+ return 0;
+}
+
int main(int argc, char *argv[])
{
if (argc < 2 || !strcasecmp(argv[1], "-?") ||
@@ -543,6 +578,8 @@ int main(int argc, char *argv[])
return cmd_pwm_get_fan_rpm();
if (!strcasecmp(argv[1], "pwmsetfanrpm"))
return cmd_pwm_set_fan_rpm(argc - 2, argv + 2);
+ if (!strcasecmp(argv[1], "usbchargemode"))
+ return cmd_usb_charge_set_mode(argc - 2, argv + 2);
/* If we're still here, command was unknown */
fprintf(stderr, "Unknown command '%s'\n\n", argv[1]);