2 * linux/kernel/irq/pm.c
4 * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
6 * This file contains power management functions related to interrupts.
10 #include <linux/module.h>
11 #include <linux/interrupt.h>
12 #include <linux/syscore_ops.h>
14 #include "internals.h"
17 * suspend_device_irqs - disable all currently enabled interrupt lines
19 * During system-wide suspend or hibernation device drivers need to be prevented
20 * from receiving interrupts and this function is provided for this purpose.
21 * It marks all interrupt lines in use, except for the timer ones, as disabled
22 * and sets the IRQS_SUSPENDED flag for each of them.
24 void suspend_device_irqs(void)
26 struct irq_desc
*desc
;
29 for_each_irq_desc(irq
, desc
) {
32 raw_spin_lock_irqsave(&desc
->lock
, flags
);
33 __disable_irq(desc
, irq
, true);
34 raw_spin_unlock_irqrestore(&desc
->lock
, flags
);
37 for_each_irq_desc(irq
, desc
)
38 if (desc
->istate
& IRQS_SUSPENDED
)
41 EXPORT_SYMBOL_GPL(suspend_device_irqs
);
43 static void resume_irqs(bool want_early
)
45 struct irq_desc
*desc
;
48 for_each_irq_desc(irq
, desc
) {
50 bool is_early
= desc
->action
&&
51 desc
->action
->flags
& IRQF_EARLY_RESUME
;
53 if (is_early
!= want_early
)
56 raw_spin_lock_irqsave(&desc
->lock
, flags
);
57 __enable_irq(desc
, irq
, true);
58 raw_spin_unlock_irqrestore(&desc
->lock
, flags
);
63 * irq_pm_syscore_ops - enable interrupt lines early
65 * Enable all interrupt lines with %IRQF_EARLY_RESUME set.
67 static void irq_pm_syscore_resume(void)
72 static struct syscore_ops irq_pm_syscore_ops
= {
73 .resume
= irq_pm_syscore_resume
,
76 static int __init
irq_pm_init_ops(void)
78 register_syscore_ops(&irq_pm_syscore_ops
);
82 device_initcall(irq_pm_init_ops
);
85 * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
87 * Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
88 * disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
89 * set as well as those with %IRQF_FORCE_RESUME.
91 void resume_device_irqs(void)
95 EXPORT_SYMBOL_GPL(resume_device_irqs
);
98 * check_wakeup_irqs - check if any wake-up interrupts are pending
100 int check_wakeup_irqs(void)
102 struct irq_desc
*desc
;
105 for_each_irq_desc(irq
, desc
) {
106 if (irqd_is_wakeup_set(&desc
->irq_data
)) {
107 if (desc
->istate
& IRQS_PENDING
)
112 * Check the non wakeup interrupts whether they need
113 * to be masked before finally going into suspend
114 * state. That's for hardware which has no wakeup
115 * source configuration facility. The chip
116 * implementation indicates that with
117 * IRQCHIP_MASK_ON_SUSPEND.
119 if (desc
->istate
& IRQS_SUSPENDED
&&
120 irq_desc_get_chip(desc
)->flags
& IRQCHIP_MASK_ON_SUSPEND
)