Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209514
b: refs/heads/master
c: 2663b3f
h: refs/heads/master
v: v3
  • Loading branch information
Huang Ying authored and Len Brown committed Aug 8, 2010
1 parent 591ac0c commit 647f491
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2a66185bed21427d8d347a42eaf0ad1d3d9fc63
refs/heads/master: 2663b3f23537618c0c286551b138353fe26b3df8
4 changes: 2 additions & 2 deletions trunk/drivers/acpi/apei/apei-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,14 @@ int apei_resources_request(struct apei_resources *resources,
list_for_each_entry(res, &resources->ioport, list) {
if (res == res_bak)
break;
release_mem_region(res->start, res->end - res->start);
release_region(res->start, res->end - res->start);
}
res_bak = NULL;
err_unmap_iomem:
list_for_each_entry(res, &resources->iomem, list) {
if (res == res_bak)
break;
release_region(res->start, res->end - res->start);
release_mem_region(res->start, res->end - res->start);
}
return -EINVAL;
}
Expand Down
60 changes: 39 additions & 21 deletions trunk/drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ static int acpi_sleep_prepare(u32 acpi_state)

}
ACPI_FLUSH_CPU_CACHE();
acpi_enable_wakeup_device_prep(acpi_state);
#endif
printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
acpi_state);
acpi_enable_wakeup_devices(acpi_state);
acpi_enter_sleep_state_prep(acpi_state);
return 0;
}
Expand Down Expand Up @@ -118,16 +118,6 @@ static int acpi_pm_freeze(void)
return 0;
}

/**
* acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
*/
static int acpi_pm_pre_suspend(void)
{
acpi_pm_freeze();
suspend_nvs_save();
return 0;
}

/**
* __acpi_pm_prepare - Prepare the platform to enter the target state.
*
Expand All @@ -137,9 +127,11 @@ static int acpi_pm_pre_suspend(void)
static int __acpi_pm_prepare(void)
{
int error = acpi_sleep_prepare(acpi_target_sleep_state);

suspend_nvs_save();

if (error)
acpi_target_sleep_state = ACPI_STATE_S0;

return error;
}

Expand All @@ -150,8 +142,9 @@ static int __acpi_pm_prepare(void)
static int acpi_pm_prepare(void)
{
int error = __acpi_pm_prepare();

if (!error)
acpi_pm_pre_suspend();
acpi_pm_freeze();

return error;
}
Expand All @@ -166,14 +159,15 @@ static void acpi_pm_finish(void)
{
u32 acpi_state = acpi_target_sleep_state;

suspend_nvs_free();
acpi_ec_unblock_transactions();

if (acpi_state == ACPI_STATE_S0)
return;

printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n",
acpi_state);
acpi_disable_wakeup_devices(acpi_state);
acpi_disable_wakeup_device(acpi_state);
acpi_leave_sleep_state(acpi_state);

/* reset firmware waking vector */
Expand All @@ -187,7 +181,6 @@ static void acpi_pm_finish(void)
*/
static void acpi_pm_end(void)
{
suspend_nvs_free();
/*
* This is necessary in case acpi_pm_finish() is not called during a
* failing transition to a sleep state.
Expand Down Expand Up @@ -258,6 +251,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
}

local_irq_save(flags);
acpi_enable_wakeup_device(acpi_state);
switch (acpi_state) {
case ACPI_STATE_S1:
barrier();
Expand Down Expand Up @@ -303,6 +297,11 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}

static void acpi_suspend_finish(void)
{
acpi_pm_finish();
}

static int acpi_suspend_state_valid(suspend_state_t pm_state)
{
u32 acpi_state;
Expand All @@ -324,7 +323,7 @@ static struct platform_suspend_ops acpi_suspend_ops = {
.begin = acpi_suspend_begin,
.prepare_late = acpi_pm_prepare,
.enter = acpi_suspend_enter,
.wake = acpi_pm_finish,
.wake = acpi_suspend_finish,
.end = acpi_pm_end,
};

Expand All @@ -337,9 +336,9 @@ static struct platform_suspend_ops acpi_suspend_ops = {
static int acpi_suspend_begin_old(suspend_state_t pm_state)
{
int error = acpi_suspend_begin(pm_state);

if (!error)
error = __acpi_pm_prepare();

return error;
}

Expand All @@ -350,9 +349,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
static struct platform_suspend_ops acpi_suspend_ops_old = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin_old,
.prepare_late = acpi_pm_pre_suspend,
.prepare_late = acpi_pm_freeze,
.enter = acpi_suspend_enter,
.wake = acpi_pm_finish,
.wake = acpi_suspend_finish,
.end = acpi_pm_end,
.recover = acpi_pm_finish,
};
Expand Down Expand Up @@ -424,6 +423,16 @@ static int acpi_hibernation_begin(void)
return error;
}

static int acpi_hibernation_pre_snapshot(void)
{
int error = acpi_pm_prepare();

if (!error)
suspend_nvs_save();

return error;
}

static int acpi_hibernation_enter(void)
{
acpi_status status = AE_OK;
Expand All @@ -432,6 +441,7 @@ static int acpi_hibernation_enter(void)
ACPI_FLUSH_CPU_CACHE();

local_irq_save(flags);
acpi_enable_wakeup_device(ACPI_STATE_S4);
/* This shouldn't return. If it returns, we have a problem */
status = acpi_enter_sleep_state(ACPI_STATE_S4);
/* Reprogram control registers and execute _BFS */
Expand Down Expand Up @@ -471,7 +481,7 @@ static void acpi_pm_thaw(void)
static struct platform_hibernation_ops acpi_hibernation_ops = {
.begin = acpi_hibernation_begin,
.end = acpi_pm_end,
.pre_snapshot = acpi_pm_prepare,
.pre_snapshot = acpi_hibernation_pre_snapshot,
.finish = acpi_pm_finish,
.prepare = acpi_pm_prepare,
.enter = acpi_hibernation_enter,
Expand Down Expand Up @@ -507,14 +517,21 @@ static int acpi_hibernation_begin_old(void)
return error;
}

static int acpi_hibernation_pre_snapshot_old(void)
{
acpi_pm_freeze();
suspend_nvs_save();
return 0;
}

/*
* The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
* been requested.
*/
static struct platform_hibernation_ops acpi_hibernation_ops_old = {
.begin = acpi_hibernation_begin_old,
.end = acpi_pm_end,
.pre_snapshot = acpi_pm_pre_suspend,
.pre_snapshot = acpi_hibernation_pre_snapshot_old,
.prepare = acpi_pm_freeze,
.finish = acpi_pm_finish,
.enter = acpi_hibernation_enter,
Expand Down Expand Up @@ -678,6 +695,7 @@ static void acpi_power_off(void)
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
printk(KERN_DEBUG "%s called\n", __func__);
local_irq_disable();
acpi_enable_wakeup_device(ACPI_STATE_S5);
acpi_enter_sleep_state(ACPI_STATE_S5);
}

Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/acpi/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
extern u8 sleep_states[];
extern int acpi_suspend(u32 state);

extern void acpi_enable_wakeup_devices(u8 sleep_state);
extern void acpi_disable_wakeup_devices(u8 sleep_state);
extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state);
extern void acpi_disable_wakeup_device(u8 sleep_state);

extern struct list_head acpi_wakeup_device_list;
extern struct mutex acpi_device_lock;
48 changes: 38 additions & 10 deletions trunk/drivers/acpi/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,45 @@
ACPI_MODULE_NAME("wakeup_devices")

/**
* acpi_enable_wakeup_devices - Enable wake-up device GPEs.
* acpi_enable_wakeup_device_prep - Prepare wake-up devices.
* @sleep_state: ACPI system sleep state.
*
* Enable wakeup device power of devices with the state.enable flag set and set
* the wakeup enable mask bits in the GPE registers that correspond to wakeup
* devices.
* Enable all wake-up devices' power, unless the requested system sleep state is
* too deep.
*/
void acpi_enable_wakeup_devices(u8 sleep_state)
void acpi_enable_wakeup_device_prep(u8 sleep_state)
{
struct list_head *node, *next;

list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node,
struct acpi_device,
wakeup_list);

if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
|| (sleep_state > (u32) dev->wakeup.sleep_state))
continue;

acpi_enable_wakeup_device_power(dev, sleep_state);
}
}

/**
* acpi_enable_wakeup_device - Enable wake-up device GPEs.
* @sleep_state: ACPI system sleep state.
*
* Enable all wake-up devices' GPEs, with the assumption that
* acpi_disable_all_gpes() was executed before, so we don't need to disable any
* GPEs here.
*/
void acpi_enable_wakeup_device(u8 sleep_state)
{
struct list_head *node, *next;

/*
* Caution: this routine must be invoked when interrupt is disabled
* Refer ACPI2.0: P212
*/
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
Expand All @@ -40,20 +68,20 @@ void acpi_enable_wakeup_devices(u8 sleep_state)
|| sleep_state > (u32) dev->wakeup.sleep_state)
continue;

if (dev->wakeup.state.enabled)
acpi_enable_wakeup_device_power(dev, sleep_state);

/* The wake-up power should have been enabled already. */
acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE);
}
}

/**
* acpi_disable_wakeup_devices - Disable devices' wakeup capability.
* acpi_disable_wakeup_device - Disable devices' wakeup capability.
* @sleep_state: ACPI system sleep state.
*
* This function only affects devices with wakeup.state.enabled set, which means
* that it reverses the changes made by acpi_enable_wakeup_device_prep().
*/
void acpi_disable_wakeup_devices(u8 sleep_state)
void acpi_disable_wakeup_device(u8 sleep_state)
{
struct list_head *node, *next;

Expand Down

0 comments on commit 647f491

Please sign in to comment.