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
This commit is contained in:
Randall Spangler
2014-02-11 15:33:46 -08:00
committed by chrome-internal-fetch
parent ff711e4a47
commit 930b41e6a9
11 changed files with 252 additions and 54 deletions

View File

@@ -821,9 +821,11 @@
#undef CONFIG_WIRELESS
/*
* Support for WiFi devices that must remain powered in suspend.
* Support for WiFi devices that must remain powered in suspend. Set to the
* combination of EC_WIRELESS_SWITCH flags (from ec_commands.h) which should
* be set in suspend.
*/
#undef CONFIG_WIRELESS_SUSPEND_ENABLE_WIFI
#undef CONFIG_WIRELESS_SUSPEND
/*
* Write protect signal is active-high. If this is defined, there must be a

View File

@@ -1520,11 +1520,41 @@ struct ec_params_switch_enable_backlight {
/* Enable/disable WLAN/Bluetooth */
#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
#define EC_VER_SWITCH_ENABLE_WIRELESS 1
struct ec_params_switch_enable_wireless {
/* Version 0 params; no response */
struct ec_params_switch_enable_wireless_v0 {
uint8_t enabled;
} __packed;
/* Version 1 params */
struct ec_params_switch_enable_wireless_v1 {
/* Flags to enable now */
uint8_t now_flags;
/* Which flags to copy from now_flags */
uint8_t now_mask;
/*
* Flags to leave enabled in S3, if they're on at the S0->S3
* transition. (Other flags will be disabled by the S0->S3
* transition.)
*/
uint8_t suspend_flags;
/* Which flags to copy from suspend_flags */
uint8_t suspend_mask;
} __packed;
/* Version 1 response */
struct ec_response_switch_enable_wireless_v1 {
/* Flags to enable now */
uint8_t now_flags;
/* Flags to leave enabled in S3 */
uint8_t suspend_flags;
} __packed;
/*****************************************************************************/
/* GPIO commands. Only available on EC if write protect has been disabled. */

View File

@@ -9,15 +9,17 @@
#define __CROS_EC_WIRELESS_H
#include "common.h"
#include "ec_commands.h"
/* Wireless power state for wireless_set_state() */
enum wireless_power_state {
WIRELESS_OFF,
WIRELESS_SUSPEND,
WIRELESS_ON
};
/**
* Set wireless switch state.
*
* @param flags Enable flags from ec_commands.h (EC_WIRELESS_SWITCH_*),
* 0 to turn all wireless off, or -1 to turn all wireless
* on.
* Set wireless power state.
*/
void wireless_enable(int flags);
void wireless_set_state(enum wireless_power_state state);
#endif /* __CROS_EC_WIRELESS_H */