linux dpm机制分析(下)【转】
转自:http://blog.csdn.net/lixiaojie1012/article/details/23707901
1 设备注册到dpm_list路径
(Platform_device->device->device_driver指向platform_driver->driver)
2 低功耗接口
dpm_suspend_start():调用注册到dpm_list的设备的回调函数,执行睡眠前的准备和保存工作;
dpm_suspend_end():执行suspend_late和suspend_noirq设备的回调函数,进行睡眠前的准备工作。
睡眠时,设备在链表中的转移:
dpm_list--->dpm_prepared_list-->dpm_suspended_list---->
dpm_late_early_list--->dpm_noirq_list
Dpm_resume_start():执行设备的resume_noirq和resume_early回调,恢复suspend_noirq和suspend_late阶段保存的东西
dpm_resume_end():执行各设备的resume和complete回调接口,做suspend和prepare的逆操作
唤醒时,设备从链表中的转移顺序是上述suspend阶段顺序的逆序。
3 低功耗接口是如何调用到各设备驱动注册的回调函数的
系统进入睡眠前回调设备的回调函数是有选择的:
如果dev->pm_domain域的回调函数注册的话,首选此处的回调函数
否则,如果dev->type域和dev->type->pm域都注册的话,会选择dev->type->pm处的回调函数
否则,如果dev->class 和 dev->class->pm两处都注册回调函数的话,会选择dev->class->pm的回调函数
如果dev->bus 和 dev->bus->pm两处都注册回调函数的话,会选择dev->bus->pm的回调函数
示例方法1和方法4:
3.1 在dev域的电源域进行注册
struct platform_device {
const char * name;
int id;
bool id_auto;
struct device dev;
u32 num_resources;
struct resource * resource;
const struct platform_device_id *id_entry;
/* MFD cell pointer */
struct mfd_cell *mfd_cell;
/* arch specific additions */
struct pdev_archdata archdata;
};
struct device {
struct device *parent;
struct device_private *p;
struct kobject kobj;
const char *init_name; /* initial name of the device */
const struct device_type *type;
struct mutex mutex; /* mutex to synchronize calls to
* its driver.*/
struct bus_type *bus; /* type of bus device is on */
struct device_driver *driver; /* which driver has allocated this device */
void *platform_data; /* Platform specific data, device core doesn't touch it */
struct dev_pm_info power;
struct dev_pm_domain *pm_domain;
…….}
struct dev_pm_domain {
struct dev_pm_ops ops;
};
struct dev_pm_ops {
int (*prepare)(struct device *dev);
void (*complete)(struct device *dev);
int (*suspend)(struct device *dev);
int (*resume)(struct device *dev);
int (*freeze)(struct device *dev);
int (*thaw)(struct device *dev);
int (*poweroff)(struct device *dev);
int (*restore)(struct device *dev);
int (*suspend_late)(struct device *dev);
int (*resume_early)(struct device *dev);
int (*freeze_late)(struct device *dev);
int (*thaw_early)(struct device *dev);
int (*poweroff_late)(struct device *dev);
int (*restore_early)(struct device *dev);
int (*suspend_noirq)(struct device *dev);
int (*resume_noirq)(struct device *dev);
int (*freeze_noirq)(struct device *dev);
int (*thaw_noirq)(struct device *dev);
int (*poweroff_noirq)(struct device *dev);
int (*restore_noirq)(struct device *dev);
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
};
低功耗接口在函数__device_suspend函数内会首先调用在struct device电源域注册的回调函数。
唤醒时调用顺序:
3.2 在bus域的ops电源域进行注册
注册设备和注册驱动进行匹配成功后
Platform_device->device->device_driver指针会指向platform_driver->driver成员
设备注册:
(1)int platform_device_add(struct platform_device *pdev)
{
……………
if (!pdev->dev.parent)
pdev->dev.parent = &platform_bus;
pdev->dev.bus = &platform_bus_type;
…………..
}
(2)struct bus_type platform_bus_type = {
.name = "platform",
.dev_attrs = platform_dev_attrs,
.match = platform_match,
.uevent = platform_uevent,
.pm = &platform_dev_pm_ops,
};
(3)static const struct dev_pm_ops platform_dev_pm_ops = {
.runtime_suspend = pm_generic_runtime_suspend,
.runtime_resume = pm_generic_runtime_resume,
.runtime_idle = pm_generic_runtime_idle,
USE_PLATFORM_PM_SLEEP_OPS
};
(4)#define USE_PLATFORM_PM_SLEEP_OPS \
.suspend = platform_pm_suspend, \
.resume = platform_pm_resume, \
.freeze = platform_pm_freeze, \
.thaw = platform_pm_thaw, \
.poweroff = platform_pm_poweroff, \
.restore = platform_pm_restore,
(5) int platform_pm_suspend(struct device *dev)
{
struct device_driver *drv = dev->driver;
int ret = 0;
if (!drv)
return 0;
if (drv->pm) {
if (drv->pm->suspend)
ret = drv->pm->suspend(dev);
} else {
ret = platform_legacy_suspend(dev, PMSG_SUSPEND);
}
return ret;
}
linux dpm机制分析(下)【转】的更多相关文章
- linux dpm机制分析(上)【转】
转自:http://blog.csdn.net/lixiaojie1012/article/details/23707681 1 DPM介绍 1.1 Dpm: 设备电源管理, ...
- 【原创】Linux信号量机制分析
背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...
- 【转】Linux Writeback机制分析
1. bdi是什么? bdi,即是backing device info的缩写,顾名思义它描述备用存储设备相关描述信息,这在内核代码里用一个结构体backing_dev_info来表示. bdi,备用 ...
- 【原创】Linux Mutex机制分析
背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...
- 仿照linux dpm机制,实现自己的dpm【转】
转自:http://blog.csdn.net/lixiaojie1012/article/details/23788713 前边我们讨论分析了linux 内核的dpm实现,分析的目的在于学以致用:在 ...
- Linux mips64r2 PCI中断路由机制分析
Linux mips64r2 PCI中断路由机制分析 本文主要分析mips64r2 PCI设备中断路由原理和irq号分配实现方法,并尝试回答如下问题: PCI设备驱动中断注册(request_irq) ...
- linux内核3.4基于wakeup_source的autosleep机制分析
点击打开链接 一:wakeup_source简介: linux 3.4内核PM使用了wakeup_source来保持唤醒状态,也就是keep awake.之前android一直是基于Linux加入了w ...
- Linux信号(signal) 机制分析
Linux信号(signal) 机制分析 [摘要]本文分析了Linux内核对于信号的实现机制和应用层的相关处理.首先介绍了软中断信号的本质及信号的两种不同分类方法尤其是不可靠信号的原理.接着分析了内核 ...
- Linux内核态抢占机制分析(转)
Linux内核态抢占机制分析 http://blog.sina.com.cn/s/blog_502c8cc401012pxj.html 摘 要]本文首先介绍非抢占式内核(Non-Preemptive ...
随机推荐
- WPF以access为数据库,简单实现一个显示数据和更新数据的实例
做一个小实例,如下图,
- 命名空间(namespace)// 友元函数
17.2.命名空间 命名空间(namespace)为防止名字冲突提供了更加可控的机制.命名空间能够划分全局命名空间,这样使用独立开发的库更加容易了.一个命名空间就是一个作用域,通过在命名空间内部定义库 ...
- bzoj4760[USACO2017 Jan]Hoof,Paper,Scissors
题意:玩n次剪刀石头布,对方每次出什么已经知道了.你出的招数必须是连续的几段(不能超过k+1段),问你最多赢几次.(n<=100000,k<=20) 正常做法:f[i][j][k]表示前i ...
- 【bzoj1704】[Usaco2007 Mar]Face The Right Way 自动转身机 贪心
题目描述 农夫约翰有N(1≤N≤5000)只牛站成一排,有一些很乖的牛朝前站着.但是有些不乖的牛却朝后站着.农夫约翰需要让所有的牛都朝前站着.幸运的是约翰最近买了一个自动转身机.这个神奇的机器能使K( ...
- 【bzoj1901】Zju2112 Dynamic Rankings 离散化+主席树+树状数组
题目描述 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是多少(1≤k≤ ...
- BZOJ4653 & 洛谷1712 & UOJ222:[NOI2016]区间——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=4653 https://www.luogu.org/problemnew/show/P1712 ht ...
- BZOJ1486:[HNOI2009]最小圈——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=1486 https://www.luogu.org/problemnew/show/P3199 题面 ...
- lighttpd - 配置文件
转载其他网站,收藏查看! 配置文件lighttpd.conf参数详细说明的链接和选译 发表于 2010年12月22日 http://redmine.lighttpd.net/projects/ligh ...
- X day4
题目 官方题解 T1: 单调栈,单调队列因为认为考场上会写崩所以写了一个十分暴力的方法(线段树) 然后做一做区间覆盖即可 #include<iostream> #include<cs ...
- 纯CSS实现的风车转动效果特效演示
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...