Commit 63dbb867 authored by Len Brown's avatar Len Brown Committed by Len Brown

[ACPI] Enable run-time CM button/LID events (David Shaohua Li)

http://bugzilla.kernel.org/show_bug.cgi?id=1415
parent 78fbd8ba
...@@ -84,6 +84,8 @@ EXPORT_SYMBOL(acpi_resource_to_address64); ...@@ -84,6 +84,8 @@ EXPORT_SYMBOL(acpi_resource_to_address64);
EXPORT_SYMBOL(acpi_enable_event); EXPORT_SYMBOL(acpi_enable_event);
EXPORT_SYMBOL(acpi_disable_event); EXPORT_SYMBOL(acpi_disable_event);
EXPORT_SYMBOL(acpi_clear_event); EXPORT_SYMBOL(acpi_clear_event);
EXPORT_SYMBOL(acpi_set_gpe_type);
EXPORT_SYMBOL(acpi_enable_gpe);
EXPORT_SYMBOL(acpi_get_timer_duration); EXPORT_SYMBOL(acpi_get_timer_duration);
EXPORT_SYMBOL(acpi_get_timer); EXPORT_SYMBOL(acpi_get_timer);
EXPORT_SYMBOL(acpi_get_sleep_type_data); EXPORT_SYMBOL(acpi_get_sleep_type_data);
......
...@@ -456,6 +456,15 @@ acpi_button_add ( ...@@ -456,6 +456,15 @@ acpi_button_add (
goto end; goto end;
} }
if (device->wakeup.flags.valid) {
/* Button's GPE is run-wake GPE */
acpi_set_gpe_type(device->wakeup.gpe_device,
device->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN);
acpi_enable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number, ACPI_NOT_ISR);
device->wakeup.state.enabled = 1;
}
printk(KERN_INFO PREFIX "%s [%s]\n", printk(KERN_INFO PREFIX "%s [%s]\n",
acpi_device_name(device), acpi_device_bid(device)); acpi_device_name(device), acpi_device_bid(device));
......
...@@ -68,12 +68,28 @@ acpi_enable_wakeup_device( ...@@ -68,12 +68,28 @@ acpi_enable_wakeup_device(
struct acpi_device * dev = container_of(node, struct acpi_device * dev = container_of(node,
struct acpi_device, wakeup_list); struct acpi_device, wakeup_list);
/* If users want to disable run-wake GPE,
* we only disable it for wake and leave it for runtime
*/
if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME);
/* Re-enable it, since set_gpe_type will disable it */
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_ISR);
spin_lock(&acpi_device_lock);
continue;
}
if (!dev->wakeup.flags.valid || if (!dev->wakeup.flags.valid ||
!dev->wakeup.state.enabled || !dev->wakeup.state.enabled ||
(sleep_state > (u32) dev->wakeup.sleep_state)) (sleep_state > (u32) dev->wakeup.sleep_state))
continue; continue;
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
/* run-wake GPE has been enabled */
if (!dev->wakeup.flags.run_wake)
acpi_enable_gpe(dev->wakeup.gpe_device, acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_ISR); dev->wakeup.gpe_number, ACPI_ISR);
dev->wakeup.state.active = 1; dev->wakeup.state.active = 1;
...@@ -100,6 +116,17 @@ acpi_disable_wakeup_device ( ...@@ -100,6 +116,17 @@ acpi_disable_wakeup_device (
struct acpi_device * dev = container_of(node, struct acpi_device * dev = container_of(node,
struct acpi_device, wakeup_list); struct acpi_device, wakeup_list);
if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN);
/* Re-enable it, since set_gpe_type will disable it */
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR);
spin_lock(&acpi_device_lock);
continue;
}
if (!dev->wakeup.flags.valid || if (!dev->wakeup.flags.valid ||
!dev->wakeup.state.active || !dev->wakeup.state.active ||
(sleep_state > (u32) dev->wakeup.sleep_state)) (sleep_state > (u32) dev->wakeup.sleep_state))
...@@ -107,10 +134,13 @@ acpi_disable_wakeup_device ( ...@@ -107,10 +134,13 @@ acpi_disable_wakeup_device (
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
acpi_disable_wakeup_device_power(dev); acpi_disable_wakeup_device_power(dev);
/* Never disable run-wake GPE */
if (!dev->wakeup.flags.run_wake) {
acpi_disable_gpe(dev->wakeup.gpe_device, acpi_disable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR); dev->wakeup.gpe_number, ACPI_NOT_ISR);
acpi_clear_gpe(dev->wakeup.gpe_device, acpi_clear_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR); dev->wakeup.gpe_number, ACPI_NOT_ISR);
}
dev->wakeup.state.active = 0; dev->wakeup.state.active = 0;
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
} }
...@@ -128,11 +158,13 @@ static int __init acpi_wakeup_device_init(void) ...@@ -128,11 +158,13 @@ static int __init acpi_wakeup_device_init(void)
struct acpi_device * dev = container_of(node, struct acpi_device * dev = container_of(node,
struct acpi_device, wakeup_list); struct acpi_device, wakeup_list);
/* Enable wakeup GPE for Lid/sleep button by default */ /* In case user doesn't load button driver */
if (dev->wakeup.flags.run_wake) { if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device, acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN);
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR);
dev->wakeup.state.enabled = 1; dev->wakeup.state.enabled = 1;
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment