Skip to content

Commit f517709

Browse files
rjwysockijbarnes993
authored andcommitted
ACPI / PM: Add more run-time wake-up fields
Use the run_wake flag to mark all devices for which run-time wake-up events may be generated by the platform. Introduce a new wake-up flag, always_enabled, for marking devices that should be permanently enabled to generate run-time events. Also, introduce a reference counter for run-wake devices and a function that will initialize all of the run-time wake-up fields for given device. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Len Brown <len.brown@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 9630bdd commit f517709

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

drivers/acpi/button.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ static int acpi_button_add(struct acpi_device *device)
425425
acpi_enable_gpe(device->wakeup.gpe_device,
426426
device->wakeup.gpe_number,
427427
ACPI_GPE_TYPE_WAKE_RUN);
428+
device->wakeup.run_wake_count++;
428429
device->wakeup.state.enabled = 1;
429430
}
430431

@@ -448,6 +449,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
448449
acpi_disable_gpe(device->wakeup.gpe_device,
449450
device->wakeup.gpe_number,
450451
ACPI_GPE_TYPE_WAKE_RUN);
452+
device->wakeup.run_wake_count--;
451453
device->wakeup.state.enabled = 0;
452454
}
453455

drivers/acpi/scan.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -741,19 +741,39 @@ acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device,
741741
return AE_OK;
742742
}
743743

744-
static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
744+
static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
745745
{
746-
acpi_status status = 0;
747-
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
748-
union acpi_object *package = NULL;
749-
int psw_error;
750-
751746
struct acpi_device_id button_device_ids[] = {
752747
{"PNP0C0D", 0},
753748
{"PNP0C0C", 0},
754749
{"PNP0C0E", 0},
755750
{"", 0},
756751
};
752+
acpi_status status;
753+
acpi_event_status event_status;
754+
755+
device->wakeup.run_wake_count = 0;
756+
757+
/* Power button, Lid switch always enable wakeup */
758+
if (!acpi_match_device_ids(device, button_device_ids)) {
759+
device->wakeup.flags.run_wake = 1;
760+
device->wakeup.flags.always_enabled = 1;
761+
return;
762+
}
763+
764+
status = acpi_get_gpe_status(NULL, device->wakeup.gpe_number,
765+
ACPI_NOT_ISR, &event_status);
766+
if (status == AE_OK)
767+
device->wakeup.flags.run_wake =
768+
!!(event_status & ACPI_EVENT_FLAG_HANDLE);
769+
}
770+
771+
static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
772+
{
773+
acpi_status status = 0;
774+
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
775+
union acpi_object *package = NULL;
776+
int psw_error;
757777

758778
/* _PRW */
759779
status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -773,6 +793,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
773793

774794
device->wakeup.flags.valid = 1;
775795
device->wakeup.prepare_count = 0;
796+
acpi_bus_set_run_wake_flags(device);
776797
/* Call _PSW/_DSW object to disable its ability to wake the sleeping
777798
* system for the ACPI device with the _PRW object.
778799
* The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -784,10 +805,6 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
784805
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
785806
"error in _DSW or _PSW evaluation\n"));
786807

787-
/* Power button, Lid switch always enable wakeup */
788-
if (!acpi_match_device_ids(device, button_device_ids))
789-
device->wakeup.flags.run_wake = 1;
790-
791808
end:
792809
if (ACPI_FAILURE(status))
793810
device->flags.wake_capable = 0;

drivers/acpi/wakeup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ int __init acpi_wakeup_device_init(void)
110110
struct acpi_device,
111111
wakeup_list);
112112
/* In case user doesn't load button driver */
113-
if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled)
113+
if (!dev->wakeup.flags.always_enabled ||
114+
dev->wakeup.state.enabled)
114115
continue;
115116
acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
116117
ACPI_GPE_TYPE_WAKE);

include/acpi/acpi_bus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ struct acpi_device_perf {
242242
struct acpi_device_wakeup_flags {
243243
u8 valid:1; /* Can successfully enable wakeup? */
244244
u8 run_wake:1; /* Run-Wake GPE devices */
245+
u8 always_enabled:1; /* Run-wake devices that are always enabled */
245246
};
246247

247248
struct acpi_device_wakeup_state {
@@ -256,6 +257,7 @@ struct acpi_device_wakeup {
256257
struct acpi_device_wakeup_state state;
257258
struct acpi_device_wakeup_flags flags;
258259
int prepare_count;
260+
int run_wake_count;
259261
};
260262

261263
/* Device */

0 commit comments

Comments
 (0)