^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This file contains power management functions related to interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/suspend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/syscore_ops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "internals.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) bool irq_pm_check_wakeup(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) if (irqd_is_wakeup_armed(&desc->irq_data)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) irqd_clear(&desc->irq_data, IRQD_WAKEUP_ARMED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) desc->istate |= IRQS_SUSPENDED | IRQS_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) desc->depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) irq_disable(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) pm_system_irq_wakeup(irq_desc_get_irq(desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * Called from __setup_irq() with desc->lock held after @action has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * been installed in the action chain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) desc->nr_actions++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (action->flags & IRQF_FORCE_RESUME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) desc->force_resume_depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) WARN_ON_ONCE(desc->force_resume_depth &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) desc->force_resume_depth != desc->nr_actions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (action->flags & IRQF_NO_SUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) desc->no_suspend_depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) else if (action->flags & IRQF_COND_SUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) desc->cond_suspend_depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) WARN_ON_ONCE(desc->no_suspend_depth &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) (desc->no_suspend_depth +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) desc->cond_suspend_depth) != desc->nr_actions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Called from __free_irq() with desc->lock held after @action has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * been removed from the action chain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) desc->nr_actions--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (action->flags & IRQF_FORCE_RESUME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) desc->force_resume_depth--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (action->flags & IRQF_NO_SUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) desc->no_suspend_depth--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) else if (action->flags & IRQF_COND_SUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) desc->cond_suspend_depth--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static bool suspend_device_irq(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned long chipflags = irq_desc_get_chip(desc)->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct irq_data *irqd = &desc->irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (!desc->action || irq_desc_is_chained(desc) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) desc->no_suspend_depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (irqd_is_wakeup_set(irqd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) irqd_set(irqd, IRQD_WAKEUP_ARMED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if ((chipflags & IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) irqd_irq_disabled(irqd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * Interrupt marked for wakeup is in disabled state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * Enable interrupt here to unmask/enable in irqchip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * to be able to resume with such interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __enable_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) irqd_set(irqd, IRQD_IRQ_ENABLED_ON_SUSPEND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * We return true here to force the caller to issue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * synchronize_irq(). We need to make sure that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * IRQD_WAKEUP_ARMED is visible before we return from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * suspend_device_irqs().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) desc->istate |= IRQS_SUSPENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) __disable_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * Hardware which has no wakeup source configuration facility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * requires that the non wakeup interrupts are masked at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * chip level. The chip implementation indicates that with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * IRQCHIP_MASK_ON_SUSPEND.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (chipflags & IRQCHIP_MASK_ON_SUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) mask_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * suspend_device_irqs - disable all currently enabled interrupt lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * During system-wide suspend or hibernation device drivers need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * prevented from receiving interrupts and this function is provided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * for this purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * So we disable all interrupts and mark them IRQS_SUSPENDED except
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * for those which are unused, those which are marked as not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * suspendable via an interrupt request with the flag IRQF_NO_SUSPEND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * set and those which are marked as active wakeup sources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * The active wakeup sources are handled by the flow handler entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * code which checks for the IRQD_WAKEUP_ARMED flag, suspends the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * interrupt and notifies the pm core about the wakeup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void suspend_device_irqs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct irq_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) for_each_irq_desc(irq, desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) bool sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (irq_settings_is_nested_thread(desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) raw_spin_lock_irqsave(&desc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) sync = suspend_device_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) raw_spin_unlock_irqrestore(&desc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (sync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) synchronize_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) EXPORT_SYMBOL_GPL(suspend_device_irqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static void resume_irq(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct irq_data *irqd = &desc->irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) irqd_clear(irqd, IRQD_WAKEUP_ARMED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (irqd_is_enabled_on_suspend(irqd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * Interrupt marked for wakeup was enabled during suspend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * entry. Disable such interrupts to restore them back to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * original state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) __disable_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) irqd_clear(irqd, IRQD_IRQ_ENABLED_ON_SUSPEND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (desc->istate & IRQS_SUSPENDED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) goto resume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* Force resume the interrupt? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (!desc->force_resume_depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Pretend that it got disabled ! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) desc->depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) irq_state_set_disabled(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) irq_state_set_masked(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) resume:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) desc->istate &= ~IRQS_SUSPENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) __enable_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void resume_irqs(bool want_early)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct irq_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) for_each_irq_desc(irq, desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) bool is_early = desc->action &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) desc->action->flags & IRQF_EARLY_RESUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!is_early && want_early)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (irq_settings_is_nested_thread(desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) raw_spin_lock_irqsave(&desc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) resume_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) raw_spin_unlock_irqrestore(&desc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * rearm_wake_irq - rearm a wakeup interrupt line after signaling wakeup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * @irq: Interrupt to rearm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) void rearm_wake_irq(unsigned int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (!desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (!(desc->istate & IRQS_SUSPENDED) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) !irqd_is_wakeup_set(&desc->irq_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) desc->istate &= ~IRQS_SUSPENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) __enable_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) irq_put_desc_busunlock(desc, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * irq_pm_syscore_ops - enable interrupt lines early
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * Enable all interrupt lines with %IRQF_EARLY_RESUME set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static void irq_pm_syscore_resume(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) resume_irqs(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static struct syscore_ops irq_pm_syscore_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .resume = irq_pm_syscore_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static int __init irq_pm_init_ops(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) register_syscore_ops(&irq_pm_syscore_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) device_initcall(irq_pm_init_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * resume_device_irqs - enable interrupt lines disabled by suspend_device_irqs()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * Enable all non-%IRQF_EARLY_RESUME interrupt lines previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * disabled by suspend_device_irqs() that have the IRQS_SUSPENDED flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * set as well as those with %IRQF_FORCE_RESUME.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) void resume_device_irqs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) resume_irqs(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) EXPORT_SYMBOL_GPL(resume_device_irqs);