summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/falco/board.c11
-rw-r--r--board/falco/board.h6
-rw-r--r--board/link/board.c11
-rw-r--r--board/link/board.h5
-rw-r--r--board/peppy/board.c11
-rw-r--r--board/peppy/board.h5
-rw-r--r--board/slippy/board.c11
-rw-r--r--board/slippy/board.h5
-rw-r--r--board/wolf/board.c11
-rw-r--r--board/wolf/board.h5
-rw-r--r--chip/lm4/switch.c12
-rw-r--r--common/build.mk1
-rw-r--r--common/chipset_haswell.c24
-rw-r--r--common/chipset_ivybridge.c17
-rw-r--r--common/wireless.c46
-rw-r--r--include/ec_commands.h7
-rw-r--r--include/switch.h5
-rw-r--r--include/wireless.h23
-rw-r--r--util/ectool.c7
19 files changed, 117 insertions, 106 deletions
diff --git a/board/falco/board.c b/board/falco/board.c
index b98d03f7b2..a812e8ea1a 100644
--- a/board/falco/board.c
+++ b/board/falco/board.c
@@ -198,17 +198,6 @@ void configure_fan_gpios(void)
}
/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled)
-{
- gpio_set_level(GPIO_WLAN_OFF_L,
- enabled & EC_WIRELESS_SWITCH_WLAN);
- gpio_set_level(GPIO_PP3300_LTE_EN,
- enabled & EC_WIRELESS_SWITCH_WWAN);
-}
-
-/**
* Perform necessary actions on host wake events.
*/
void board_process_wake_events(uint32_t active_wake_events)
diff --git a/board/falco/board.h b/board/falco/board.h
index 5a20099288..2dc76d7190 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -38,6 +38,7 @@
#define CONFIG_PWM_FAN
#define CONFIG_TEMP_SENSOR
#define CONFIG_USB_PORT_POWER_DUMB
+#define CONFIG_WIRELESS
#ifndef __ASSEMBLER__
@@ -210,6 +211,11 @@ enum board_version {
BOARD_VERSION_EVT = 1,
};
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
+#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
+#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
+
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */
diff --git a/board/link/board.c b/board/link/board.c
index 62c7332d78..f93fe22313 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -219,17 +219,6 @@ void configure_fan_gpios(void)
}
/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled)
-{
- gpio_set_level(GPIO_RADIO_ENABLE_WLAN,
- enabled & EC_WIRELESS_SWITCH_WLAN);
- gpio_set_level(GPIO_RADIO_ENABLE_BT,
- enabled & EC_WIRELESS_SWITCH_BLUETOOTH);
-}
-
-/**
* Perform necessary actions on host events.
*/
void board_process_wake_events(uint32_t active_wake_events)
diff --git a/board/link/board.h b/board/link/board.h
index 38e7130ba7..8ef9e426bc 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -43,6 +43,7 @@
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_TMP006
#define CONFIG_USB_PORT_POWER_SMART
+#define CONFIG_WIRELESS
#define CONFIG_WP_ACTIVE_HIGH
#ifndef __ASSEMBLER__
@@ -234,6 +235,10 @@ enum board_version {
BOARD_VERSION_EVT = 1,
};
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_RADIO_ENABLE_WLAN
+#define WIRELESS_GPIO_BLUETOOTH GPIO_RADIO_ENABLE_BT
+#define WIRELESS_GPIO_WLAN_POWER GPIO_ENABLE_WLAN
#endif /* !__ASSEMBLER__ */
diff --git a/board/peppy/board.c b/board/peppy/board.c
index 293747c43b..fb97805ef7 100644
--- a/board/peppy/board.c
+++ b/board/peppy/board.c
@@ -192,17 +192,6 @@ void configure_fan_gpios(void)
}
/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled)
-{
- gpio_set_level(GPIO_WLAN_OFF_L,
- enabled & EC_WIRELESS_SWITCH_WLAN);
- gpio_set_level(GPIO_PP3300_LTE_EN,
- enabled & EC_WIRELESS_SWITCH_WWAN);
-}
-
-/**
* Perform necessary actions on host wake events.
*/
void board_process_wake_events(uint32_t active_wake_events)
diff --git a/board/peppy/board.h b/board/peppy/board.h
index 70ad78c48d..a999d6f9e4 100644
--- a/board/peppy/board.h
+++ b/board/peppy/board.h
@@ -37,6 +37,7 @@
#define CONFIG_PWM_FAN
#define CONFIG_TEMP_SENSOR
#define CONFIG_USB_PORT_POWER_DUMB
+#define CONFIG_WIRELESS
#ifndef __ASSEMBLER__
@@ -208,6 +209,10 @@ enum board_version {
BOARD_VERSION_EVT = 1,
};
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
+#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
+#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
#endif /* !__ASSEMBLER__ */
diff --git a/board/slippy/board.c b/board/slippy/board.c
index da361174c2..92782827ad 100644
--- a/board/slippy/board.c
+++ b/board/slippy/board.c
@@ -192,17 +192,6 @@ void configure_fan_gpios(void)
}
/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled)
-{
- gpio_set_level(GPIO_WLAN_OFF_L,
- enabled & EC_WIRELESS_SWITCH_WLAN);
- gpio_set_level(GPIO_PP3300_LTE_EN,
- enabled & EC_WIRELESS_SWITCH_WWAN);
-}
-
-/**
* Perform necessary actions on host wake events.
*/
void board_process_wake_events(uint32_t active_wake_events)
diff --git a/board/slippy/board.h b/board/slippy/board.h
index d41db4781b..3a29c23762 100644
--- a/board/slippy/board.h
+++ b/board/slippy/board.h
@@ -36,6 +36,7 @@
#define CONFIG_PWM_FAN
#define CONFIG_TEMP_SENSOR
#define CONFIG_USB_PORT_POWER_DUMB
+#define CONFIG_WIRELESS
#define CONFIG_WP_ACTIVE_HIGH
#ifndef __ASSEMBLER__
@@ -209,6 +210,10 @@ enum board_version {
BOARD_VERSION_EVT = 1,
};
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
+#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
+#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
#endif /* !__ASSEMBLER__ */
diff --git a/board/wolf/board.c b/board/wolf/board.c
index c1afbb1cbd..ddeb3e6ea5 100644
--- a/board/wolf/board.c
+++ b/board/wolf/board.c
@@ -191,17 +191,6 @@ void configure_fan_gpios(void)
}
/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled)
-{
- gpio_set_level(GPIO_WLAN_OFF_L,
- enabled & EC_WIRELESS_SWITCH_WLAN);
- gpio_set_level(GPIO_PP3300_LTE_EN,
- enabled & EC_WIRELESS_SWITCH_WWAN);
-}
-
-/**
* Perform necessary actions on host wake events.
*/
void board_process_wake_events(uint32_t active_wake_events)
diff --git a/board/wolf/board.h b/board/wolf/board.h
index 2e8a41b884..6c8d440bab 100644
--- a/board/wolf/board.h
+++ b/board/wolf/board.h
@@ -31,6 +31,7 @@
#define CONFIG_PWM_FAN
#define CONFIG_TEMP_SENSOR
#define CONFIG_USB_PORT_POWER_DUMB
+#define CONFIG_WIRELESS
#ifndef __ASSEMBLER__
@@ -194,6 +195,10 @@ enum board_version {
BOARD_VERSION_EVT = 1,
};
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
+#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
+#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
#endif /* !__ASSEMBLER__ */
diff --git a/chip/lm4/switch.c b/chip/lm4/switch.c
index 9d11aa2d9e..40b41a039d 100644
--- a/chip/lm4/switch.c
+++ b/chip/lm4/switch.c
@@ -500,15 +500,3 @@ DECLARE_CONSOLE_COMMAND(mmapinfo, command_mmapinfo,
"Print memmap switch state",
NULL);
-/*****************************************************************************/
-/* Host commands */
-
-static int switch_command_enable_wireless(struct host_cmd_handler_args *args)
-{
- const struct ec_params_switch_enable_wireless *p = args->params;
- board_enable_wireless(p->enabled);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_WIRELESS,
- switch_command_enable_wireless,
- EC_VER_MASK(0));
diff --git a/common/build.mk b/common/build.mk
index a9391d3f68..a4f0422f67 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -48,6 +48,7 @@ common-$(CONFIG_POWER_BUTTON)+=power_button.o
common-$(CONFIG_PSTORE)+=pstore_commands.o
common-$(CONFIG_REGULATOR_IR357X)+=regulator_ir357x.o
common-$(CONFIG_SMART_BATTERY)+=smart_battery.o smart_battery_stub.o
+common-$(CONFIG_WIRELESS)+=wireless.o
common-$(HAS_TASK_CHIPSET)+=chipset.o
common-$(HAS_TASK_CONSOLE)+=console.o
common-$(HAS_TASK_HOSTCMD)+=host_command.o host_event_commands.o
diff --git a/common/chipset_haswell.c b/common/chipset_haswell.c
index 18ea5494f4..4b58c1ff10 100644
--- a/common/chipset_haswell.c
+++ b/common/chipset_haswell.c
@@ -15,6 +15,7 @@
#include "system.h"
#include "timer.h"
#include "util.h"
+#include "wireless.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
@@ -131,11 +132,10 @@ enum x86_state x86_chipset_init(void)
gpio_set_level(GPIO_PP1350_EN, 0);
gpio_set_level(GPIO_EC_EDP_VDD_EN, 0);
gpio_set_level(GPIO_PP3300_DX_EN, 0);
- gpio_set_level(GPIO_PP3300_LTE_EN, 0);
- gpio_set_level(GPIO_PP3300_WLAN_EN, 0);
gpio_set_level(GPIO_PP5000_EN, 0);
gpio_set_level(GPIO_PCH_RSMRST_L, 0);
gpio_set_level(GPIO_PCH_DPWROK, 0);
+ wireless_enable(0);
}
}
@@ -242,19 +242,13 @@ enum x86_state x86_handle_state(enum x86_state state)
/* Turn on power rails */
gpio_set_level(GPIO_PP3300_DX_EN, 1);
- /* Enable WLAN */
- gpio_set_level(GPIO_PP3300_WLAN_EN, 1);
- gpio_set_level(GPIO_WLAN_OFF_L, 1);
-
- /* Enable LTE/WWAN */
- gpio_set_level(GPIO_PP3300_LTE_EN, 1);
+ /* Enable wireless */
+ wireless_enable(1);
/* Wait for non-core power rails good */
if (x86_wait_signals(IN_PGOOD_S0)) {
chipset_force_shutdown();
- gpio_set_level(GPIO_WLAN_OFF_L, 0);
- gpio_set_level(GPIO_PP3300_LTE_EN, 0);
- gpio_set_level(GPIO_PP3300_WLAN_EN, 0);
+ wireless_enable(0);
gpio_set_level(GPIO_EC_EDP_VDD_EN, 0);
gpio_set_level(GPIO_PP3300_DX_EN, 0);
return X86_S3;
@@ -297,12 +291,8 @@ enum x86_state x86_handle_state(enum x86_state state)
/* Disable +CPU_CORE */
gpio_set_level(GPIO_VCORE_EN, 0);
- /* Disable WLAN */
- gpio_set_level(GPIO_WLAN_OFF_L, 0);
- gpio_set_level(GPIO_PP3300_WLAN_EN, 0);
-
- /* Disable LTE/WWAN */
- gpio_set_level(GPIO_PP3300_LTE_EN, 0);
+ /* Disable wireless */
+ wireless_enable(0);
/*
* Deassert prochot since CPU is off and we're about to drop
diff --git a/common/chipset_ivybridge.c b/common/chipset_ivybridge.c
index 32e35031b5..176e68108f 100644
--- a/common/chipset_ivybridge.c
+++ b/common/chipset_ivybridge.c
@@ -15,6 +15,7 @@
#include "system.h"
#include "timer.h"
#include "util.h"
+#include "wireless.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
@@ -237,10 +238,8 @@ enum x86_state x86_handle_state(enum x86_state state)
/* Turn on power rails */
gpio_set_level(GPIO_ENABLE_VS, 1);
- /* Enable WLAN */
- gpio_set_level(GPIO_ENABLE_WLAN, 1);
- gpio_set_level(GPIO_RADIO_ENABLE_WLAN, 1);
- gpio_set_level(GPIO_RADIO_ENABLE_BT, 1);
+ /* Enable wireless */
+ wireless_enable(1);
/*
* Make sure touchscreen is out if reset (even if the lid is
@@ -253,9 +252,7 @@ enum x86_state x86_handle_state(enum x86_state state)
if (x86_wait_signals(IN_PGOOD_S0)) {
chipset_force_shutdown();
gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0);
- gpio_set_level(GPIO_ENABLE_WLAN, 0);
- gpio_set_level(GPIO_RADIO_ENABLE_WLAN, 0);
- gpio_set_level(GPIO_RADIO_ENABLE_BT, 0);
+ wireless_enable(0);
gpio_set_level(GPIO_ENABLE_VS, 0);
return X86_S3;
}
@@ -295,10 +292,8 @@ enum x86_state x86_handle_state(enum x86_state state)
/* Disable +CPU_CORE and +VGFX_CORE */
gpio_set_level(GPIO_ENABLE_VCORE, 0);
- /* Disable WLAN */
- gpio_set_level(GPIO_ENABLE_WLAN, 0);
- gpio_set_level(GPIO_RADIO_ENABLE_WLAN, 0);
- gpio_set_level(GPIO_RADIO_ENABLE_BT, 0);
+ /* Disable wireless */
+ wireless_enable(0);
/*
* Deassert prochot since CPU is off and we're about to drop
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));
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 5d0df934ce..76e02bbf6e 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -143,9 +143,10 @@
#define EC_HOST_CMD_FLAG_VERSION_3 0x02
/* Wireless switch flags */
-#define EC_WIRELESS_SWITCH_WLAN 0x01
-#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
-#define EC_WIRELESS_SWITCH_WWAN 0x04
+#define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */
+#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */
+#define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */
+#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */
/*
* This header file is used in coreboot both in C and ACPI code. The ACPI code
diff --git a/include/switch.h b/include/switch.h
index 70cbfdc3e3..2cd732774e 100644
--- a/include/switch.h
+++ b/include/switch.h
@@ -27,9 +27,4 @@ void switch_interrupt(enum gpio_signal signal);
*/
int switch_get_write_protect(void);
-/**
- * Set wireless switch state.
- */
-void board_enable_wireless(uint8_t enabled);
-
#endif /* __CROS_EC_SWITCH_H */
diff --git a/include/wireless.h b/include/wireless.h
new file mode 100644
index 0000000000..ca23832239
--- /dev/null
+++ b/include/wireless.h
@@ -0,0 +1,23 @@
+/* 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 API for Chrome EC */
+
+#ifndef __CROS_EC_WIRELESS_H
+#define __CROS_EC_WIRELESS_H
+
+#include "common.h"
+#include "ec_commands.h"
+
+/**
+ * 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.
+ */
+void wireless_enable(int flags);
+
+#endif /* __CROS_EC_WIRELESS_H */
diff --git a/util/ectool.c b/util/ectool.c
index eafe2e5d93..70edcf3329 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -2041,9 +2041,10 @@ int cmd_wireless(int argc, char *argv[])
if (argc != 2) {
fprintf(stderr, "Usage: %s <mask>\n", argv[0]);
- fprintf(stderr, " 0x1 = WLAN\n"
- " 0x2 = Bluetooth\n"
- " 0x4 = WWAN\n");
+ 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);