diff options
author | Vic Yang <victoryang@chromium.org> | 2012-05-25 15:48:36 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-06-01 08:15:47 -0700 |
commit | 3f129c161e2636e6e4d0c5f1cb1d5fe53f452fcc (patch) | |
tree | df48d0657812a0047ce804b16ac4d6b99675afe0 | |
parent | fbfd828b9a28f4e91fc100ef9e474f590acc7989 (diff) | |
download | chrome-ec-3f129c161e2636e6e4d0c5f1cb1d5fe53f452fcc.tar.gz |
Add host command to switch LCD backlight and WLAN/Bluetooth
We need to be able to toggle these signals to increase test coverage.
BUG=chrome-os-partner:9967
TEST=Toggle 'ectool wireless' and see GPIO signal changes.
'ectool backlight 0' and see LCD backlight turn off.
Change-Id: Ic96fe26aa82c33b0e51e1f973280a0edc322f158
Reviewed-on: https://gerrit.chromium.org/gerrit/23625
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
-rw-r--r-- | chip/lm4/power_button.c | 14 | ||||
-rw-r--r-- | common/x86_power.c | 17 | ||||
-rw-r--r-- | include/ec_commands.h | 19 | ||||
-rw-r--r-- | util/ectool.c | 60 |
4 files changed, 110 insertions, 0 deletions
diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index fe7b75d8e5..17bb369011 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -10,6 +10,7 @@ #include "eoption.h" #include "gpio.h" #include "hooks.h" +#include "host_command.h" #include "keyboard.h" #include "keyboard_scan.h" #include "lpc.h" @@ -637,3 +638,16 @@ DECLARE_CONSOLE_COMMAND(mmapinfo, command_mmapinfo, NULL, "Print memmap switch state", NULL); + +/*****************************************************************************/ +/* Host commands */ + +int switch_command_enable_backlight(uint8_t *data, int *resp_size) +{ + struct ec_params_switch_enable_backlight *p = + (struct ec_params_switch_enable_backlight *)data; + gpio_set_level(GPIO_ENABLE_BACKLIGHT, p->enabled); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_BKLIGHT, + switch_command_enable_backlight); diff --git a/common/x86_power.c b/common/x86_power.c index 48d05b6d6d..6115492487 100644 --- a/common/x86_power.c +++ b/common/x86_power.c @@ -10,6 +10,7 @@ #include "console.h" #include "gpio.h" #include "hooks.h" +#include "host_command.h" #include "power_button.h" #include "system.h" #include "task.h" @@ -606,3 +607,19 @@ DECLARE_CONSOLE_COMMAND(x86reset, command_x86reset, "[warm | cold]", "Issue x86 reset", NULL); + +/*****************************************************************************/ +/* Host commands */ + +int switch_command_enable_wireless(uint8_t *data, int *resp_size) +{ + struct ec_params_switch_enable_wireless *p = + (struct ec_params_switch_enable_wireless *)data; + gpio_set_level(GPIO_RADIO_ENABLE_WLAN, + p->enabled & EC_WIRELESS_SWITCH_WLAN); + gpio_set_level(GPIO_RADIO_ENABLE_BT, + p->enabled & EC_WIRELESS_SWITCH_BLUETOOTH); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_WIRELESS, + switch_command_enable_wireless); diff --git a/include/ec_commands.h b/include/ec_commands.h index 805398e1fb..db84020a4d 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -94,6 +94,10 @@ /* Fake developer switch (for testing) */ #define EC_SWITCH_FAKE_DEVELOPER 0x20 +/* Wireless switch flags */ +#define EC_WIRELESS_SWITCH_WLAN 0x01 +#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 + /* The offset of temperature value stored in mapped memory. * This allows reporting a temperature range of * 200K to 454K = -73C to 181C. @@ -583,6 +587,21 @@ struct ec_response_host_event_mask { #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e /*****************************************************************************/ +/* GPIO switch commands */ + +/* Enable/disable LCD backlight */ +#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90 +struct ec_params_switch_enable_backlight { + uint8_t enabled; +} __attribute__ ((packed)); + +/* Enabled/disable WLAN/Bluetooth */ +#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91 +struct ec_params_switch_enable_wireless { + uint8_t enabled; +} __attribute__ ((packed)); + +/*****************************************************************************/ /* Special commands * * These do not follow the normal rules for commands. See each command for diff --git a/util/ectool.c b/util/ectool.c index abdb9a0938..fab5cef1b0 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -27,6 +27,8 @@ static inline int MIN(int a, int b) { return a < b ? a : b; } const char help_str[] = "Commands:\n" + " backlight <enabled>\n" + " Enable/disable LCD backlight\n" " battery\n" " Prints battery info\n" " chipinfo\n" @@ -89,6 +91,8 @@ const char help_str[] = " Get the threshold temperature value from thermal engine.\n" " thermalset <sensor_id> <threshold_id> <value>\n" " Set the threshold temperature value for thermal engine.\n" + " wireless <mask>\n" + " Enable/disable WLAN/Bluetooth radio\n" " autofanctrl <on>\n" " Turn on automatic fan speed control.\n" " pwmgetfanrpm\n" @@ -1384,6 +1388,60 @@ 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; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <mask>\n", argv[0]); + fprintf(stderr, " 0x1 = WLAN\n" + " 0x2 = Bluetooth\n"); + return -1; + } + p.enabled = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad value.\n"); + return -1; + } + + rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS, + &p, sizeof(p), NULL, 0); + if (rv) + return rv; + + printf("Success.\n"); + return 0; +} + + +int cmd_lcd_backlight(int argc, char *argv[]) +{ + struct ec_params_switch_enable_backlight p; + char *e; + int rv; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <0|1>\n", argv[0]); + return -1; + } + p.enabled = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad value.\n"); + return -1; + } + + rv = ec_command(EC_CMD_SWITCH_ENABLE_BKLIGHT, + &p, sizeof(p), NULL, 0); + if (rv) + return rv; + + printf("Success.\n"); + return 0; +} + + int cmd_battery(int argc, char *argv[]) { char batt_text[EC_MEMMAP_TEXT_MAX]; @@ -1479,6 +1537,7 @@ struct command { /* NULL-terminated list of commands */ const struct command commands[] = { {"autofanctrl", cmd_thermal_auto_fan_ctrl}, + {"backlight", cmd_lcd_backlight}, {"battery", cmd_battery}, {"chipinfo", cmd_chipinfo}, {"eventclear", cmd_host_event_clear}, @@ -1515,6 +1574,7 @@ const struct command commands[] = { {"thermalset", cmd_thermal_set_threshold}, {"usbchargemode", cmd_usb_charge_set_mode}, {"version", cmd_version}, + {"wireless", cmd_wireless}, {NULL, NULL} }; |