Energy-saving interruption wake-up in Linux

Source: Internet
Author: User

Energy-saving interruption wake-up in Linux

In Linux, energy saving is enabled. If mem is enabled, the system can be awakened by interruption. In the energy-saving mode, whether to support the interrupt wake-up system is described in this article.

For example, in the suspend method of the touch screen, if enable_irq_wake is called, The system sleep after the touch screen interruption is enabled. In the resume method, disable_irq_wake is called to disable the system sleep.

Enable_irq_wake

This function can be considered in two aspects. 1. You must set the support for this interrupt before entering the suspend. 2. Mark the corresponding interrupt number in the interrupt wakeup table and enable the feature.

Enable_irq_wake calls the set_irq_wake (IRQ, 1) function to trace set_irq_wake. this function first obtains the Interrupt Descriptor to prevent all interruptions. Call set_irq_wake_real to set the interrupt (step 1), and then set desc-> Status | = irq_wakeup (step 2 ), before entering suspend, this status checks whether the flag of status has irq_wakeup to determine whether the sleep is interrupted.

Step 1: set_irq_wake_real. The function is as follows,

318 static int set_irq_wake_real(unsigned int irq, unsigned int on)
319 {
320         struct irq_desc *desc = irq_to_desc(irq);
321         int ret = -ENXIO;
322
323         if (desc->chip->set_wake)
324                 ret = desc->chip->set_wake(irq, on);
325
326         return ret;
327 }
This function actually calls the set_wake operation to interrupt the related chip.
For mx25 of Freescale (related to systems), in machine_start, different systems have different machine_desc through machine_desc. Configuration interruption occurs when set_irq_handler is called, set_irq_chip is used to set the chip operation. set_irq_chip is actually the chip pointer corresponding to different interrupt numbers pointing to mxc_avic_chip.
    static struct irq_chip mxc_avic_chip = {
    .ack = mxc_mask_irq,
    .mask = mxc_mask_irq,
    .unmask = mxc_unmask_irq,
    .set_wake = mxc_set_wake_irq,
};
All chip operations, including startup, enable, and disable, are encapsulated on the basis of the above method, which is related to register configuration.
The set_wake method is actually a register configuration operation that allows the mxc series to interrupt during suspend.
   
Step 2: desc-> Status | = irq_wakeup,
Irq_wakeup involves two parts,
(1) check_wakeup_irqs, which is called by sysdev_suspend. When preparing to enter suspend, sysdev_suspend is called. In this function, check_wakeup_irqs is called to check whether the interrupt set to irq_wakeup is still in the pending state, that is, the interrupt is not aborted. If yes, the access to suspend is prohibited.
(2) for different systems, the operations that allow interruption and wake-up in the energy-saving configuration are different. Therefore, platform_suspend_ops is provided in Linux to differentiate different methods for unified operations.
In late_initcall (mx25_pm_init), call the suspend_set_ops method to set platform_suspend_ops to set ops.
struct platform_suspend_ops mx25_suspend_ops = {
    .begin = mx25_pm_begin,
    .valid = mx25_pm_valid,
    .prepare = mx25_suspend_prepare,
    .enter = mx25_suspend_enter,
    .finish = mx25_suspend_finish,
};
After sysdev_suspend is successful, the enter method of mx25 is called, that is, mx25_suspend_enter. This function finally calls mxc_cpu_lp_set ("mem" Mode suspend ). In this function,
    if ((desc->status & IRQ_WAKEUP) != 0)
                 lpimr &= ~(1 << (i - 32));
Configure the lpimr register, which is the interrupt setting that allows sleep interruption wake-up.
      
The wake-up Process of sleep interruption is like this, while disable_irq_wakeup and enable_irq_wakeup are just similar operations.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.