aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/wakeup.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-06-24 19:18:39 -0400
committerLen Brown <len.brown@intel.com>2010-07-06 22:34:26 -0400
commite8b6f970107cfc9c00cdcdb12ec6c7e135cf379f (patch)
tree20c66dfbc33bd5a0818a679ade11a32e267409ed /drivers/acpi/wakeup.c
parentb76df673522d94e3eafcf16935b3d7e5dded3078 (diff)
ACPICA: Introduce acpi_gpe_wakeup()
ACPICA uses reference counters to avoid disabling GPEs too early in case they have been enabled for many times. This is done separately for runtime and for wakeup, but the wakeup GPE reference counter is not really necessary, because GPEs are only enabled to wake up the system at the hardware level by acpi_enter_sleep_state(). Thus it only is necessary to set the corresponding bits in the wakeup enable masks of these GPEs' registers right before the system enters a sleep state. Moreover, the GPE wakeup enable bits can only be set when the target sleep state of the system is known and they need to be cleared immediately after wakeup regardless of how many wakeup devices are associated with a given GPE. On the basis of the above observations, introduce function acpi_gpe_wakeup() to be used for setting or clearing the enable bit corresponding to a given GPE in its enable register's enable_for_wake mask. Modify the ACPI suspend and wakeup code the use acpi_gpe_wakeup() instead of acpi_{enable|disable}_gpe() to set and clear GPE enable bits in their registers' enable_for_wake masks during system transitions to a sleep state and back to the working state, respectively. [This will allow us to drop the third argument of acpi_{enable|disable}_gpe() and simplify the GPE handling code.] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/wakeup.c')
-rw-r--r--drivers/acpi/wakeup.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 388747a7ef4f..c80537bc3234 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -64,13 +64,14 @@ void acpi_enable_wakeup_device(u8 sleep_state)
64 struct acpi_device *dev = 64 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 65 container_of(node, struct acpi_device, wakeup_list);
66 66
67 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled 67 if (!dev->wakeup.flags.valid
68 || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
68 || sleep_state > (u32) dev->wakeup.sleep_state) 69 || sleep_state > (u32) dev->wakeup.sleep_state)
69 continue; 70 continue;
70 71
71 /* The wake-up power should have been enabled already. */ 72 /* The wake-up power should have been enabled already. */
72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 73 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
73 ACPI_GPE_TYPE_WAKE); 74 ACPI_GPE_ENABLE);
74 } 75 }
75} 76}
76 77
@@ -89,13 +90,16 @@ void acpi_disable_wakeup_device(u8 sleep_state)
89 struct acpi_device *dev = 90 struct acpi_device *dev =
90 container_of(node, struct acpi_device, wakeup_list); 91 container_of(node, struct acpi_device, wakeup_list);
91 92
92 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled 93 if (!dev->wakeup.flags.valid
94 || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
93 || (sleep_state > (u32) dev->wakeup.sleep_state)) 95 || (sleep_state > (u32) dev->wakeup.sleep_state))
94 continue; 96 continue;
95 97
96 acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 98 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
97 ACPI_GPE_TYPE_WAKE); 99 ACPI_GPE_DISABLE);
98 acpi_disable_wakeup_device_power(dev); 100
101 if (dev->wakeup.state.enabled)
102 acpi_disable_wakeup_device_power(dev);
99 } 103 }
100} 104}
101 105