summaryrefslogtreecommitdiff
path: root/common/wireless.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /common/wireless.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-release-R101-14588.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'common/wireless.c')
-rw-r--r--common/wireless.c169
1 files changed, 0 insertions, 169 deletions
diff --git a/common/wireless.c b/common/wireless.c
deleted file mode 100644
index d1f5cad645..0000000000
--- a/common/wireless.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Wireless power management */
-
-#include "common.h"
-#include "console.h"
-#include "gpio.h"
-#include "host_command.h"
-#include "util.h"
-#include "wireless.h"
-
-/* Unless told otherwise, disable wireless in suspend */
-#ifndef CONFIG_WIRELESS_SUSPEND
-#define CONFIG_WIRELESS_SUSPEND 0
-#endif
-
-/*
- * Flags which will be left on when suspending. Other flags will be disabled
- * when suspending.
- */
-static int suspend_flags = CONFIG_WIRELESS_SUSPEND;
-
-/**
- * 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.
- * @param mask Which of those flags to set
- */
-static void wireless_enable(int flags)
-{
-#ifdef WIRELESS_GPIO_WLAN
- gpio_set_level(WIRELESS_GPIO_WLAN,
- flags & EC_WIRELESS_SWITCH_WLAN);
-#endif
-
-#ifdef WIRELESS_GPIO_WWAN
- gpio_set_level(WIRELESS_GPIO_WWAN,
- flags & EC_WIRELESS_SWITCH_WWAN);
-#endif
-
-#ifdef WIRELESS_GPIO_BLUETOOTH
- gpio_set_level(WIRELESS_GPIO_BLUETOOTH,
- flags & EC_WIRELESS_SWITCH_BLUETOOTH);
-#endif
-
-#ifdef WIRELESS_GPIO_WLAN_POWER
-#ifndef CONFIG_WLAN_POWER_ACTIVE_LOW
- gpio_set_level(WIRELESS_GPIO_WLAN_POWER,
- flags & EC_WIRELESS_SWITCH_WLAN_POWER);
-#else
- gpio_set_level(WIRELESS_GPIO_WLAN_POWER,
- !(flags & EC_WIRELESS_SWITCH_WLAN_POWER));
-#endif /* CONFIG_WLAN_POWER_ACTIVE_LOW */
-#endif
-
-}
-
-static int wireless_get(void)
-{
- int flags = 0;
-
-#ifdef WIRELESS_GPIO_WLAN
- if (gpio_get_level(WIRELESS_GPIO_WLAN))
- flags |= EC_WIRELESS_SWITCH_WLAN;
-#endif
-
-#ifdef WIRELESS_GPIO_WWAN
- if (gpio_get_level(WIRELESS_GPIO_WWAN))
- flags |= EC_WIRELESS_SWITCH_WWAN;
-#endif
-
-#ifdef WIRELESS_GPIO_BLUETOOTH
- if (gpio_get_level(WIRELESS_GPIO_BLUETOOTH))
- flags |= EC_WIRELESS_SWITCH_BLUETOOTH;
-#endif
-
-#ifdef WIRELESS_GPIO_WLAN_POWER
-#ifndef CONFIG_WLAN_POWER_ACTIVE_LOW
- if (gpio_get_level(WIRELESS_GPIO_WLAN_POWER))
-#else
- if (!gpio_get_level(WIRELESS_GPIO_WLAN_POWER))
-#endif /* CONFIG_WLAN_POWER_ACTIVE_LOW */
- flags |= EC_WIRELESS_SWITCH_WLAN_POWER;
-#endif
-
- return flags;
-}
-
-void wireless_set_state(enum wireless_power_state state)
-{
- switch (state) {
- case WIRELESS_OFF:
- wireless_enable(0);
- break;
- case WIRELESS_SUSPEND:
- /*
- * When suspending, only turn things off. If the AP has
- * disabled WiFi power, going into S3 should not re-enable it.
- */
- wireless_enable(wireless_get() & suspend_flags);
- break;
- case WIRELESS_ON:
- wireless_enable(EC_WIRELESS_SWITCH_ALL);
- break;
- }
-}
-
-static enum ec_status wireless_enable_cmd(struct host_cmd_handler_args *args)
-{
- const struct ec_params_switch_enable_wireless_v1 *p = args->params;
- struct ec_response_switch_enable_wireless_v1 *r = args->response;
-
- if (args->version == 0) {
- /* Ver.0 command just set all current flags */
- wireless_enable(p->now_flags);
- return EC_RES_SUCCESS;
- }
-
- /* Ver.1 can set flags based on mask */
- wireless_enable((wireless_get() & ~p->now_mask) |
- (p->now_flags & p->now_mask));
-
- suspend_flags = (suspend_flags & ~p->suspend_mask) |
- (p->suspend_flags & p->suspend_mask);
-
- /* And return the current flags */
- r->now_flags = wireless_get();
- r->suspend_flags = suspend_flags;
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_WIRELESS,
- wireless_enable_cmd,
- EC_VER_MASK(0) | EC_VER_MASK(1));
-
-static int command_wireless(int argc, char **argv)
-{
- char *e;
- int i;
-
- if (argc >= 2) {
- i = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
-
- wireless_enable(i);
- }
-
- if (argc >= 3) {
- i = strtoi(argv[2], &e, 0);
- if (*e)
- return EC_ERROR_PARAM2;
-
- suspend_flags = i;
- }
-
- ccprintf("Wireless flags: now=0x%x, suspend=0x%x\n", wireless_get(),
- suspend_flags);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(wireless, command_wireless,
- "[now [suspend]]",
- "Get/set wireless flags");