summaryrefslogtreecommitdiff
path: root/util/ectool.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-02-11 15:33:46 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-02-22 00:50:37 +0000
commit930b41e6a9782e7c8e37f3a283de2e8a3164b155 (patch)
tree5eaf1d7071aaad8e63e5e46ca778cb1aa9a41158 /util/ectool.c
parentff711e4a475c917df0cb38ef747bd4207a513591 (diff)
downloadchrome-ec-930b41e6a9782e7c8e37f3a283de2e8a3164b155.tar.gz
Allow AP to set wireless power state in suspend
Previously, the AP could only set the current wireless power state. It couldn't determine what the EC would do in S3, nor could it get the current wireless power state. Extend the wireless command to do so, and add an EC console command to aid in debugging. BUG=chrome-os-partner:25655 BRANCH=rambi TEST=manual; expected numbers are from EC 'wireless' command AP off -> 0x0, 0x9 AP on -> 0xd 0x9 AP suspended -> 0x9 0x9 AP on -> 0xd 0x9 ectool wireless 0x1 -> 0x1 0x9 ectool wireless 0xd -> 0xd 0x9 ectool wireless 0 0 0 0 -> 0xd 0x9 (and prints 0xd 0x9 to root shell) ectool wireless 5 -1 -1 0 -> 0x5 0x9 AP suspended -> 0x1 0x9 (doesn't turn on 0x8, just turns off 0x4) AP on -> 0xd 0x9 ectool wireless 0 0 0 -1 -> 0xd 0x0 AP suspended -> 0x0 0x0 AP on -> 0xd 0x9 Change-Id: I8ead2d4a4423b51ec4f638bf94c62de98726b25c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187273
Diffstat (limited to 'util/ectool.c')
-rw-r--r--util/ectool.c69
1 files changed, 58 insertions, 11 deletions
diff --git a/util/ectool.c b/util/ectool.c
index dedb617cf9..f0c3d3500f 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -158,7 +158,7 @@ const char help_str[] =
" Set USB mux switch state\n"
" version\n"
" Prints EC version\n"
- " wireless <mask>\n"
+ " wireless <flags> [<mask> [<suspend_flags> <suspend_mask>]]\n"
" Enable/disable WLAN/Bluetooth radio\n"
"\n"
"Not working for you? Make sure LPC I/O is configured:\n"
@@ -2316,30 +2316,77 @@ int cmd_switches(int argc, char *argv[])
int cmd_wireless(int argc, char *argv[])
{
- struct ec_params_switch_enable_wireless p;
char *e;
int rv;
+ int now_flags;
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <mask>\n", argv[0]);
+ if (argc < 2) {
+ fprintf(stderr,
+ "Usage: %s <flags> [<mask> [<susflags> <susmask>]]\n",
+ argv[0]);
fprintf(stderr, " 0x1 = WLAN radio\n"
" 0x2 = Bluetooth radio\n"
" 0x4 = WWAN power\n"
" 0x8 = WLAN power\n");
return -1;
}
- p.enabled = strtol(argv[1], &e, 0);
+
+ now_flags = strtol(argv[1], &e, 0);
if (e && *e) {
- fprintf(stderr, "Bad value.\n");
+ fprintf(stderr, "Bad flags.\n");
return -1;
}
- rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS, 0,
- &p, sizeof(p), NULL, 0);
- if (rv < 0)
- return rv;
+ if (argc < 3) {
+ /* Old-style - current flags only */
+ struct ec_params_switch_enable_wireless_v0 p;
+
+ p.enabled = now_flags;
+ rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS, 0,
+ &p, sizeof(p), NULL, 0);
+ if (rv < 0)
+ return rv;
+
+ printf("Success.\n");
+ } else {
+ /* New-style - masks and suspend flags */
+ struct ec_params_switch_enable_wireless_v1 p;
+ struct ec_response_switch_enable_wireless_v1 r;
+
+ memset(&p, 0, sizeof(p));
+
+ p.now_flags = now_flags;
+
+ p.now_mask = strtol(argv[2], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad mask.\n");
+ return -1;
+ }
+
+ if (argc > 4) {
+ p.suspend_flags = strtol(argv[3], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad suspend flags.\n");
+ return -1;
+ }
+
+ p.suspend_mask = strtol(argv[4], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad suspend mask.\n");
+ return -1;
+ }
+ }
+
+ rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS,
+ EC_VER_SWITCH_ENABLE_WIRELESS,
+ &p, sizeof(p), &r, sizeof(r));
+ if (rv < 0)
+ return rv;
+
+ printf("Now=0x%x, suspend=0x%x\n",
+ r.now_flags, r.suspend_flags);
+ }
- printf("Success.\n");
return 0;
}