diff options
author | Rafael J. Wysocki | 2021-11-10 14:01:09 +0100 |
---|---|---|
committer | Rafael J. Wysocki | 2021-11-10 14:01:09 +0100 |
commit | 2c49dabad80d2177045554328da679f37b767ac9 (patch) | |
tree | 300e95bbb0cbefc524006dd287070b9d2f7b7137 /drivers/acpi | |
parent | 452a3e723f75880757acf87b053935c43aa89f89 (diff) | |
parent | dff5acfd87e17ce8be3566b9948dc5ad558b0425 (diff) |
Merge branch 'acpi-dsc'
Merge new ACPI device configuration object _DSC support for 5.16-rc1.
* acpi-dsc:
Documentation: ACPI: Fix non-D0 probe _DSC object example
at24: Support probing while in non-zero ACPI D state
media: i2c: imx319: Support device probe in non-zero ACPI D state
ACPI: Add a convenience function to tell a device is in D0 state
Documentation: ACPI: Document _DSC object usage for enum power state
i2c: Allow an ACPI driver to manage the device's power state during probe
ACPI: scan: Obtain device's desired enumeration power state
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/device_pm.c | 26 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 0028b6b51c87..19b33c028f35 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1400,4 +1400,30 @@ bool acpi_storage_d3(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_storage_d3); +/** + * acpi_dev_state_d0 - Tell if the device is in D0 power state + * @dev: Physical device the ACPI power state of which to check + * + * On a system without ACPI, return true. On a system with ACPI, return true if + * the current ACPI power state of the device is D0, or false otherwise. + * + * Note that the power state of a device is not well-defined after it has been + * passed to acpi_device_set_power() and before that function returns, so it is + * not valid to ask for the ACPI power state of the device in that time frame. + * + * This function is intended to be used in a driver's probe or remove + * function. See Documentation/firmware-guide/acpi/low-power-probe.rst for + * more information. + */ +bool acpi_dev_state_d0(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return true; + + return adev->power.state == ACPI_STATE_D0; +} +EXPORT_SYMBOL_GPL(acpi_dev_state_d0); + #endif /* CONFIG_PM */ diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index dce2c291b982..a50f1967c73d 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1017,6 +1017,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) static void acpi_bus_get_power_flags(struct acpi_device *device) { + unsigned long long dsc = ACPI_STATE_D0; u32 i; /* Presence of _PS0|_PR0 indicates 'power manageable' */ @@ -1038,6 +1039,9 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) if (acpi_has_method(device->handle, "_DSW")) device->power.flags.dsw_present = 1; + acpi_evaluate_integer(device->handle, "_DSC", NULL, &dsc); + device->power.state_for_enumeration = dsc; + /* * Enumerate supported power management states */ |