aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWitold Szczeponik <Witold.Szczeponik@gmx.net>2009-03-30 13:31:06 -0400
committerLen Brown <len.brown@intel.com>2009-04-03 21:44:10 -0400
commit6328a57401dc5f5cf9931738eb7268fcd8058c49 (patch)
tree48aaa1fd1fee09a8641fb94ae16b19b95408778a /drivers
parent8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff)
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in http://lkml.org/lkml/2008/12/8/284, with new error handling.) This patch sets the power of PnP ACPI devices to D0 when they are activated and to D3 when they are disabled. The latter is in correspondence with the ACPI 3.0 specification, whereas the former is added in order to be able to power up a device after it has been previously disabled (or when booting up a system). (As a consequence, the patch makes the PnP ACPI code more ACPI compliant.) Section 6.2.2 of the ACPI Specification (at least versions 1.0b and 3.0a) states: "Prior to running this control method [_DIS], the OS[PM] will have already put the device in the D3 state." Unfortunately, there is no clear statement as to when to put a device in the D0 state. :-( Therefore, the patch executes the method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the device is disabled, _SRS enables the device at the specified resources." (From the ACPI 3.0a Specification.) The patch fixes a problem with some IBM ThinkPads (at least the 600E and the 600X) where the serial ports have a dedicated power source that needs to be brought up before the serial port can be used. Without this patch, the serial port is enabled but has no power. (In the past, the tpctl utility had to be utilized to turn on the power, but support for this feature stopped with version 5.9 as it did not support the more recent kernel versions.) The error handlers that handle any errors that can occur during the power up/power down phases return the error codes to the caller directly. Comments welcome! :-) No regressions were observed on hardware that does not require this patch. The patch is applied against 2.6.27.x. Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net> Acked-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pnp/pnpacpi/core.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 2834846a185d..9a3a682c6981 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -83,7 +83,6 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
83 acpi_handle handle = dev->data; 83 acpi_handle handle = dev->data;
84 struct acpi_buffer buffer; 84 struct acpi_buffer buffer;
85 int ret; 85 int ret;
86 acpi_status status;
87 86
88 pnp_dbg(&dev->dev, "set resources\n"); 87 pnp_dbg(&dev->dev, "set resources\n");
89 ret = pnpacpi_build_resource_template(dev, &buffer); 88 ret = pnpacpi_build_resource_template(dev, &buffer);
@@ -94,21 +93,31 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
94 kfree(buffer.pointer); 93 kfree(buffer.pointer);
95 return ret; 94 return ret;
96 } 95 }
97 status = acpi_set_current_resources(handle, &buffer); 96 if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
98 if (ACPI_FAILURE(status))
99 ret = -EINVAL; 97 ret = -EINVAL;
98 else if (acpi_bus_power_manageable(handle))
99 ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
100 kfree(buffer.pointer); 100 kfree(buffer.pointer);
101 return ret; 101 return ret;
102} 102}
103 103
104static int pnpacpi_disable_resources(struct pnp_dev *dev) 104static int pnpacpi_disable_resources(struct pnp_dev *dev)
105{ 105{
106 acpi_status status; 106 acpi_handle handle = dev->data;
107 int ret;
108
109 dev_dbg(&dev->dev, "disable resources\n");
107 110
108 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 111 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
109 status = acpi_evaluate_object((acpi_handle) dev->data, 112 ret = 0;
110 "_DIS", NULL, NULL); 113 if (acpi_bus_power_manageable(handle)) {
111 return ACPI_FAILURE(status) ? -ENODEV : 0; 114 ret = acpi_bus_set_power(handle, ACPI_STATE_D3);
115 if (ret)
116 return ret;
117 }
118 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
119 ret = -ENODEV;
120 return ret;
112} 121}
113 122
114#ifdef CONFIG_ACPI_SLEEP 123#ifdef CONFIG_ACPI_SLEEP