summaryrefslogtreecommitdiff
path: root/common/wireless.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-07-11 14:30:41 -0700
committerChromeBot <chrome-bot@google.com>2013-07-11 16:51:40 -0700
commiteb8920c93921122e19c1ccf682b76d45a0bda7fd (patch)
treedbf17dba2d4be2c24940369f768dd49b2e36a635 /common/wireless.c
parent6696843708b7e5cb83a6c061a76cf70cbfd2523f (diff)
downloadchrome-ec-eb8920c93921122e19c1ccf682b76d45a0bda7fd.tar.gz
Split wireless power/radio control out of switch.c
Chipset control of wireless power uses the new API instead of overriding the wireless power itself. Refactor board-specific support for it to just a few config #defines instead of board-specific functions. This makes some assumptions about the polarity of the enable signals. Not making those assumptions would require defining an array of structs or some other heavier-weight board-specific info. Since the assumptions hold for all current boards, let's make them now because this is a step in the right direction, and reserve doing something more general until we actually have a use case for it (so we build in just the flexibility we need). BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms; see that link wifi turns on at boot and off at shutdown (verify via 'gpioget' from EC console) Change-Id: Ic036e76158198d2d5e3dd244c3c7b9b1e8d62982 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61608 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/wireless.c')
-rw-r--r--common/wireless.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/common/wireless.c b/common/wireless.c
new file mode 100644
index 0000000000..2344f08cd5
--- /dev/null
+++ b/common/wireless.c
@@ -0,0 +1,46 @@
+/* Copyright (c) 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 "gpio.h"
+#include "host_command.h"
+
+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
+ gpio_set_level(WIRELESS_GPIO_WLAN_POWER,
+ flags & EC_WIRELESS_SWITCH_WLAN_POWER);
+#endif
+
+}
+
+static int wireless_enable_cmd(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_switch_enable_wireless *p = args->params;
+
+ wireless_enable(p->enabled);
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_WIRELESS,
+ wireless_enable_cmd,
+ EC_VER_MASK(0));