aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/bus.c8
-rw-r--r--drivers/pci/pci-acpi.c19
-rw-r--r--drivers/pci/pci.c11
-rw-r--r--drivers/pci/pci.h1
4 files changed, 36 insertions, 3 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4edff1738579..d77c2307883c 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -212,6 +212,12 @@ acpi_bus_set_power (
212 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n")); 212 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
213 return_VALUE(-ENODEV); 213 return_VALUE(-ENODEV);
214 } 214 }
215 /*
216 * Get device's current power state if it's unknown
217 * This means device power state isn't initialized or previous setting failed
218 */
219 if (device->power.state == ACPI_STATE_UNKNOWN)
220 acpi_bus_get_power(device->handle, &device->power.state);
215 if (state == device->power.state) { 221 if (state == device->power.state) {
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); 222 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
217 return_VALUE(0); 223 return_VALUE(0);
@@ -231,7 +237,7 @@ acpi_bus_set_power (
231 * On transitions to a high-powered state we first apply power (via 237 * On transitions to a high-powered state we first apply power (via
232 * power resources) then evalute _PSx. Conversly for transitions to 238 * power resources) then evalute _PSx. Conversly for transitions to
233 * a lower-powered state. 239 * a lower-powered state.
234 */ 240 */
235 if (state < device->power.state) { 241 if (state < device->power.state) {
236 if (device->power.flags.power_resources) { 242 if (device->power.flags.power_resources) {
237 result = acpi_power_transition(device, state); 243 result = acpi_power_transition(device, state);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 8eb599708de8..a0d43ea872df 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -253,6 +253,24 @@ static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state)
253 return -ENODEV; 253 return -ENODEV;
254} 254}
255 255
256static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
257{
258 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
259 static int state_conv[] = {
260 [0] = 0,
261 [1] = 1,
262 [2] = 2,
263 [3] = 3,
264 [4] = 3
265 };
266 int acpi_state = state_conv[(int __force) state];
267
268 if (!handle)
269 return -ENODEV;
270 return acpi_bus_set_power(handle, acpi_state);
271}
272
273
256/* ACPI bus type */ 274/* ACPI bus type */
257static int pci_acpi_find_device(struct device *dev, acpi_handle *handle) 275static int pci_acpi_find_device(struct device *dev, acpi_handle *handle)
258{ 276{
@@ -300,6 +318,7 @@ static int __init pci_acpi_init(void)
300 if (ret) 318 if (ret)
301 return 0; 319 return 0;
302 platform_pci_choose_state = acpi_pci_choose_state; 320 platform_pci_choose_state = acpi_pci_choose_state;
321 platform_pci_set_power_state = acpi_pci_set_power_state;
303 return 0; 322 return 0;
304} 323}
305arch_initcall(pci_acpi_init); 324arch_initcall(pci_acpi_init);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5af941807785..a1c66e8ea5f2 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -235,7 +235,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
235 * -EIO if device does not support PCI PM. 235 * -EIO if device does not support PCI PM.
236 * 0 if we can successfully change the power state. 236 * 0 if we can successfully change the power state.
237 */ 237 */
238 238int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t) = NULL;
239int 239int
240pci_set_power_state(struct pci_dev *dev, pci_power_t state) 240pci_set_power_state(struct pci_dev *dev, pci_power_t state)
241{ 241{
@@ -299,8 +299,15 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
299 msleep(10); 299 msleep(10);
300 else if (state == PCI_D2 || dev->current_state == PCI_D2) 300 else if (state == PCI_D2 || dev->current_state == PCI_D2)
301 udelay(200); 301 udelay(200);
302 dev->current_state = state;
303 302
303 /*
304 * Give firmware a chance to be called, such as ACPI _PRx, _PSx
305 * Firmware method after natice method ?
306 */
307 if (platform_pci_set_power_state)
308 platform_pci_set_power_state(dev, state);
309
310 dev->current_state = state;
304 return 0; 311 return 0;
305} 312}
306 313
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 25c44922f7db..d94d7af4f7a0 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -13,6 +13,7 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
13 void *alignf_data); 13 void *alignf_data);
14/* Firmware callbacks */ 14/* Firmware callbacks */
15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
16 17
17/* PCI /proc functions */ 18/* PCI /proc functions */
18#ifdef CONFIG_PROC_FS 19#ifdef CONFIG_PROC_FS