内核主要通过dev_pm_ops和dev_pm_info两个数据结构执行设备电源管理功能,其中dev_pm_ops结构体包含了在系统挂起和恢复流程的不同阶段,需要调用的设备相关回调函数。它一共包含两种类型函数,大部分普通回调用于通用系统休眠流程,而runtime_xxx格式的回调用于动态电源管理流程。以下为其结构体定义: struct dev_pm_ops ...
dev_pm_ops 结构体中,有3个以 runtime 开头的成员函数:runtime_suspend()、runtime_resume()和runtime_idle(),它们辅助设备完成运行时的电源管理: 运行时 PM 与前文描述的系统级挂起到 RAM 时候的PM不太一样,它是针对单个设备,指系统在非睡眠状态的情况下,某个设备在空闲时可以进入运行时挂起状态,而在不...
Linux设备模型中的很多数据结构,都会包含struct dev_pm_ops变量,具体如下: 1:structbus_type { 2:... 3:conststructdev_pm_ops *pm; 4:... 5:}; 6: 7:structdevice_driver { 8:... 9:conststructdev_pm_ops *pm; 10:... 11:}; 12: 13:structclass{ 14:... 15:conststructdev_pm_ops ...
pm = S3C24XX_DEV_PM_OPS, }, }; static int __init i2c_adap_s3c_init(void) { return platform_driver_register(&s3c24xx_i2c_driver); } subsys_initcall(i2c_adap_s3c_init); 这里定义并注册了针对该款芯片的的 platform driver,同时: void __init exynos4_map_io(void) { ... /* The I2C...
子系统和驱动程序的设备电源管理操作,都定义在dev_pm_ops结构中,这个结构在include/linux/pm.h中定义: struct dev_pm_ops { int (*prepare)(struct device *dev); void (*complete)(struct device *dev); int (*suspend)(struct device *dev); ...
const struct dev_pm_ops *pm; struct driver_private *p; }; 其中: const char *name; 用于和硬件进行匹配。 内核描述硬件,必须包含struct device结构体成员: struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; /* initial name of the devi...
而直接填充platform_driver的suspend()、resume()做电源管理回调的方法目前已经过时,较好的做法是实现platfrom_driver的device_driver中dev_pm_ops结构体成员(详细的参考电源管理章节)。 2.2.1 device_driver 结构体 与platform_driver地位对等的i2c_driver、spi_driver、usb_driver、pci_driver中都包含了device_driver结...
先来看一个非常重要的数据结构,这个数据结构是内核为device电源管理所抽象出来的回调函数,我们关心最后三个即可,即runtime_pm方法,设备的suspend和resume最终都调用该结构体下的某个函数。 structdev_pm_ops{int(*prepare)(struct device *dev);void(*complete)(struct device *dev);int(*suspend)(struct device ...
leds_class- >pm = &leds_class_dev_pm_ops; leds_class- >dev_groups = led_groups;return0; } 它创建了一个名为"leds"的设备类,并设置了与电源管理相关的操作函数和设备属性组。通过这个初始化过程,LED设备驱动程序可以注册到该设备类,并与LED子系统进行交互。
平台驱动rockchip-drm匹配到设备树,会到设备树dts查找ports节点和iommus节点,使用component_master_add_with_match函数注册自己到component框架中,设置了rockchip_drm_ops,其component可以通过component_add函数增加, master匹配上所有component后,会调用master的bind回调函数,最后通过drm_dev_register()函数注册到DRM core。