Linux Power Management Series (i)

Source: Internet
Author: User
Tags apm linux sleep

This series will step through the knowledge of Linux power management, related to common power management mechanisms, Linux power management mechanisms, the relevant interfaces for power management in Linux drivers, and the analysis of Linux Power Management architecture documentation in the kernel documentation. The following will be introduced to the relevant content, as far as possible to be easy to understand, clear-organized.

Electricity is now the infrastructure of society, it lights the whole world. With the prevalence of mobile internet, a variety of intelligent devices, a variety of CPUs and large screens, are constantly torturing the cell phone battery, a variety of exciting hand-travel, but also in the crushing of smart phone power. Battery technology has developed for many years, before the discovery of new energy storage materials, considering the overall weight and the acceptability of heat, cell phone battery power is not a big breakthrough. We all know that Android is based on the development of Linux, to improve the future of smart device life, on the one hand, the need to improve battery capacity, on the other hand, it is necessary to stand in the system perspective, like process scheduling, scheduling "power", in order to meet a certain load requirements, minimize power consumption, delay equipment use time. This article will go from the bottom up, in order to introduce the power management concept in the Android smartphone design and implementation.

The object of power management is a variety of hardware device drivers, system framework of various application scheduling, etc. (this is my initial understanding, what is wrong, please advise). If the daily life as an example of analogy, an adult, a day of meals, you can work full-speed, eating like a charge, eat, and then work, the body of glucose and other energy storage materials like batteries, in a certain energy supply, the more the job, boss the more happy. Only when the horse needs to run, let it eat grass, which is the core idea of power management, it is mainly two points

1. Flexible closure of temporarily unused parts

2. When you need to re-use those parts that have been closed, there is no long wait, and the switching state does not consume too much energy.

Power management Using the premise is to control the hardware support node function, can be temporarily shut down by the command, the operating system needs to support power management,

Common power management mechanisms

In the x86 machine, there are two methods of power management, APM (Advanced Power Management, premium Management), and ACPI (Advanced Configuration and Power Interface, high profile and Power interface), These two standards cannot be allowed on Linux at the same time, and Linux runs ACPI by default. It is important to note that APM and ACPI are conflicting two modules, and users can only load one of them at a time

APM allows the device to be in a suspend (suspended state) or standby (standby state) and detects battery capacity, using the prerequisite for BIOS and Linux core support, and has APMD (APM daemon) and APM applications. It is a BIOS-based power management standard that provides CPU and device power management capabilities, defects are over-reliance on the BIOS, compatibility with old and new bios, and inability to determine whether power management commands are initiated by the user or by the BIOS, are not suitable for the development of new hardware, and in order to compensate for the shortcomings of APM, The ACPI specification has been proposed.

ACPI primarily converts the primary performer of power management from the BIOS to the operating system, which provides greater flexibility and scalability. ACPI, in addition to the functionality of APM, can control peripherals individually, with finer-grained node control. For applications that have acpid and pmtools, download the link here

ACPI mainly supports three node modes:

1. Standby (S1 mode), Standby mode: Display power off, just the host power off, at this time, knock any key can restore the original state

2. Suspend to RAM (STR,S3 mode), suspend to memory, the system stores the current information in memory, only a few key components such as CPU and memory, press the Power key can restore the original state

3. Suspend to disk (STD,S4 mode), suspend to the hard disk, the system in the shutdown before the current data in memory, and then write the memory to the swap partition on the hard disk, the next time the user press the power on key to open, the computer directly from the hard disk read data, restore the original state.

ACPI has six types of working states:

S0--> All devices fully open

S1--> only shuts down the CPU (interrupt enable)

S2--> shutting down the CPU and bus clocks

S5--> shut down the machine

Under the/sys/power directory

Enter for the mode, only to state the status of the flag bit to enter it.

Because there is no current on the low-power projects, so can only refer to the standard Linux hibernation and wake-up mechanism analysis (a ~ four) to understand, and other relevant opportunities later, to grasp the depth to understand.

struct Platform_suspend_ops {

Int (*valid) (suspend_state_t state);

Int (*begin) (suspend_state_t state);

Int (*prepare) (void);

Int (*prepare_late) (void);

Int (*enter) (suspend_state_t state);

void (*wake) (void);

void (*finish) (void);

void (*end) (void);

void (*recover) (void);

};

The execution of a dormant wake-up process, in turn, is begin->prepare->prepare_late->enter->wake->finish->end.

Sleep stays in the Enter function, wake and hibernate are inverse processes.

At the Linux driver level, the Linux power management subsystem has encapsulated a unified interface, all types of device drivers only need to implement the relevant interface functions, the operating system when it thinks it is appropriate to notify the driver to complete these operations. On the basis of general device drivers, using Pm_register and Pm_unregister for registration and logoff, using pm_access for sleep viability detection, using the Pm_callback function to perform status notification after the callback response, using Pm_dev_idle, Used to detect the device idle state mechanism.

Not familiar with Android, just know it in the standard Linux sleep wake mechanism, added early suspend and late resume two modes, specific analysis to follow related articles.

Reference: Advanced applications for Linux ACPI power management

Linux Power Management-Overall architecture

5 Http://www.acpi.info:ACPI's official website, which provides free access to the latest ACPI specifications.

The ACPI Project Web site is supported under 6 http://acpi.sourceforge.net:Linux. The ACPI version in the official Linux kernel is actually lagging far behind the latest version, since the addition of any new features in the Linux stable version is very cautious. You can download the latest ACPI patches from here.

7 Linux Core source code directory: documentation/power/, there are some developers wrote about power management on Linux implementation of the document.

Linux Power Management Series (i)

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.