《嵌入式 Linux 系统的电源管理》讲义
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
远见品质
Device Power Mawk.baidu.comagement (DPM)
Device PM
Deals with the process of placing individual devices into low-power states while the system is running. Invoked explicitly on devices, or may happen automatically after a device has been idle for a set of amount of time.
远见品质
Hardware components
远见品质
Hardware components
Power Controlled Components include:
Intel PXA Xscale CPU, real-time clock, DRAM, Flash, LCD, front light, UART, audio codec, touchscreen, keys and power button,etc.
远见品质
Kernel PM_Subsystem
远见品质
Kernel PM_Subsystem
What we will talk Covers the two
broad areas of power management:
System Power Management (SPM) Device Power Management (DPM) And more……
i2c_adapter_driver = {
.name = "i2c_adapter", .bus = &i2c_bus_type, .probe = i2c_device_probe, .remove = i2c_device_remove,
}; static struct class i2c_adapter_class = {
远见品质
Device Power Management
New driver model (LDM) in the 2.6
kernel, which provides a hierarchical representation of the devices in the system. Device power states are described as 'D' states, and consist of states D0-D3, inclusive. (Influenced by ACPI Spec)
远见品质
Handheld Energy Budgets
远见品质
PM Theory
OS PM focuses on active power
consumption Modulate methods:
Voltage/clock modulate Clock selected Power supply selected
} dev_power_t; enum {
SUSPEND_SAVE_STATE, SUSPEND_POWER_DOWN,
}; enum {
RESUME_POWER_ON, RESUME_RESTORE_STATE,
};
远见品质
Power Dependencies
Two steps to suspend device
} struct bus_type i2c_bus_type = {
.name = "i2c", .match = i2c_device_match, .suspend = i2c_bus_suspend, .resume = i2c_bus_resume,
}; static int i2c_bus_suspend(struct device* dev, u32 state){
The Xscale PXA27X CPU supports
several power-saving features.
远见品质
Xscale CPU PM Features
PXA27X PM features, including frequency
scaling and CPU core voltage scaling. And several modes of operation:
The success's road
CE Linux PM
远见品质
What We’ll Talk
PM Theory and Hardware Support 2.6 kernel PM_Subsystem
CELF PM Specification Appendix
Current PM Implementation
one to save state another to power the device down
Conversely,
one call is made to the resume() method to power the device up another to restore device state.
Run mode All power supplies enabled, all clocks running and every on-chip resource is functional. Idle mode CPU clock stopped. other on-chip resources are active. When an interrupt occurs, the CPU is reactivated. Sleep mode Power is switched off to the majority of the processor. Some preprogrammed event, such as a power button press, wakes up the CPU from this mode
.name = "i2c-adapter", .release = &i2c_adapter_class_dev_release,
};
远见品质
Register PM handlers
static struct device_driver i2c_pxa_driver ={
.name .bus .probe .remove .suspend .resume = "pxa2xx-i2c", = &platform_bus_type, = i2c_pxa_probe, = i2c_pxa_remove, = i2c_pxa_controller_suspend, = i2c_pxa_controller_resume,
if (dev->driver && dev->driver->suspend) rc = dev->driver->suspend(dev,state,0);
} //Device Specified driver, explain later
远见品质
Register PM handlers
static struct device_driver
远见品质
System Power Management (SPM)
System PM
The entire system is placed into a low-power state. running system is saved before powered down, and restored once the system has regained power. Automatically enter a low-power state after it has been idle for some amount of time, or when some critical state has been reached. Also policy decisions that are up to the user to configure and require some global mechanism for controlling.
(n can be “0~3”)
When n == 0 (resume steps similar)
state_store() [drivers/base/power/sysfs.c] -> dpm_runtime_suspend() [drivers/base/power/runtime.c] -> suspend_device() [drivers/base/power/suspend.c] -> • call suspend handler of the bus which the specified device belongs to . -> • call suspend handler for the specified device
#ifdef CONFIG_PM i2c_pxa_wait_bus_not_busy(); i2c_pxa_stop(); #endif return 0;
}
远见品质
Internal Sequence of Device PM
echo n > /sys/bus/i2c/devices/1-1/power/state
远见品质
Register PM handlers
static int __init i2c_init(void){ retval = bus_register(&i2c_bus_type); retval = driver_register(&i2c_adapter_driver); return class_register(&i2c_adapter_class);
all children devices must be powered down before
their parent can be powered down. Conversely, the parent device must be powered up before any children devices may be accessed. Only when a device's depend count (struct device_pm::depend field.)is 0 may it be powered down. int device_pm_get/put(struct device *);
远见品质
Device PM Data Structs
typedef enum {
DEVICE_PM_ON, DEVICE_PM_INT1, DEVICE_PM_INT2, DEVICE_PM_OFF, DEVICE_PM_UNKNOWN, //Device’s initial power state
}; static int __init i2c_adap_pxa_init(void){
return driver_register(&i2c_pxa_driver);
}
远见品质
Register PM handlers
static int
i2c_pxa_controller_suspend(struct device *dev, u32 state, u32 level){
远见品质
Device PM Data Structs
A device's PM infor stored in struct
device_pm, struct device contains a device_pm object. struct device_pm
{
dev_power_t u8 atomic_t atomic_t struct kobject }; power_state; * saved_state; depend; disable; kobj;