aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Lu <aaron.lu@intel.com>2012-11-21 17:33:40 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-21 17:33:40 -0500
commit1399dfcdfe89898ccd791216f9679ba734aea910 (patch)
tree294a90abd00a3a293ea80419782aa690c788102c
parentddc150f7a33ae0c9cb16eaac3641abc00f56316f (diff)
ACPI / PM: Introduce os_accessible flag for power_state
Currently we have valid flag to represent if this ACPI device power state is valid. A device power state is valid does not necessarily mean we, as OSPM, has a mean to put the device into that power state, e.g. D3 cold is always a valid power state for any ACPI device, but if there is no _PS3 or _PRx for this device, we can't really put that device into D3 cold power state. The same is true for D0 power state. So here comes the os_accessible flag, which is only set if the device has provided us the required means to put it into that power state, e.g. if we have _PS3 or _PRx, we can put the device into D3 cold state and thus, D3 cold power state's os_accessible flag will be set in this case. And a new wrapper inline function is added to be used to check if firmware has provided us a way to power off the device during runtime. Signed-off-by: Aaron Lu <aaron.lu@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/scan.c9
-rw-r--r--include/acpi/acpi_bus.h6
2 files changed, 14 insertions, 1 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 1fcb8678665c..da1416af0c8b 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -965,8 +965,10 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
965 * D3hot is only valid if _PR3 present. 965 * D3hot is only valid if _PR3 present.
966 */ 966 */
967 if (ps->resources.count || 967 if (ps->resources.count ||
968 (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) 968 (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) {
969 ps->flags.valid = 1; 969 ps->flags.valid = 1;
970 ps->flags.os_accessible = 1;
971 }
970 972
971 ps->power = -1; /* Unknown - driver assigned */ 973 ps->power = -1; /* Unknown - driver assigned */
972 ps->latency = -1; /* Unknown - driver assigned */ 974 ps->latency = -1; /* Unknown - driver assigned */
@@ -982,6 +984,11 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
982 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) 984 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set)
983 device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1; 985 device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1;
984 986
987 /* Presence of _PS3 or _PRx means we can put the device into D3 cold */
988 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set ||
989 device->power.flags.power_resources)
990 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1;
991
985 acpi_bus_init_power(device); 992 acpi_bus_init_power(device);
986 993
987 return 0; 994 return 0;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 80155fda517f..c3bc4511e0c0 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -201,6 +201,7 @@ struct acpi_device_power_flags {
201struct acpi_device_power_state { 201struct acpi_device_power_state {
202 struct { 202 struct {
203 u8 valid:1; 203 u8 valid:1;
204 u8 os_accessible:1;
204 u8 explicit_set:1; /* _PSx present? */ 205 u8 explicit_set:1; /* _PSx present? */
205 u8 reserved:6; 206 u8 reserved:6;
206 } flags; 207 } flags;
@@ -500,6 +501,11 @@ static inline bool acpi_device_can_wakeup(struct acpi_device *adev)
500 return adev->wakeup.flags.valid; 501 return adev->wakeup.flags.valid;
501} 502}
502 503
504static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
505{
506 return adev->power.states[ACPI_STATE_D3_COLD].flags.os_accessible;
507}
508
503#else /* CONFIG_ACPI */ 509#else /* CONFIG_ACPI */
504 510
505static inline int register_acpi_bus_type(void *bus) { return 0; } 511static inline int register_acpi_bus_type(void *bus) { return 0; }