ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

总线,设备,驱动模型架构与paltfrom平台总线

2022-03-08 22:02:10  阅读:205  来源: 互联网

标签:架构 paltfrom 总线 probe driver platform bus device struct


驱动通用架构

注册总线

bus_register:bus_type_private的初始化,在这条总线目录下创建/bus/busname,/device, /driver 目录,初始化这条总线上的设备链表:struct klist klist_devices;初始化这条总线上的驱动链表:struct klist klist_drivers

注册驱动

driver_register->bus_add_driver->driver_attach->bus_for_each_dev->__driver_attach->driver_match_device/driver_probe_device->really_probe->(dev->bus->probe|drv->probe)

注册设备

device_register->device_add->bus_add_device/bus_probe_device->device_initial_probe->__device_attach->bus_for_each_drv->__device_attach_driver->driver_match_device/driver_probe_device

 

paltform总线

平台总线

kernel_init->do_basic_setup->driver_init(先于do_initcalls执行)->platform_bus_init(device_register(&platform_bus);bus_register(&platform_bus_type))

平台设备platform_device

arch_initcall(customize_machine)会把根的子节点都转换成platform_device节点;下图的两种方式都是从根节点遍历子节点,分配struct platform_device的内存,还分配了该platform device需要的resource的内存,加入统一设备模型系统中

 

设备树中的reg和interrupts资源将会被转换成platform_device内的struct resources资源;其他属性:platform_device->struct device dev->struct device_node *of_node直接指向设备树转换来的device_node

平台驱动platform_driver

platform_driver_register(struct platform_driver *drv)->driver_register(struct device_driver * drv)

匹配过程

先用设备树中的 compatible 属性和platform_driver中的driver中的 of_match_table 来匹配

再用 platform_driver 中的 id_table 中的 name 和 platform_device 中的 name来匹配

或者用platform_device中的name和 platform_driver 中的 driver 中的 name来匹配

 

 

标签:架构,paltfrom,总线,probe,driver,platform,bus,device,struct
来源: https://www.cnblogs.com/lzd626/p/15982693.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有