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>
This commit is contained in:
Randall Spangler
2013-07-11 14:30:41 -07:00
committed by ChromeBot
parent 6696843708
commit eb8920c939
19 changed files with 117 additions and 106 deletions

View File

@@ -197,17 +197,6 @@ void configure_fan_gpios(void)
gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1);
}
/**
* 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.
*/

View File

@@ -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 */

View File

@@ -218,17 +218,6 @@ void configure_fan_gpios(void)
gpio_set_alternate_function(LM4_GPIO_M, 0xc0, 1);
}
/**
* 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.
*/

View File

@@ -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__ */

View File

@@ -191,17 +191,6 @@ void configure_fan_gpios(void)
gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1);
}
/**
* 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.
*/

View File

@@ -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__ */

View File

@@ -191,17 +191,6 @@ void configure_fan_gpios(void)
gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1);
}
/**
* 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.
*/

View File

@@ -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__ */

View File

@@ -190,17 +190,6 @@ void configure_fan_gpios(void)
gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1);
}
/**
* 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.
*/

View File

@@ -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__ */

View File

@@ -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));

View File

@@ -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

View File

@@ -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

View File

@@ -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

46
common/wireless.c Normal file
View File

@@ -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));

View File

@@ -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

View File

@@ -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 */

23
include/wireless.h Normal file
View File

@@ -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 */

View File

@@ -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);