initial commit with v2.6.32.60
[linux-2.6.32.60-moxart.git] / kernel / irq / pm.c
blobb1fc3ddaa82c36ec8c19c8be865f61e45261be00
1 /*
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.
7 */
9 #include <linux/irq.h>
10 #include <linux/module.h>
11 #include <linux/interrupt.h>
13 #include "internals.h"
15 /**
16 * suspend_device_irqs - disable all currently enabled interrupt lines
18 * During system-wide suspend or hibernation device drivers need to be prevented
19 * from receiving interrupts and this function is provided for this purpose.
20 * It marks all interrupt lines in use, except for the timer ones, as disabled
21 * and sets the IRQ_SUSPENDED flag for each of them.
23 void suspend_device_irqs(void)
25 struct irq_desc *desc;
26 int irq;
28 for_each_irq_desc(irq, desc) {
29 unsigned long flags;
31 spin_lock_irqsave(&desc->lock, flags);
32 __disable_irq(desc, irq, true);
33 spin_unlock_irqrestore(&desc->lock, flags);
36 for_each_irq_desc(irq, desc)
37 if (desc->status & IRQ_SUSPENDED)
38 synchronize_irq(irq);
40 EXPORT_SYMBOL_GPL(suspend_device_irqs);
42 static void resume_irqs(bool want_early)
44 struct irq_desc *desc;
45 int irq;
47 for_each_irq_desc(irq, desc) {
48 unsigned long flags;
49 bool is_early = desc->action &&
50 desc->action->flags & IRQF_EARLY_RESUME;
52 if (is_early != want_early)
53 continue;
55 spin_lock_irqsave(&desc->lock, flags);
56 __enable_irq(desc, irq, true);
57 spin_unlock_irqrestore(&desc->lock, flags);
61 /**
62 * irq_pm_syscore_ops - enable interrupt lines early
64 * Enable all interrupt lines with %IRQF_EARLY_RESUME set.
66 void irq_pm_syscore_resume(void)
68 resume_irqs(true);
71 /**
72 * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
74 * Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
75 * disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
76 * set as well as those with %IRQF_FORCE_RESUME.
78 void resume_device_irqs(void)
80 resume_irqs(false);
82 EXPORT_SYMBOL_GPL(resume_device_irqs);
84 /**
85 * check_wakeup_irqs - check if any wake-up interrupts are pending
87 int check_wakeup_irqs(void)
89 struct irq_desc *desc;
90 int irq;
92 for_each_irq_desc(irq, desc)
93 if ((desc->status & IRQ_WAKEUP) && (desc->status & IRQ_PENDING))
94 return -EBUSY;
96 return 0;