Lines Matching +full:wake +full:- +full:up

1 // SPDX-License-Identifier: GPL-2.0
13 * dev_pm_attach_wake_irq - Attach device interrupt as a wake IRQ
15 * @wirq: Wake irq specific data
17 * Internal function to attach a dedicated wake-up interrupt as a wake IRQ.
24 return -EINVAL; in dev_pm_attach_wake_irq()
26 spin_lock_irqsave(&dev->power.lock, flags); in dev_pm_attach_wake_irq()
27 if (dev_WARN_ONCE(dev, dev->power.wakeirq, in dev_pm_attach_wake_irq()
28 "wake irq already initialized\n")) { in dev_pm_attach_wake_irq()
29 spin_unlock_irqrestore(&dev->power.lock, flags); in dev_pm_attach_wake_irq()
30 return -EEXIST; in dev_pm_attach_wake_irq()
33 dev->power.wakeirq = wirq; in dev_pm_attach_wake_irq()
36 spin_unlock_irqrestore(&dev->power.lock, flags); in dev_pm_attach_wake_irq()
41 * dev_pm_set_wake_irq - Attach device IO interrupt as wake IRQ
45 * Attach a device IO interrupt as a wake IRQ. The wake IRQ gets
46 * automatically configured for wake-up from suspend based
56 return -EINVAL; in dev_pm_set_wake_irq()
60 return -ENOMEM; in dev_pm_set_wake_irq()
62 wirq->dev = dev; in dev_pm_set_wake_irq()
63 wirq->irq = irq; in dev_pm_set_wake_irq()
74 * dev_pm_clear_wake_irq - Detach a device IO interrupt wake IRQ
77 * Detach a device wake IRQ and free resources.
81 * a wake IRQ configured. This avoid adding wake IRQ specific
86 struct wake_irq *wirq = dev->power.wakeirq; in dev_pm_clear_wake_irq()
92 spin_lock_irqsave(&dev->power.lock, flags); in dev_pm_clear_wake_irq()
94 dev->power.wakeirq = NULL; in dev_pm_clear_wake_irq()
95 spin_unlock_irqrestore(&dev->power.lock, flags); in dev_pm_clear_wake_irq()
97 if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED) { in dev_pm_clear_wake_irq()
98 free_irq(wirq->irq, wirq); in dev_pm_clear_wake_irq()
99 wirq->status &= ~WAKE_IRQ_DEDICATED_MASK; in dev_pm_clear_wake_irq()
101 kfree(wirq->name); in dev_pm_clear_wake_irq()
107 * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts
108 * @irq: Device specific dedicated wake-up interrupt
109 * @_wirq: Wake IRQ data
111 * Some devices have a separate wake-up interrupt in addition to the
112 * device IO interrupt. The wake-up interrupt signals that a device
113 * should be woken up from it's idle state. This handler uses device
114 * specific pm_runtime functions to wake the device, and then it's
115 * up to the device to do whatever it needs to. Note that as the
116 * device may need to restore context and start up regulators, we
120 * We assume that the wake-up interrupt just needs to wake-up the
131 pm_wakeup_event(wirq->dev, 0); in handle_threaded_wake_irq()
137 res = pm_runtime_resume(wirq->dev); in handle_threaded_wake_irq()
139 dev_warn(wirq->dev, in handle_threaded_wake_irq()
140 "wake IRQ with no resume: %i\n", res); in handle_threaded_wake_irq()
151 return -EINVAL; in __dev_pm_set_dedicated_wake_irq()
155 return -ENOMEM; in __dev_pm_set_dedicated_wake_irq()
157 wirq->name = kasprintf(GFP_KERNEL, "%s:wakeup", dev_name(dev)); in __dev_pm_set_dedicated_wake_irq()
158 if (!wirq->name) { in __dev_pm_set_dedicated_wake_irq()
159 err = -ENOMEM; in __dev_pm_set_dedicated_wake_irq()
163 wirq->dev = dev; in __dev_pm_set_dedicated_wake_irq()
164 wirq->irq = irq; in __dev_pm_set_dedicated_wake_irq()
170 * Consumer device may need to power up and restore state in __dev_pm_set_dedicated_wake_irq()
175 wirq->name, wirq); in __dev_pm_set_dedicated_wake_irq()
183 wirq->status = WAKE_IRQ_DEDICATED_ALLOCATED | flag; in __dev_pm_set_dedicated_wake_irq()
190 kfree(wirq->name); in __dev_pm_set_dedicated_wake_irq()
198 * dev_pm_set_dedicated_wake_irq - Request a dedicated wake-up interrupt
200 * @irq: Device wake-up interrupt
202 * Unless your hardware has separate wake-up interrupts in addition
205 * Sets up a threaded interrupt handler for a device that has
206 * a dedicated wake-up interrupt in addition to the device IO
216 * dev_pm_set_dedicated_wake_irq_reverse - Request a dedicated wake-up interrupt
219 * @irq: Device wake-up interrupt
221 * Unless your hardware has separate wake-up interrupts in addition
224 * Sets up a threaded interrupt handler for a device that has a dedicated
225 * wake-up interrupt in addition to the device IO interrupt. It sets
227 * to enable dedicated wake-up interrupt after running the runtime suspend
237 * dev_pm_enable_wake_irq_check - Checks and enables wake-up interrupt
239 * @can_change_status: Can change wake-up interrupt status
241 * Enables wakeirq conditionally. We need to enable wake-up interrupt
244 * otherwise try to disable already disabled wakeirq. The wake-up interrupt
248 * Caller must hold &dev->power.lock to change wirq->status
253 struct wake_irq *wirq = dev->power.wakeirq; in dev_pm_enable_wake_irq_check()
255 if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK)) in dev_pm_enable_wake_irq_check()
258 if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) { in dev_pm_enable_wake_irq_check()
261 wirq->status |= WAKE_IRQ_DEDICATED_MANAGED; in dev_pm_enable_wake_irq_check()
268 if (!can_change_status || !(wirq->status & WAKE_IRQ_DEDICATED_REVERSE)) { in dev_pm_enable_wake_irq_check()
269 enable_irq(wirq->irq); in dev_pm_enable_wake_irq_check()
270 wirq->status |= WAKE_IRQ_DEDICATED_ENABLED; in dev_pm_enable_wake_irq_check()
275 * dev_pm_disable_wake_irq_check - Checks and disables wake-up interrupt
279 * Disables wake-up interrupt conditionally based on status.
284 struct wake_irq *wirq = dev->power.wakeirq; in dev_pm_disable_wake_irq_check()
286 if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK)) in dev_pm_disable_wake_irq_check()
289 if (cond_disable && (wirq->status & WAKE_IRQ_DEDICATED_REVERSE)) in dev_pm_disable_wake_irq_check()
292 if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED) { in dev_pm_disable_wake_irq_check()
293 wirq->status &= ~WAKE_IRQ_DEDICATED_ENABLED; in dev_pm_disable_wake_irq_check()
294 disable_irq_nosync(wirq->irq); in dev_pm_disable_wake_irq_check()
299 * dev_pm_enable_wake_irq_complete - enable wake IRQ not enabled before
300 * @dev: Device using the wake IRQ
302 * Enable wake IRQ conditionally based on status, mainly used if want to
303 * enable wake IRQ after running ->runtime_suspend() which depends on
310 struct wake_irq *wirq = dev->power.wakeirq; in dev_pm_enable_wake_irq_complete()
312 if (!wirq || !(wirq->status & WAKE_IRQ_DEDICATED_MASK)) in dev_pm_enable_wake_irq_complete()
315 if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED && in dev_pm_enable_wake_irq_complete()
316 wirq->status & WAKE_IRQ_DEDICATED_REVERSE) { in dev_pm_enable_wake_irq_complete()
317 enable_irq(wirq->irq); in dev_pm_enable_wake_irq_complete()
318 wirq->status |= WAKE_IRQ_DEDICATED_ENABLED; in dev_pm_enable_wake_irq_complete()
323 * dev_pm_arm_wake_irq - Arm device wake-up
324 * @wirq: Device wake-up interrupt
326 * Sets up the wake-up event conditionally based on the
334 if (device_may_wakeup(wirq->dev)) { in dev_pm_arm_wake_irq()
335 if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED && in dev_pm_arm_wake_irq()
336 !(wirq->status & WAKE_IRQ_DEDICATED_ENABLED)) in dev_pm_arm_wake_irq()
337 enable_irq(wirq->irq); in dev_pm_arm_wake_irq()
339 enable_irq_wake(wirq->irq); in dev_pm_arm_wake_irq()
344 * dev_pm_disarm_wake_irq - Disarm device wake-up
345 * @wirq: Device wake-up interrupt
347 * Clears up the wake-up event conditionally based on the
355 if (device_may_wakeup(wirq->dev)) { in dev_pm_disarm_wake_irq()
356 disable_irq_wake(wirq->irq); in dev_pm_disarm_wake_irq()
358 if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED && in dev_pm_disarm_wake_irq()
359 !(wirq->status & WAKE_IRQ_DEDICATED_ENABLED)) in dev_pm_disarm_wake_irq()
360 disable_irq_nosync(wirq->irq); in dev_pm_disarm_wake_irq()