mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
Clean up x86power module
Code cleanup; no functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system to OS; should still boot Change-Id: Icbb628e60792cbecd073a526cd6f879d9e4b20ab Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36692 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -669,7 +669,7 @@ DECLARE_CONSOLE_COMMAND(mmapinfo, command_mmapinfo,
|
||||
/*****************************************************************************/
|
||||
/* Host commands */
|
||||
|
||||
int switch_command_enable_backlight(struct host_cmd_handler_args *args)
|
||||
static int switch_command_enable_backlight(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_switch_enable_backlight *p = args->params;
|
||||
gpio_set_level(GPIO_ENABLE_BACKLIGHT, p->enabled);
|
||||
@@ -677,3 +677,18 @@ int switch_command_enable_backlight(struct host_cmd_handler_args *args)
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_SWITCH_ENABLE_BKLIGHT,
|
||||
switch_command_enable_backlight, 0);
|
||||
|
||||
static int switch_command_enable_wireless(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_switch_enable_wireless *p = args->params;
|
||||
|
||||
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,
|
||||
EC_VER_MASK(0));
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
/* X86 chipset power control module for Chrome EC */
|
||||
|
||||
#include "board.h"
|
||||
#include "chipset.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
@@ -107,7 +107,9 @@ static uint64_t last_shutdown_time;
|
||||
/* Delay before go into hibernation in seconds*/
|
||||
static uint32_t hibernate_delay = 86400; /* 24 Hrs */
|
||||
|
||||
/* Update input signal state */
|
||||
/**
|
||||
* Update input signal state.
|
||||
*/
|
||||
static void update_in_signals(void)
|
||||
{
|
||||
uint32_t inew = 0;
|
||||
@@ -158,9 +160,13 @@ static void update_in_signals(void)
|
||||
in_signals = inew;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for all the inputs in <want> to be present. Returns EC_ERROR_TIMEOUT
|
||||
* if timeout before reaching the desired state.
|
||||
/**
|
||||
* Wait for inputs to be present
|
||||
*
|
||||
* @param want Input flags which must be present (IN_*)
|
||||
*
|
||||
* @return EC_SUCCESS when all inputs are present, or ERROR_TIMEOUT if timeout
|
||||
* before reaching the desired state.
|
||||
*/
|
||||
static int wait_in_signals(uint32_t want)
|
||||
{
|
||||
@@ -318,9 +324,6 @@ void chipset_throttle_cpu(int throttle)
|
||||
/*****************************************************************************/
|
||||
/* Hooks */
|
||||
|
||||
/**
|
||||
* Hook notified when lid state changes.
|
||||
*/
|
||||
static void x86_lid_change(void)
|
||||
{
|
||||
/* Wake up the task to update power state */
|
||||
@@ -328,9 +331,6 @@ static void x86_lid_change(void)
|
||||
}
|
||||
DECLARE_HOOK(HOOK_LID_CHANGE, x86_lid_change, HOOK_PRIO_DEFAULT);
|
||||
|
||||
/**
|
||||
* Hook notified when AC state changes.
|
||||
*/
|
||||
static void x86_power_ac_change(void)
|
||||
{
|
||||
if (power_ac_present()) {
|
||||
@@ -346,21 +346,6 @@ static void x86_power_ac_change(void)
|
||||
}
|
||||
DECLARE_HOOK(HOOK_AC_CHANGE, x86_power_ac_change, HOOK_PRIO_DEFAULT);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Interrupts */
|
||||
|
||||
void x86_power_interrupt(enum gpio_signal signal)
|
||||
{
|
||||
/* Shadow signals and compare with our desired signal state. */
|
||||
update_in_signals();
|
||||
|
||||
/* Wake up the task */
|
||||
task_wake(TASK_ID_X86POWER);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initialization */
|
||||
|
||||
static void x86_power_init(void)
|
||||
{
|
||||
/* Update input state */
|
||||
@@ -414,6 +399,18 @@ static void x86_power_init(void)
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, x86_power_init, HOOK_PRIO_INIT_CHIPSET);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Interrupts */
|
||||
|
||||
void x86_power_interrupt(enum gpio_signal signal)
|
||||
{
|
||||
/* Shadow signals and compare with our desired signal state. */
|
||||
update_in_signals();
|
||||
|
||||
/* Wake up the task */
|
||||
task_wake(TASK_ID_X86POWER);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Task function */
|
||||
|
||||
@@ -441,8 +438,10 @@ void x86_power_task(void)
|
||||
hibernate_delay * 1000000ull;
|
||||
time_now = get_time().val;
|
||||
if (time_now > target_time) {
|
||||
/* Time's up. Hibernate until wake pin
|
||||
* asserted. */
|
||||
/*
|
||||
* Time's up. Hibernate until wake pin
|
||||
* asserted.
|
||||
*/
|
||||
CPRINTF("[%T x86 hibernating]\n");
|
||||
system_hibernate(0, 0);
|
||||
}
|
||||
@@ -760,22 +759,3 @@ DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay,
|
||||
"[sec]",
|
||||
"Set the delay before going into hibernation",
|
||||
NULL);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Host commands */
|
||||
|
||||
/* TODO: belongs in power_button.c since it owns switches? */
|
||||
static int switch_command_enable_wireless(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_switch_enable_wireless *p = args->params;
|
||||
|
||||
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,
|
||||
EC_VER_MASK(0));
|
||||
|
||||
Reference in New Issue
Block a user