diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/acpi.h | 3 | ||||
| -rw-r--r-- | include/linux/device.h | 9 | ||||
| -rw-r--r-- | include/linux/pci.h | 57 | ||||
| -rw-r--r-- | include/linux/pci_hotplug.h | 14 | ||||
| -rw-r--r-- | include/linux/pci_regs.h | 1 | ||||
| -rw-r--r-- | include/linux/platform_device.h | 1 | ||||
| -rw-r--r-- | include/linux/pm.h | 314 | ||||
| -rw-r--r-- | include/linux/pm_wakeup.h | 28 | ||||
| -rw-r--r-- | include/linux/suspend.h | 14 |
9 files changed, 373 insertions, 68 deletions
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 0601075d09a1..a17177639376 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -235,6 +235,9 @@ int acpi_check_region(resource_size_t start, resource_size_t n, | |||
| 235 | int acpi_check_mem_region(resource_size_t start, resource_size_t n, | 235 | int acpi_check_mem_region(resource_size_t start, resource_size_t n, |
| 236 | const char *name); | 236 | const char *name); |
| 237 | 237 | ||
| 238 | #ifdef CONFIG_PM_SLEEP | ||
| 239 | void __init acpi_old_suspend_ordering(void); | ||
| 240 | #endif /* CONFIG_PM_SLEEP */ | ||
| 238 | #else /* CONFIG_ACPI */ | 241 | #else /* CONFIG_ACPI */ |
| 239 | 242 | ||
| 240 | static inline int early_acpi_boot_init(void) | 243 | static inline int early_acpi_boot_init(void) |
diff --git a/include/linux/device.h b/include/linux/device.h index 6a2d04c011bc..f71a78d123ae 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -68,6 +68,8 @@ struct bus_type { | |||
| 68 | int (*resume_early)(struct device *dev); | 68 | int (*resume_early)(struct device *dev); |
| 69 | int (*resume)(struct device *dev); | 69 | int (*resume)(struct device *dev); |
| 70 | 70 | ||
| 71 | struct pm_ext_ops *pm; | ||
| 72 | |||
| 71 | struct bus_type_private *p; | 73 | struct bus_type_private *p; |
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| @@ -131,6 +133,8 @@ struct device_driver { | |||
| 131 | int (*resume) (struct device *dev); | 133 | int (*resume) (struct device *dev); |
| 132 | struct attribute_group **groups; | 134 | struct attribute_group **groups; |
| 133 | 135 | ||
| 136 | struct pm_ops *pm; | ||
| 137 | |||
| 134 | struct driver_private *p; | 138 | struct driver_private *p; |
| 135 | }; | 139 | }; |
| 136 | 140 | ||
| @@ -197,6 +201,8 @@ struct class { | |||
| 197 | 201 | ||
| 198 | int (*suspend)(struct device *dev, pm_message_t state); | 202 | int (*suspend)(struct device *dev, pm_message_t state); |
| 199 | int (*resume)(struct device *dev); | 203 | int (*resume)(struct device *dev); |
| 204 | |||
| 205 | struct pm_ops *pm; | ||
| 200 | }; | 206 | }; |
| 201 | 207 | ||
| 202 | extern int __must_check class_register(struct class *class); | 208 | extern int __must_check class_register(struct class *class); |
| @@ -248,8 +254,11 @@ struct device_type { | |||
| 248 | struct attribute_group **groups; | 254 | struct attribute_group **groups; |
| 249 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); | 255 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
| 250 | void (*release)(struct device *dev); | 256 | void (*release)(struct device *dev); |
| 257 | |||
| 251 | int (*suspend)(struct device *dev, pm_message_t state); | 258 | int (*suspend)(struct device *dev, pm_message_t state); |
| 252 | int (*resume)(struct device *dev); | 259 | int (*resume)(struct device *dev); |
| 260 | |||
| 261 | struct pm_ops *pm; | ||
| 253 | }; | 262 | }; |
| 254 | 263 | ||
| 255 | /* interface for exporting device attributes */ | 264 | /* interface for exporting device attributes */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index d18b1dd49fab..a6a088e1a804 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -17,8 +17,7 @@ | |||
| 17 | #ifndef LINUX_PCI_H | 17 | #ifndef LINUX_PCI_H |
| 18 | #define LINUX_PCI_H | 18 | #define LINUX_PCI_H |
| 19 | 19 | ||
| 20 | /* Include the pci register defines */ | 20 | #include <linux/pci_regs.h> /* The pci register defines */ |
| 21 | #include <linux/pci_regs.h> | ||
| 22 | 21 | ||
| 23 | /* | 22 | /* |
| 24 | * The PCI interface treats multi-function devices as independent | 23 | * The PCI interface treats multi-function devices as independent |
| @@ -49,12 +48,22 @@ | |||
| 49 | #include <linux/list.h> | 48 | #include <linux/list.h> |
| 50 | #include <linux/compiler.h> | 49 | #include <linux/compiler.h> |
| 51 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
| 51 | #include <linux/kobject.h> | ||
| 52 | #include <asm/atomic.h> | 52 | #include <asm/atomic.h> |
| 53 | #include <linux/device.h> | 53 | #include <linux/device.h> |
| 54 | 54 | ||
| 55 | /* Include the ID list */ | 55 | /* Include the ID list */ |
| 56 | #include <linux/pci_ids.h> | 56 | #include <linux/pci_ids.h> |
| 57 | 57 | ||
| 58 | /* pci_slot represents a physical slot */ | ||
| 59 | struct pci_slot { | ||
| 60 | struct pci_bus *bus; /* The bus this slot is on */ | ||
| 61 | struct list_head list; /* node in list of slots on this bus */ | ||
| 62 | struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ | ||
| 63 | unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ | ||
| 64 | struct kobject kobj; | ||
| 65 | }; | ||
| 66 | |||
| 58 | /* File state for mmap()s on /proc/bus/pci/X/Y */ | 67 | /* File state for mmap()s on /proc/bus/pci/X/Y */ |
| 59 | enum pci_mmap_state { | 68 | enum pci_mmap_state { |
| 60 | pci_mmap_io, | 69 | pci_mmap_io, |
| @@ -142,6 +151,7 @@ struct pci_dev { | |||
| 142 | 151 | ||
| 143 | void *sysdata; /* hook for sys-specific extension */ | 152 | void *sysdata; /* hook for sys-specific extension */ |
| 144 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ | 153 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
| 154 | struct pci_slot *slot; /* Physical slot this device is in */ | ||
| 145 | 155 | ||
| 146 | unsigned int devfn; /* encoded device & function index */ | 156 | unsigned int devfn; /* encoded device & function index */ |
| 147 | unsigned short vendor; | 157 | unsigned short vendor; |
| @@ -167,6 +177,13 @@ struct pci_dev { | |||
| 167 | pci_power_t current_state; /* Current operating state. In ACPI-speak, | 177 | pci_power_t current_state; /* Current operating state. In ACPI-speak, |
| 168 | this is D0-D3, D0 being fully functional, | 178 | this is D0-D3, D0 being fully functional, |
| 169 | and D3 being off. */ | 179 | and D3 being off. */ |
| 180 | int pm_cap; /* PM capability offset in the | ||
| 181 | configuration space */ | ||
| 182 | unsigned int pme_support:5; /* Bitmask of states from which PME# | ||
| 183 | can be generated */ | ||
| 184 | unsigned int d1_support:1; /* Low power state D1 is supported */ | ||
| 185 | unsigned int d2_support:1; /* Low power state D2 is supported */ | ||
| 186 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ | ||
| 170 | 187 | ||
| 171 | #ifdef CONFIG_PCIEASPM | 188 | #ifdef CONFIG_PCIEASPM |
| 172 | struct pcie_link_state *link_state; /* ASPM link state. */ | 189 | struct pcie_link_state *link_state; /* ASPM link state. */ |
| @@ -191,7 +208,6 @@ struct pci_dev { | |||
| 191 | unsigned int is_added:1; | 208 | unsigned int is_added:1; |
| 192 | unsigned int is_busmaster:1; /* device is busmaster */ | 209 | unsigned int is_busmaster:1; /* device is busmaster */ |
| 193 | unsigned int no_msi:1; /* device may not use msi */ | 210 | unsigned int no_msi:1; /* device may not use msi */ |
| 194 | unsigned int no_d1d2:1; /* only allow d0 or d3 */ | ||
| 195 | unsigned int block_ucfg_access:1; /* userspace config space access is blocked */ | 211 | unsigned int block_ucfg_access:1; /* userspace config space access is blocked */ |
| 196 | unsigned int broken_parity_status:1; /* Device generates false positive parity */ | 212 | unsigned int broken_parity_status:1; /* Device generates false positive parity */ |
| 197 | unsigned int msi_enabled:1; | 213 | unsigned int msi_enabled:1; |
| @@ -267,6 +283,7 @@ struct pci_bus { | |||
| 267 | struct list_head children; /* list of child buses */ | 283 | struct list_head children; /* list of child buses */ |
| 268 | struct list_head devices; /* list of devices on this bus */ | 284 | struct list_head devices; /* list of devices on this bus */ |
| 269 | struct pci_dev *self; /* bridge device as seen by parent */ | 285 | struct pci_dev *self; /* bridge device as seen by parent */ |
| 286 | struct list_head slots; /* list of slots on this bus */ | ||
| 270 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; | 287 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; |
| 271 | /* address space routed to this bus */ | 288 | /* address space routed to this bus */ |
| 272 | 289 | ||
| @@ -328,7 +345,7 @@ struct pci_bus_region { | |||
| 328 | struct pci_dynids { | 345 | struct pci_dynids { |
| 329 | spinlock_t lock; /* protects list, index */ | 346 | spinlock_t lock; /* protects list, index */ |
| 330 | struct list_head list; /* for IDs added at runtime */ | 347 | struct list_head list; /* for IDs added at runtime */ |
| 331 | unsigned int use_driver_data:1; /* pci_driver->driver_data is used */ | 348 | unsigned int use_driver_data:1; /* pci_device_id->driver_data is used */ |
| 332 | }; | 349 | }; |
| 333 | 350 | ||
| 334 | /* ---------------------------------------------------------------- */ | 351 | /* ---------------------------------------------------------------- */ |
| @@ -390,7 +407,7 @@ struct pci_driver { | |||
| 390 | int (*resume_early) (struct pci_dev *dev); | 407 | int (*resume_early) (struct pci_dev *dev); |
| 391 | int (*resume) (struct pci_dev *dev); /* Device woken up */ | 408 | int (*resume) (struct pci_dev *dev); /* Device woken up */ |
| 392 | void (*shutdown) (struct pci_dev *dev); | 409 | void (*shutdown) (struct pci_dev *dev); |
| 393 | 410 | struct pm_ext_ops *pm; | |
| 394 | struct pci_error_handlers *err_handler; | 411 | struct pci_error_handlers *err_handler; |
| 395 | struct device_driver driver; | 412 | struct device_driver driver; |
| 396 | struct pci_dynids dynids; | 413 | struct pci_dynids dynids; |
| @@ -489,6 +506,10 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus, | |||
| 489 | struct pci_ops *ops, void *sysdata); | 506 | struct pci_ops *ops, void *sysdata); |
| 490 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 507 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
| 491 | int busnr); | 508 | int busnr); |
| 509 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | ||
| 510 | const char *name); | ||
| 511 | void pci_destroy_slot(struct pci_slot *slot); | ||
| 512 | void pci_update_slot_number(struct pci_slot *slot, int slot_nr); | ||
| 492 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 513 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
| 493 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); | 514 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); |
| 494 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); | 515 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); |
| @@ -618,6 +639,8 @@ int pci_restore_state(struct pci_dev *dev); | |||
| 618 | int pci_set_power_state(struct pci_dev *dev, pci_power_t state); | 639 | int pci_set_power_state(struct pci_dev *dev, pci_power_t state); |
| 619 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); | 640 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); |
| 620 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); | 641 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); |
| 642 | int pci_prepare_to_sleep(struct pci_dev *dev); | ||
| 643 | int pci_back_from_sleep(struct pci_dev *dev); | ||
| 621 | 644 | ||
| 622 | /* Functions for PCI Hotplug drivers to use */ | 645 | /* Functions for PCI Hotplug drivers to use */ |
| 623 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); | 646 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
| @@ -839,6 +862,11 @@ static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) | |||
| 839 | return -EIO; | 862 | return -EIO; |
| 840 | } | 863 | } |
| 841 | 864 | ||
| 865 | static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) | ||
| 866 | { | ||
| 867 | return -EIO; | ||
| 868 | } | ||
| 869 | |||
| 842 | static inline int pci_set_dma_max_seg_size(struct pci_dev *dev, | 870 | static inline int pci_set_dma_max_seg_size(struct pci_dev *dev, |
| 843 | unsigned int size) | 871 | unsigned int size) |
| 844 | { | 872 | { |
| @@ -977,9 +1005,9 @@ static inline void pci_set_drvdata(struct pci_dev *pdev, void *data) | |||
| 977 | /* If you want to know what to call your pci_dev, ask this function. | 1005 | /* If you want to know what to call your pci_dev, ask this function. |
| 978 | * Again, it's a wrapper around the generic device. | 1006 | * Again, it's a wrapper around the generic device. |
| 979 | */ | 1007 | */ |
| 980 | static inline char *pci_name(struct pci_dev *pdev) | 1008 | static inline const char *pci_name(struct pci_dev *pdev) |
| 981 | { | 1009 | { |
| 982 | return pdev->dev.bus_id; | 1010 | return dev_name(&pdev->dev); |
| 983 | } | 1011 | } |
| 984 | 1012 | ||
| 985 | 1013 | ||
| @@ -1014,7 +1042,9 @@ enum pci_fixup_pass { | |||
| 1014 | pci_fixup_header, /* After reading configuration header */ | 1042 | pci_fixup_header, /* After reading configuration header */ |
| 1015 | pci_fixup_final, /* Final phase of device fixups */ | 1043 | pci_fixup_final, /* Final phase of device fixups */ |
| 1016 | pci_fixup_enable, /* pci_enable_device() time */ | 1044 | pci_fixup_enable, /* pci_enable_device() time */ |
| 1017 | pci_fixup_resume, /* pci_enable_device() time */ | 1045 | pci_fixup_resume, /* pci_device_resume() */ |
| 1046 | pci_fixup_suspend, /* pci_device_suspend */ | ||
| 1047 | pci_fixup_resume_early, /* pci_device_resume_early() */ | ||
| 1018 | }; | 1048 | }; |
| 1019 | 1049 | ||
| 1020 | /* Anonymous variables would be nice... */ | 1050 | /* Anonymous variables would be nice... */ |
| @@ -1036,6 +1066,12 @@ enum pci_fixup_pass { | |||
| 1036 | #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ | 1066 | #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ |
| 1037 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ | 1067 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ |
| 1038 | resume##vendor##device##hook, vendor, device, hook) | 1068 | resume##vendor##device##hook, vendor, device, hook) |
| 1069 | #define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ | ||
| 1070 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ | ||
| 1071 | resume_early##vendor##device##hook, vendor, device, hook) | ||
| 1072 | #define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ | ||
| 1073 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ | ||
| 1074 | suspend##vendor##device##hook, vendor, device, hook) | ||
| 1039 | 1075 | ||
| 1040 | 1076 | ||
| 1041 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1077 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
| @@ -1060,7 +1096,10 @@ extern int pci_pci_problems; | |||
| 1060 | extern unsigned long pci_cardbus_io_size; | 1096 | extern unsigned long pci_cardbus_io_size; |
| 1061 | extern unsigned long pci_cardbus_mem_size; | 1097 | extern unsigned long pci_cardbus_mem_size; |
| 1062 | 1098 | ||
| 1063 | extern int pcibios_add_platform_entries(struct pci_dev *dev); | 1099 | int pcibios_add_platform_entries(struct pci_dev *dev); |
| 1100 | void pcibios_disable_device(struct pci_dev *dev); | ||
| 1101 | int pcibios_set_pcie_reset_state(struct pci_dev *dev, | ||
| 1102 | enum pcie_reset_state state); | ||
| 1064 | 1103 | ||
| 1065 | #ifdef CONFIG_PCI_MMCONFIG | 1104 | #ifdef CONFIG_PCI_MMCONFIG |
| 1066 | extern void __init pci_mmcfg_early_init(void); | 1105 | extern void __init pci_mmcfg_early_init(void); |
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h index 8f67e8f2a3cc..a08cd06b541a 100644 --- a/include/linux/pci_hotplug.h +++ b/include/linux/pci_hotplug.h | |||
| @@ -95,9 +95,6 @@ struct hotplug_slot_attribute { | |||
| 95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. | 95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. |
| 96 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 96 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
| 97 | * will be used when this value is requested by a user. | 97 | * will be used when this value is requested by a user. |
| 98 | * @get_address: Called to get pci address of a slot. | ||
| 99 | * If this field is NULL, the value passed in the struct hotplug_slot_info | ||
| 100 | * will be used when this value is requested by a user. | ||
| 101 | * @get_max_bus_speed: Called to get the max bus speed for a slot. | 98 | * @get_max_bus_speed: Called to get the max bus speed for a slot. |
| 102 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 99 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
| 103 | * will be used when this value is requested by a user. | 100 | * will be used when this value is requested by a user. |
| @@ -120,7 +117,6 @@ struct hotplug_slot_ops { | |||
| 120 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); | 117 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); |
| 121 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); | 118 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); |
| 122 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); | 119 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); |
| 123 | int (*get_address) (struct hotplug_slot *slot, u32 *value); | ||
| 124 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 120 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
| 125 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 121 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
| 126 | }; | 122 | }; |
| @@ -140,7 +136,6 @@ struct hotplug_slot_info { | |||
| 140 | u8 attention_status; | 136 | u8 attention_status; |
| 141 | u8 latch_status; | 137 | u8 latch_status; |
| 142 | u8 adapter_status; | 138 | u8 adapter_status; |
| 143 | u32 address; | ||
| 144 | enum pci_bus_speed max_bus_speed; | 139 | enum pci_bus_speed max_bus_speed; |
| 145 | enum pci_bus_speed cur_bus_speed; | 140 | enum pci_bus_speed cur_bus_speed; |
| 146 | }; | 141 | }; |
| @@ -166,15 +161,14 @@ struct hotplug_slot { | |||
| 166 | 161 | ||
| 167 | /* Variables below this are for use only by the hotplug pci core. */ | 162 | /* Variables below this are for use only by the hotplug pci core. */ |
| 168 | struct list_head slot_list; | 163 | struct list_head slot_list; |
| 169 | struct kobject kobj; | 164 | struct pci_slot *pci_slot; |
| 170 | }; | 165 | }; |
| 171 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) | 166 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) |
| 172 | 167 | ||
| 173 | extern int pci_hp_register (struct hotplug_slot *slot); | 168 | extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr); |
| 174 | extern int pci_hp_deregister (struct hotplug_slot *slot); | 169 | extern int pci_hp_deregister(struct hotplug_slot *slot); |
| 175 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, | 170 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, |
| 176 | struct hotplug_slot_info *info); | 171 | struct hotplug_slot_info *info); |
| 177 | extern struct kset *pci_hotplug_slots_kset; | ||
| 178 | 172 | ||
| 179 | /* PCI Setting Record (Type 0) */ | 173 | /* PCI Setting Record (Type 0) */ |
| 180 | struct hpp_type0 { | 174 | struct hpp_type0 { |
| @@ -227,9 +221,9 @@ struct hotplug_params { | |||
| 227 | #include <acpi/acpi.h> | 221 | #include <acpi/acpi.h> |
| 228 | #include <acpi/acpi_bus.h> | 222 | #include <acpi/acpi_bus.h> |
| 229 | #include <acpi/actypes.h> | 223 | #include <acpi/actypes.h> |
| 230 | extern acpi_status acpi_run_oshp(acpi_handle handle); | ||
| 231 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, | 224 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, |
| 232 | struct hotplug_params *hpp); | 225 | struct hotplug_params *hpp); |
| 226 | int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); | ||
| 233 | int acpi_root_bridge(acpi_handle handle); | 227 | int acpi_root_bridge(acpi_handle handle); |
| 234 | #endif | 228 | #endif |
| 235 | #endif | 229 | #endif |
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h index c0c1223c9194..19958b929905 100644 --- a/include/linux/pci_regs.h +++ b/include/linux/pci_regs.h | |||
| @@ -231,6 +231,7 @@ | |||
| 231 | #define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ | 231 | #define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ |
| 232 | #define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ | 232 | #define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ |
| 233 | #define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ | 233 | #define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ |
| 234 | #define PCI_PM_CAP_PME_SHIFT 11 /* Start of the PME Mask in PMC */ | ||
| 234 | #define PCI_PM_CTRL 4 /* PM control and status register */ | 235 | #define PCI_PM_CTRL 4 /* PM control and status register */ |
| 235 | #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ | 236 | #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ |
| 236 | #define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ | 237 | #define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 3261681c82a4..95ac21ab3a09 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
| @@ -53,6 +53,7 @@ struct platform_driver { | |||
| 53 | int (*suspend_late)(struct platform_device *, pm_message_t state); | 53 | int (*suspend_late)(struct platform_device *, pm_message_t state); |
| 54 | int (*resume_early)(struct platform_device *); | 54 | int (*resume_early)(struct platform_device *); |
| 55 | int (*resume)(struct platform_device *); | 55 | int (*resume)(struct platform_device *); |
| 56 | struct pm_ext_ops *pm; | ||
| 56 | struct device_driver driver; | 57 | struct device_driver driver; |
| 57 | }; | 58 | }; |
| 58 | 59 | ||
diff --git a/include/linux/pm.h b/include/linux/pm.h index 39a7ee859b67..4ad9de94449a 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
| @@ -112,7 +112,9 @@ typedef struct pm_message { | |||
| 112 | int event; | 112 | int event; |
| 113 | } pm_message_t; | 113 | } pm_message_t; |
| 114 | 114 | ||
| 115 | /* | 115 | /** |
| 116 | * struct pm_ops - device PM callbacks | ||
| 117 | * | ||
| 116 | * Several driver power state transitions are externally visible, affecting | 118 | * Several driver power state transitions are externally visible, affecting |
| 117 | * the state of pending I/O queues and (for drivers that touch hardware) | 119 | * the state of pending I/O queues and (for drivers that touch hardware) |
| 118 | * interrupts, wakeups, DMA, and other hardware state. There may also be | 120 | * interrupts, wakeups, DMA, and other hardware state. There may also be |
| @@ -120,6 +122,284 @@ typedef struct pm_message { | |||
| 120 | * to the rest of the driver stack (such as a driver that's ON gating off | 122 | * to the rest of the driver stack (such as a driver that's ON gating off |
| 121 | * clocks which are not in active use). | 123 | * clocks which are not in active use). |
| 122 | * | 124 | * |
| 125 | * The externally visible transitions are handled with the help of the following | ||
| 126 | * callbacks included in this structure: | ||
| 127 | * | ||
| 128 | * @prepare: Prepare the device for the upcoming transition, but do NOT change | ||
| 129 | * its hardware state. Prevent new children of the device from being | ||
| 130 | * registered after @prepare() returns (the driver's subsystem and | ||
| 131 | * generally the rest of the kernel is supposed to prevent new calls to the | ||
| 132 | * probe method from being made too once @prepare() has succeeded). If | ||
| 133 | * @prepare() detects a situation it cannot handle (e.g. registration of a | ||
| 134 | * child already in progress), it may return -EAGAIN, so that the PM core | ||
| 135 | * can execute it once again (e.g. after the new child has been registered) | ||
| 136 | * to recover from the race condition. This method is executed for all | ||
| 137 | * kinds of suspend transitions and is followed by one of the suspend | ||
| 138 | * callbacks: @suspend(), @freeze(), or @poweroff(). | ||
| 139 | * The PM core executes @prepare() for all devices before starting to | ||
| 140 | * execute suspend callbacks for any of them, so drivers may assume all of | ||
| 141 | * the other devices to be present and functional while @prepare() is being | ||
| 142 | * executed. In particular, it is safe to make GFP_KERNEL memory | ||
| 143 | * allocations from within @prepare(). However, drivers may NOT assume | ||
| 144 | * anything about the availability of the user space at that time and it | ||
| 145 | * is not correct to request firmware from within @prepare() (it's too | ||
| 146 | * late to do that). [To work around this limitation, drivers may | ||
| 147 | * register suspend and hibernation notifiers that are executed before the | ||
| 148 | * freezing of tasks.] | ||
| 149 | * | ||
| 150 | * @complete: Undo the changes made by @prepare(). This method is executed for | ||
| 151 | * all kinds of resume transitions, following one of the resume callbacks: | ||
| 152 | * @resume(), @thaw(), @restore(). Also called if the state transition | ||
| 153 | * fails before the driver's suspend callback (@suspend(), @freeze(), | ||
| 154 | * @poweroff()) can be executed (e.g. if the suspend callback fails for one | ||
| 155 | * of the other devices that the PM core has unsuccessfully attempted to | ||
| 156 | * suspend earlier). | ||
| 157 | * The PM core executes @complete() after it has executed the appropriate | ||
| 158 | * resume callback for all devices. | ||
| 159 | * | ||
| 160 | * @suspend: Executed before putting the system into a sleep state in which the | ||
| 161 | * contents of main memory are preserved. Quiesce the device, put it into | ||
| 162 | * a low power state appropriate for the upcoming system state (such as | ||
| 163 | * PCI_D3hot), and enable wakeup events as appropriate. | ||
| 164 | * | ||
| 165 | * @resume: Executed after waking the system up from a sleep state in which the | ||
| 166 | * contents of main memory were preserved. Put the device into the | ||
| 167 | * appropriate state, according to the information saved in memory by the | ||
| 168 | * preceding @suspend(). The driver starts working again, responding to | ||
| 169 | * hardware events and software requests. The hardware may have gone | ||
| 170 | * through a power-off reset, or it may have maintained state from the | ||
| 171 | * previous suspend() which the driver may rely on while resuming. On most | ||
| 172 | * platforms, there are no restrictions on availability of resources like | ||
| 173 | * clocks during @resume(). | ||
| 174 | * | ||
| 175 | * @freeze: Hibernation-specific, executed before creating a hibernation image. | ||
| 176 | * Quiesce operations so that a consistent image can be created, but do NOT | ||
| 177 | * otherwise put the device into a low power device state and do NOT emit | ||
| 178 | * system wakeup events. Save in main memory the device settings to be | ||
| 179 | * used by @restore() during the subsequent resume from hibernation or by | ||
| 180 | * the subsequent @thaw(), if the creation of the image or the restoration | ||
| 181 | * of main memory contents from it fails. | ||
| 182 | * | ||
| 183 | * @thaw: Hibernation-specific, executed after creating a hibernation image OR | ||
| 184 | * if the creation of the image fails. Also executed after a failing | ||
| 185 | * attempt to restore the contents of main memory from such an image. | ||
| 186 | * Undo the changes made by the preceding @freeze(), so the device can be | ||
| 187 | * operated in the same way as immediately before the call to @freeze(). | ||
| 188 | * | ||
| 189 | * @poweroff: Hibernation-specific, executed after saving a hibernation image. | ||
| 190 | * Quiesce the device, put it into a low power state appropriate for the | ||
| 191 | * upcoming system state (such as PCI_D3hot), and enable wakeup events as | ||
| 192 | * appropriate. | ||
| 193 | * | ||
| 194 | * @restore: Hibernation-specific, executed after restoring the contents of main | ||
| 195 | * memory from a hibernation image. Driver starts working again, | ||
| 196 | * responding to hardware events and software requests. Drivers may NOT | ||
| 197 | * make ANY assumptions about the hardware state right prior to @restore(). | ||
| 198 | * On most platforms, there are no restrictions on availability of | ||
| 199 | * resources like clocks during @restore(). | ||
| 200 | * | ||
| 201 | * All of the above callbacks, except for @complete(), return error codes. | ||
| 202 | * However, the error codes returned by the resume operations, @resume(), | ||
| 203 | * @thaw(), and @restore(), do not cause the PM core to abort the resume | ||
| 204 | * transition during which they are returned. The error codes returned in | ||
| 205 | * that cases are only printed by the PM core to the system logs for debugging | ||
| 206 | * purposes. Still, it is recommended that drivers only return error codes | ||
| 207 | * from their resume methods in case of an unrecoverable failure (i.e. when the | ||
| 208 | * device being handled refuses to resume and becomes unusable) to allow us to | ||
| 209 | * modify the PM core in the future, so that it can avoid attempting to handle | ||
| 210 | * devices that failed to resume and their children. | ||
| 211 | * | ||
| 212 | * It is allowed to unregister devices while the above callbacks are being | ||
| 213 | * executed. However, it is not allowed to unregister a device from within any | ||
| 214 | * of its own callbacks. | ||
| 215 | */ | ||
| 216 | |||
| 217 | struct pm_ops { | ||
| 218 | int (*prepare)(struct device *dev); | ||
| 219 | void (*complete)(struct device *dev); | ||
| 220 | int (*suspend)(struct device *dev); | ||
| 221 | int (*resume)(struct device *dev); | ||
| 222 | int (*freeze)(struct device *dev); | ||
| 223 | int (*thaw)(struct device *dev); | ||
| 224 | int (*poweroff)(struct device *dev); | ||
| 225 | int (*restore)(struct device *dev); | ||
| 226 | }; | ||
| 227 | |||
| 228 | /** | ||
| 229 | * struct pm_ext_ops - extended device PM callbacks | ||
| 230 | * | ||
| 231 | * Some devices require certain operations related to suspend and hibernation | ||
| 232 | * to be carried out with interrupts disabled. Thus, 'struct pm_ext_ops' below | ||
| 233 | * is defined, adding callbacks to be executed with interrupts disabled to | ||
| 234 | * 'struct pm_ops'. | ||
| 235 | * | ||
| 236 | * The following callbacks included in 'struct pm_ext_ops' are executed with | ||
| 237 | * the nonboot CPUs switched off and with interrupts disabled on the only | ||
| 238 | * functional CPU. They also are executed with the PM core list of devices | ||
| 239 | * locked, so they must NOT unregister any devices. | ||
| 240 | * | ||
| 241 | * @suspend_noirq: Complete the operations of ->suspend() by carrying out any | ||
| 242 | * actions required for suspending the device that need interrupts to be | ||
| 243 | * disabled | ||
| 244 | * | ||
| 245 | * @resume_noirq: Prepare for the execution of ->resume() by carrying out any | ||
| 246 | * actions required for resuming the device that need interrupts to be | ||
| 247 | * disabled | ||
| 248 | * | ||
| 249 | * @freeze_noirq: Complete the operations of ->freeze() by carrying out any | ||
| 250 | * actions required for freezing the device that need interrupts to be | ||
| 251 | * disabled | ||
| 252 | * | ||
| 253 | * @thaw_noirq: Prepare for the execution of ->thaw() by carrying out any | ||
| 254 | * actions required for thawing the device that need interrupts to be | ||
| 255 | * disabled | ||
| 256 | * | ||
| 257 | * @poweroff_noirq: Complete the operations of ->poweroff() by carrying out any | ||
| 258 | * actions required for handling the device that need interrupts to be | ||
| 259 | * disabled | ||
| 260 | * | ||
| 261 | * @restore_noirq: Prepare for the execution of ->restore() by carrying out any | ||
| 262 | * actions required for restoring the operations of the device that need | ||
| 263 | * interrupts to be disabled | ||
| 264 | * | ||
| 265 | * All of the above callbacks return error codes, but the error codes returned | ||
| 266 | * by the resume operations, @resume_noirq(), @thaw_noirq(), and | ||
| 267 | * @restore_noirq(), do not cause the PM core to abort the resume transition | ||
| 268 | * during which they are returned. The error codes returned in that cases are | ||
| 269 | * only printed by the PM core to the system logs for debugging purposes. | ||
| 270 | * Still, as stated above, it is recommended that drivers only return error | ||
| 271 | * codes from their resume methods if the device being handled fails to resume | ||
| 272 | * and is not usable any more. | ||
| 273 | */ | ||
| 274 | |||
| 275 | struct pm_ext_ops { | ||
| 276 | struct pm_ops base; | ||
| 277 | int (*suspend_noirq)(struct device *dev); | ||
| 278 | int (*resume_noirq)(struct device *dev); | ||
| 279 | int (*freeze_noirq)(struct device *dev); | ||
| 280 | int (*thaw_noirq)(struct device *dev); | ||
| 281 | int (*poweroff_noirq)(struct device *dev); | ||
| 282 | int (*restore_noirq)(struct device *dev); | ||
| 283 | }; | ||
| 284 | |||
| 285 | /** | ||
| 286 | * PM_EVENT_ messages | ||
| 287 | * | ||
| 288 | * The following PM_EVENT_ messages are defined for the internal use of the PM | ||
| 289 | * core, in order to provide a mechanism allowing the high level suspend and | ||
| 290 | * hibernation code to convey the necessary information to the device PM core | ||
| 291 | * code: | ||
| 292 | * | ||
| 293 | * ON No transition. | ||
| 294 | * | ||
| 295 | * FREEZE System is going to hibernate, call ->prepare() and ->freeze() | ||
| 296 | * for all devices. | ||
| 297 | * | ||
| 298 | * SUSPEND System is going to suspend, call ->prepare() and ->suspend() | ||
| 299 | * for all devices. | ||
| 300 | * | ||
| 301 | * HIBERNATE Hibernation image has been saved, call ->prepare() and | ||
| 302 | * ->poweroff() for all devices. | ||
| 303 | * | ||
| 304 | * QUIESCE Contents of main memory are going to be restored from a (loaded) | ||
| 305 | * hibernation image, call ->prepare() and ->freeze() for all | ||
| 306 | * devices. | ||
| 307 | * | ||
| 308 | * RESUME System is resuming, call ->resume() and ->complete() for all | ||
| 309 | * devices. | ||
| 310 | * | ||
| 311 | * THAW Hibernation image has been created, call ->thaw() and | ||
| 312 | * ->complete() for all devices. | ||
| 313 | * | ||
| 314 | * RESTORE Contents of main memory have been restored from a hibernation | ||
| 315 | * image, call ->restore() and ->complete() for all devices. | ||
| 316 | * | ||
| 317 | * RECOVER Creation of a hibernation image or restoration of the main | ||
| 318 | * memory contents from a hibernation image has failed, call | ||
| 319 | * ->thaw() and ->complete() for all devices. | ||
| 320 | */ | ||
| 321 | |||
| 322 | #define PM_EVENT_ON 0x0000 | ||
| 323 | #define PM_EVENT_FREEZE 0x0001 | ||
| 324 | #define PM_EVENT_SUSPEND 0x0002 | ||
| 325 | #define PM_EVENT_HIBERNATE 0x0004 | ||
| 326 | #define PM_EVENT_QUIESCE 0x0008 | ||
| 327 | #define PM_EVENT_RESUME 0x0010 | ||
| 328 | #define PM_EVENT_THAW 0x0020 | ||
| 329 | #define PM_EVENT_RESTORE 0x0040 | ||
| 330 | #define PM_EVENT_RECOVER 0x0080 | ||
| 331 | |||
| 332 | #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) | ||
| 333 | |||
| 334 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | ||
| 335 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) | ||
| 336 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) | ||
| 337 | #define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) | ||
| 338 | #define PMSG_RESUME ((struct pm_message){ .event = PM_EVENT_RESUME, }) | ||
| 339 | #define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, }) | ||
| 340 | #define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, }) | ||
| 341 | #define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, }) | ||
| 342 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | ||
| 343 | |||
| 344 | /** | ||
| 345 | * Device power management states | ||
| 346 | * | ||
| 347 | * These state labels are used internally by the PM core to indicate the current | ||
| 348 | * status of a device with respect to the PM core operations. | ||
| 349 | * | ||
| 350 | * DPM_ON Device is regarded as operational. Set this way | ||
| 351 | * initially and when ->complete() is about to be called. | ||
| 352 | * Also set when ->prepare() fails. | ||
| 353 | * | ||
| 354 | * DPM_PREPARING Device is going to be prepared for a PM transition. Set | ||
| 355 | * when ->prepare() is about to be called. | ||
| 356 | * | ||
| 357 | * DPM_RESUMING Device is going to be resumed. Set when ->resume(), | ||
| 358 | * ->thaw(), or ->restore() is about to be called. | ||
| 359 | * | ||
| 360 | * DPM_SUSPENDING Device has been prepared for a power transition. Set | ||
| 361 | * when ->prepare() has just succeeded. | ||
| 362 | * | ||
| 363 | * DPM_OFF Device is regarded as inactive. Set immediately after | ||
| 364 | * ->suspend(), ->freeze(), or ->poweroff() has succeeded. | ||
| 365 | * Also set when ->resume()_noirq, ->thaw_noirq(), or | ||
| 366 | * ->restore_noirq() is about to be called. | ||
| 367 | * | ||
| 368 | * DPM_OFF_IRQ Device is in a "deep sleep". Set immediately after | ||
| 369 | * ->suspend_noirq(), ->freeze_noirq(), or | ||
| 370 | * ->poweroff_noirq() has just succeeded. | ||
| 371 | */ | ||
| 372 | |||
| 373 | enum dpm_state { | ||
| 374 | DPM_INVALID, | ||
| 375 | DPM_ON, | ||
| 376 | DPM_PREPARING, | ||
| 377 | DPM_RESUMING, | ||
| 378 | DPM_SUSPENDING, | ||
| 379 | DPM_OFF, | ||
| 380 | DPM_OFF_IRQ, | ||
| 381 | }; | ||
| 382 | |||
| 383 | struct dev_pm_info { | ||
| 384 | pm_message_t power_state; | ||
| 385 | unsigned can_wakeup:1; | ||
| 386 | unsigned should_wakeup:1; | ||
| 387 | enum dpm_state status; /* Owned by the PM core */ | ||
| 388 | #ifdef CONFIG_PM_SLEEP | ||
| 389 | struct list_head entry; | ||
| 390 | #endif | ||
| 391 | }; | ||
| 392 | |||
| 393 | /* | ||
| 394 | * The PM_EVENT_ messages are also used by drivers implementing the legacy | ||
| 395 | * suspend framework, based on the ->suspend() and ->resume() callbacks common | ||
| 396 | * for suspend and hibernation transitions, according to the rules below. | ||
| 397 | */ | ||
| 398 | |||
| 399 | /* Necessary, because several drivers use PM_EVENT_PRETHAW */ | ||
| 400 | #define PM_EVENT_PRETHAW PM_EVENT_QUIESCE | ||
| 401 | |||
| 402 | /* | ||
| 123 | * One transition is triggered by resume(), after a suspend() call; the | 403 | * One transition is triggered by resume(), after a suspend() call; the |
| 124 | * message is implicit: | 404 | * message is implicit: |
| 125 | * | 405 | * |
| @@ -164,35 +444,13 @@ typedef struct pm_message { | |||
| 164 | * or from system low-power states such as standby or suspend-to-RAM. | 444 | * or from system low-power states such as standby or suspend-to-RAM. |
| 165 | */ | 445 | */ |
| 166 | 446 | ||
| 167 | #define PM_EVENT_ON 0 | 447 | #ifdef CONFIG_PM_SLEEP |
| 168 | #define PM_EVENT_FREEZE 1 | 448 | extern void device_pm_lock(void); |
| 169 | #define PM_EVENT_SUSPEND 2 | 449 | extern void device_power_up(pm_message_t state); |
| 170 | #define PM_EVENT_HIBERNATE 4 | 450 | extern void device_resume(pm_message_t state); |
| 171 | #define PM_EVENT_PRETHAW 8 | ||
| 172 | |||
| 173 | #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) | ||
| 174 | |||
| 175 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | ||
| 176 | #define PMSG_PRETHAW ((struct pm_message){ .event = PM_EVENT_PRETHAW, }) | ||
| 177 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) | ||
| 178 | #define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) | ||
| 179 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | ||
| 180 | |||
| 181 | struct dev_pm_info { | ||
| 182 | pm_message_t power_state; | ||
| 183 | unsigned can_wakeup:1; | ||
| 184 | unsigned should_wakeup:1; | ||
| 185 | bool sleeping:1; /* Owned by the PM core */ | ||
| 186 | #ifdef CONFIG_PM_SLEEP | ||
| 187 | struct list_head entry; | ||
| 188 | #endif | ||
| 189 | }; | ||
| 190 | 451 | ||
| 452 | extern void device_pm_unlock(void); | ||
| 191 | extern int device_power_down(pm_message_t state); | 453 | extern int device_power_down(pm_message_t state); |
| 192 | extern void device_power_up(void); | ||
| 193 | extern void device_resume(void); | ||
| 194 | |||
| 195 | #ifdef CONFIG_PM_SLEEP | ||
| 196 | extern int device_suspend(pm_message_t state); | 454 | extern int device_suspend(pm_message_t state); |
| 197 | extern int device_prepare_suspend(pm_message_t state); | 455 | extern int device_prepare_suspend(pm_message_t state); |
| 198 | 456 | ||
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index f0d0b2cb8d20..0aae7776185e 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h | |||
| @@ -35,6 +35,11 @@ static inline void device_init_wakeup(struct device *dev, int val) | |||
| 35 | dev->power.can_wakeup = dev->power.should_wakeup = !!val; | 35 | dev->power.can_wakeup = dev->power.should_wakeup = !!val; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static inline void device_set_wakeup_capable(struct device *dev, int val) | ||
| 39 | { | ||
| 40 | dev->power.can_wakeup = !!val; | ||
| 41 | } | ||
| 42 | |||
| 38 | static inline int device_can_wakeup(struct device *dev) | 43 | static inline int device_can_wakeup(struct device *dev) |
| 39 | { | 44 | { |
| 40 | return dev->power.can_wakeup; | 45 | return dev->power.can_wakeup; |
| @@ -47,21 +52,7 @@ static inline void device_set_wakeup_enable(struct device *dev, int val) | |||
| 47 | 52 | ||
| 48 | static inline int device_may_wakeup(struct device *dev) | 53 | static inline int device_may_wakeup(struct device *dev) |
| 49 | { | 54 | { |
| 50 | return dev->power.can_wakeup & dev->power.should_wakeup; | 55 | return dev->power.can_wakeup && dev->power.should_wakeup; |
| 51 | } | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Platform hook to activate device wakeup capability, if that's not already | ||
| 55 | * handled by enable_irq_wake() etc. | ||
| 56 | * Returns zero on success, else negative errno | ||
| 57 | */ | ||
| 58 | extern int (*platform_enable_wakeup)(struct device *dev, int is_on); | ||
| 59 | |||
| 60 | static inline int call_platform_enable_wakeup(struct device *dev, int is_on) | ||
| 61 | { | ||
| 62 | if (platform_enable_wakeup) | ||
| 63 | return (*platform_enable_wakeup)(dev, is_on); | ||
| 64 | return 0; | ||
| 65 | } | 56 | } |
| 66 | 57 | ||
| 67 | #else /* !CONFIG_PM */ | 58 | #else /* !CONFIG_PM */ |
| @@ -72,6 +63,8 @@ static inline void device_init_wakeup(struct device *dev, int val) | |||
| 72 | dev->power.can_wakeup = !!val; | 63 | dev->power.can_wakeup = !!val; |
| 73 | } | 64 | } |
| 74 | 65 | ||
| 66 | static inline void device_set_wakeup_capable(struct device *dev, int val) { } | ||
| 67 | |||
| 75 | static inline int device_can_wakeup(struct device *dev) | 68 | static inline int device_can_wakeup(struct device *dev) |
| 76 | { | 69 | { |
| 77 | return dev->power.can_wakeup; | 70 | return dev->power.can_wakeup; |
| @@ -80,11 +73,6 @@ static inline int device_can_wakeup(struct device *dev) | |||
| 80 | #define device_set_wakeup_enable(dev, val) do {} while (0) | 73 | #define device_set_wakeup_enable(dev, val) do {} while (0) |
| 81 | #define device_may_wakeup(dev) 0 | 74 | #define device_may_wakeup(dev) 0 |
| 82 | 75 | ||
| 83 | static inline int call_platform_enable_wakeup(struct device *dev, int is_on) | ||
| 84 | { | ||
| 85 | return 0; | ||
| 86 | } | ||
| 87 | |||
| 88 | #endif /* !CONFIG_PM */ | 76 | #endif /* !CONFIG_PM */ |
| 89 | 77 | ||
| 90 | #endif /* _LINUX_PM_WAKEUP_H */ | 78 | #endif /* _LINUX_PM_WAKEUP_H */ |
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index a6977423baf7..e8e69159af71 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -86,6 +86,11 @@ typedef int __bitwise suspend_state_t; | |||
| 86 | * that implement @begin(), but platforms implementing @begin() should | 86 | * that implement @begin(), but platforms implementing @begin() should |
| 87 | * also provide a @end() which cleans up transitions aborted before | 87 | * also provide a @end() which cleans up transitions aborted before |
| 88 | * @enter(). | 88 | * @enter(). |
| 89 | * | ||
| 90 | * @recover: Recover the platform from a suspend failure. | ||
| 91 | * Called by the PM core if the suspending of devices fails. | ||
| 92 | * This callback is optional and should only be implemented by platforms | ||
| 93 | * which require special recovery actions in that situation. | ||
| 89 | */ | 94 | */ |
| 90 | struct platform_suspend_ops { | 95 | struct platform_suspend_ops { |
| 91 | int (*valid)(suspend_state_t state); | 96 | int (*valid)(suspend_state_t state); |
| @@ -94,6 +99,7 @@ struct platform_suspend_ops { | |||
| 94 | int (*enter)(suspend_state_t state); | 99 | int (*enter)(suspend_state_t state); |
| 95 | void (*finish)(void); | 100 | void (*finish)(void); |
| 96 | void (*end)(void); | 101 | void (*end)(void); |
| 102 | void (*recover)(void); | ||
| 97 | }; | 103 | }; |
| 98 | 104 | ||
| 99 | #ifdef CONFIG_SUSPEND | 105 | #ifdef CONFIG_SUSPEND |
| @@ -149,7 +155,7 @@ extern void mark_free_pages(struct zone *zone); | |||
| 149 | * The methods in this structure allow a platform to carry out special | 155 | * The methods in this structure allow a platform to carry out special |
| 150 | * operations required by it during a hibernation transition. | 156 | * operations required by it during a hibernation transition. |
| 151 | * | 157 | * |
| 152 | * All the methods below must be implemented. | 158 | * All the methods below, except for @recover(), must be implemented. |
| 153 | * | 159 | * |
| 154 | * @begin: Tell the platform driver that we're starting hibernation. | 160 | * @begin: Tell the platform driver that we're starting hibernation. |
| 155 | * Called right after shrinking memory and before freezing devices. | 161 | * Called right after shrinking memory and before freezing devices. |
| @@ -189,6 +195,11 @@ extern void mark_free_pages(struct zone *zone); | |||
| 189 | * @restore_cleanup: Clean up after a failing image restoration. | 195 | * @restore_cleanup: Clean up after a failing image restoration. |
| 190 | * Called right after the nonboot CPUs have been enabled and before | 196 | * Called right after the nonboot CPUs have been enabled and before |
| 191 | * thawing devices (runs with IRQs on). | 197 | * thawing devices (runs with IRQs on). |
| 198 | * | ||
| 199 | * @recover: Recover the platform from a failure to suspend devices. | ||
| 200 | * Called by the PM core if the suspending of devices during hibernation | ||
| 201 | * fails. This callback is optional and should only be implemented by | ||
| 202 | * platforms which require special recovery actions in that situation. | ||
| 192 | */ | 203 | */ |
| 193 | struct platform_hibernation_ops { | 204 | struct platform_hibernation_ops { |
| 194 | int (*begin)(void); | 205 | int (*begin)(void); |
| @@ -200,6 +211,7 @@ struct platform_hibernation_ops { | |||
| 200 | void (*leave)(void); | 211 | void (*leave)(void); |
| 201 | int (*pre_restore)(void); | 212 | int (*pre_restore)(void); |
| 202 | void (*restore_cleanup)(void); | 213 | void (*restore_cleanup)(void); |
| 214 | void (*recover)(void); | ||
| 203 | }; | 215 | }; |
| 204 | 216 | ||
| 205 | #ifdef CONFIG_HIBERNATION | 217 | #ifdef CONFIG_HIBERNATION |
